diff --git a/src/views/ChoreEdit/ChoreEdit.jsx b/src/views/ChoreEdit/ChoreEdit.jsx index 4349e70..31a8c1f 100644 --- a/src/views/ChoreEdit/ChoreEdit.jsx +++ b/src/views/ChoreEdit/ChoreEdit.jsx @@ -1,4 +1,9 @@ -import { Add, HorizontalRule } from '@mui/icons-material' +import { + Add, + ChevronRight, + ExpandMore, + HorizontalRule, +} from '@mui/icons-material' import { Box, Button, @@ -102,6 +107,12 @@ const ChoreEdit = () => { const [errors, setErrors] = useState({}) const [attemptToSave, setAttemptToSave] = useState(false) const [addLabelModalOpen, setAddLabelModalOpen] = useState(false) + const [expandedSections, setExpandedSections] = useState({ + basicInfo: true, + assignment: true, + schedule: true, + taskSettings: true, + }) const { data: userLabelsRaw, isLoading: isUserLabelsLoading } = useLabels() const updateChoreMutation = useUpdateChore() const createChoreMutation = useCreateChore() @@ -124,6 +135,83 @@ const ChoreEdit = () => { const Navigate = useNavigate() + const toggleSection = sectionKey => { + setExpandedSections(prev => ({ + ...prev, + [sectionKey]: !prev[sectionKey], + })) + } + + const CollapsibleSection = ({ sectionKey, title, subtitle, children }) => { + const isExpanded = expandedSections[sectionKey] + + return ( + + toggleSection(sectionKey)} + sx={{ + display: 'flex', + alignItems: 'center', + cursor: 'pointer', + p: 2, + borderRadius: 'md', + backgroundColor: 'background.level1', + border: '1px solid', + borderColor: 'divider', + mb: isExpanded ? 2 : 0, + transition: 'all 0.2s ease-in-out', + '&:hover': { + backgroundColor: 'background.level2', + borderColor: 'primary.main', + }, + }} + > + {isExpanded ? ( + + ) : ( + + )} + + + {title} + + {subtitle && ( + + {subtitle} + + )} + + + + {isExpanded && ( + + {children} + + )} + + ) + } + const HandleValidateChore = () => { const errors = {} @@ -410,15 +498,11 @@ const ChoreEdit = () => { return ( {/* Section 1: Basic Information */} - - {/* - Basic Information - */} - + Name @@ -596,18 +680,14 @@ const ChoreEdit = () => { /> - + {/* Section 2: Assignment & Responsibility */} - - - Assignment - - + Assignees Who can do this task? @@ -714,18 +794,14 @@ const ChoreEdit = () => { )} - + {/* Section 3: Schedule & Timing */} - - - Schedule & Timing - - + { )} - + {/* Section 4: Task Settings */} - - - Task Settings - - + Points System @@ -1117,7 +1189,7 @@ const ChoreEdit = () => { - + {choreId > 0 && (