Initial commit - restaurant dashboard
هذا الالتزام موجود في:
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Typography,
|
||||
@@ -11,10 +11,56 @@ import {
|
||||
Radio
|
||||
} from '@mui/material';
|
||||
|
||||
const RequiredEquipments = ({ currentStepIndex = 0, onNext, onBack }) => {
|
||||
const RequiredEquipments = ({ currentStepIndex = 0, onNext, onBack, formData, updateFormData }) => {
|
||||
const theme = useTheme();
|
||||
const [errors, setErrors] = useState({});
|
||||
|
||||
const [selectedDays, setSelectedDays] = useState([]);
|
||||
// تعيين القيمة الافتراضية لـ needSpecializedEquipment إذا غير موجودة
|
||||
useEffect(() => {
|
||||
if (!formData.needSpecializedEquipment) {
|
||||
updateFormData({ needSpecializedEquipment: 'no' });
|
||||
}
|
||||
}, [formData.needSpecializedEquipment, updateFormData]);
|
||||
|
||||
// التعامل مع تغير القيمة النصية للمعدات العامة
|
||||
const handleEquipmentChange = (e) => {
|
||||
updateFormData({ equipment: e.target.value });
|
||||
};
|
||||
|
||||
|
||||
const handleNeedSpecializedChange = (e) => {
|
||||
updateFormData({ needSpecializedEquipment: e.target.value });
|
||||
};
|
||||
|
||||
// التعامل مع القيمة النصية للمعدات المتخصصة
|
||||
const handleSpecializedEquipmentChange = (e) => {
|
||||
updateFormData({ specialized_equipment: e.target.value });
|
||||
};
|
||||
|
||||
// دالة التحقق من صحة الحقول
|
||||
const validate = () => {
|
||||
let tempErrors = {};
|
||||
|
||||
// if (!formData.equipment || formData.equipment.trim() === '') {
|
||||
// tempErrors.equipment = 'Equipment is required';
|
||||
// }
|
||||
// if (!formData.needSpecializedEquipment || (formData.needSpecializedEquipment !== 'yes' && formData.needSpecializedEquipment !== 'no')) {
|
||||
// tempErrors.needSpecializedEquipment = 'Please select Yes or No';
|
||||
// }
|
||||
if (formData.needSpecializedEquipment === 'yes' && (!formData.specialized_equipment || formData.specialized_equipment.trim() === '')) {
|
||||
tempErrors.specialized_equipment = 'Please specify specialized equipments';
|
||||
}
|
||||
|
||||
setErrors(tempErrors);
|
||||
return Object.keys(tempErrors).length === 0;
|
||||
};
|
||||
|
||||
// دالة معالجة الضغط على زر Next مع تحقق الفالديشن
|
||||
const handleNext = () => {
|
||||
if (validate()) {
|
||||
onNext();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box
|
||||
@@ -56,15 +102,19 @@ const RequiredEquipments = ({ currentStepIndex = 0, onNext, onBack }) => {
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
{/* Operational Hours Input */}
|
||||
{/* Equipment Input */}
|
||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
|
||||
<Typography variant="body2" color="black" sx={{ fontWeight: '500', fontSize: '16px' }}>
|
||||
Equipment
|
||||
</Typography>
|
||||
<TextField
|
||||
placeholder=" Ovens Refrigerators Pizza Machines |"
|
||||
placeholder="Ovens Refrigerators Pizza Machines |"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
value={formData.equipment || ''}
|
||||
onChange={handleEquipmentChange}
|
||||
error={!!errors.equipment}
|
||||
helperText={errors.equipment}
|
||||
sx={{
|
||||
'& input': { fontWeight: 500, fontSize: '15px' },
|
||||
'& input::placeholder': { color: '#969BA7' },
|
||||
@@ -84,22 +134,27 @@ const RequiredEquipments = ({ currentStepIndex = 0, onNext, onBack }) => {
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Box sx={{}}>
|
||||
{/* Need Specialized Equipment */}
|
||||
<Box>
|
||||
<Typography
|
||||
variant="body2"
|
||||
sx={{ fontWeight: 500, fontSize: '16px', mb: 1, mt: 2, color: '#191635' }}
|
||||
>
|
||||
Need Specialized Equipment
|
||||
</Typography>
|
||||
<RadioGroup row name="additionalFacilities">
|
||||
<RadioGroup
|
||||
row
|
||||
name="needSpecializedEquipment"
|
||||
value={formData.needSpecializedEquipment || 'no'}
|
||||
onChange={handleNeedSpecializedChange}
|
||||
>
|
||||
<FormControlLabel
|
||||
value="yes"
|
||||
control={
|
||||
<Radio
|
||||
sx={{
|
||||
|
||||
color: 'rgba(150, 155, 167, 0.6)', // شفافية اللون
|
||||
transform: 'scale(0.85)', // تقليل حجم الزر لتقليل "سُمك الحواف"
|
||||
color: 'rgba(150, 155, 167, 0.6)',
|
||||
transform: 'scale(0.85)',
|
||||
'&.Mui-checked': {
|
||||
color: theme.palette.primary.main
|
||||
}
|
||||
@@ -125,53 +180,62 @@ const RequiredEquipments = ({ currentStepIndex = 0, onNext, onBack }) => {
|
||||
label="No"
|
||||
/>
|
||||
</RadioGroup>
|
||||
{errors.needSpecializedEquipment && (
|
||||
<Typography color="error" variant="caption" sx={{ mt: 0.5 }}>
|
||||
{errors.needSpecializedEquipment}
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
|
||||
|
||||
{/* Specialized Equipments For Food Preparation Input */}
|
||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
|
||||
<Typography variant="body2" sx={{ fontWeight: 500, fontSize: '16px' }}>
|
||||
Specialized Equipments For Food Preparation
|
||||
</Typography>
|
||||
<TextField
|
||||
placeholder="Knife Spoon Handle |"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
multiline
|
||||
minRows={3}
|
||||
sx={{
|
||||
'& .MuiInputBase-root': {
|
||||
fontWeight: 500,
|
||||
fontSize: '15px',
|
||||
alignItems: 'start',
|
||||
},
|
||||
'& textarea::placeholder': {
|
||||
color: '#969BA7',
|
||||
},
|
||||
'& .MuiOutlinedInput-root': {
|
||||
borderRadius: '10px',
|
||||
transition: '0.3s',
|
||||
'&.Mui-focused fieldset': {
|
||||
borderColor: theme.palette.primary.main,
|
||||
boxShadow: '0 0 0 2px rgba(255, 145, 77, 0.2)',
|
||||
{/* Specialized Equipments For Food Preparation */}
|
||||
{formData.needSpecializedEquipment === 'yes' && (
|
||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
|
||||
<Typography variant="body2" sx={{ fontWeight: 500, fontSize: '16px' }}>
|
||||
Specialized Equipments For Food Preparation
|
||||
</Typography>
|
||||
<TextField
|
||||
placeholder="Knife Spoon Handle |"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
multiline
|
||||
minRows={3}
|
||||
value={formData.specialized_equipment || ''}
|
||||
onChange={handleSpecializedEquipmentChange}
|
||||
error={!!errors.specialized_equipment}
|
||||
helperText={errors.specialized_equipment
|
||||
}
|
||||
sx={{
|
||||
'& .MuiInputBase-root': {
|
||||
fontWeight: 500,
|
||||
fontSize: '15px',
|
||||
alignItems: 'start',
|
||||
},
|
||||
},
|
||||
'& .MuiOutlinedInput-root.Mui-focused': {
|
||||
borderColor: '#3f51b5',
|
||||
boxShadow: '0 0 0 2px rgba(63,81,181,0.1)',
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{/* Next Button */}
|
||||
'& textarea::placeholder': {
|
||||
color: '#969BA7',
|
||||
},
|
||||
'& .MuiOutlinedInput-root': {
|
||||
borderRadius: '10px',
|
||||
transition: '0.3s',
|
||||
'&.Mui-focused fieldset': {
|
||||
borderColor: theme.palette.primary.main,
|
||||
boxShadow: '0 0 0 2px rgba(255, 145, 77, 0.2)',
|
||||
},
|
||||
},
|
||||
'& .MuiOutlinedInput-root.Mui-focused': {
|
||||
borderColor: '#3f51b5',
|
||||
boxShadow: '0 0 0 2px rgba(63,81,181,0.1)',
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Buttons */}
|
||||
<Box sx={{ pt: 2 }}>
|
||||
<Button
|
||||
variant="contained"
|
||||
fullWidth
|
||||
onClick={onNext}
|
||||
onClick={handleNext}
|
||||
sx={{
|
||||
fontFamily: 'PlusJakartaSans',
|
||||
fontWeight: 600,
|
||||
@@ -189,7 +253,6 @@ const RequiredEquipments = ({ currentStepIndex = 0, onNext, onBack }) => {
|
||||
Next
|
||||
</Button>
|
||||
|
||||
{/* زر Back تحت زر Next */}
|
||||
<Button
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
@@ -202,7 +265,7 @@ const RequiredEquipments = ({ currentStepIndex = 0, onNext, onBack }) => {
|
||||
height: { xs: '45px', sm: '52px' },
|
||||
borderRadius: '50px',
|
||||
textTransform: 'none',
|
||||
display: { xs: 'block', sm: 'block', md: 'none' }, // يظهر فقط في xs و sm
|
||||
display: { xs: 'block', sm: 'block', md: 'none' },
|
||||
borderColor: theme.palette.primary.main,
|
||||
color: theme.palette.primary.main,
|
||||
'&:hover': {
|
||||
@@ -214,7 +277,6 @@ const RequiredEquipments = ({ currentStepIndex = 0, onNext, onBack }) => {
|
||||
Back
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
</Stack>
|
||||
</Box>
|
||||
);
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم