Skip to content

Commit

Permalink
feat: use goals table on report overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
Melichka authored and the-homeless-god committed Aug 31, 2024
1 parent 2d6a169 commit 6d1c99d
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions application/frontend/src/components/ReportOverlay/ReportOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Typography,
} from "@mui/material"

import { GoalsTable } from "../GoalsTable"
import {
Backdrop,
ButtonContainer,
Expand All @@ -30,15 +31,32 @@ interface ReportOverlayProps {
onClose: () => void
}

interface Goal {
title: string
status: string
description: string
}

export const ReportOverlay: React.FC<ReportOverlayProps> = ({ isOpen, onClose }) => {
const [tab, setTab] = useState<number>(0)
const [onVacation, setOnVacation] = useState<string>("")
const [reporterOnVacation, setReporterOnVacation] = useState<string>("")
const [goals, setGoals] = useState<Goal[]>([])

const handleTabChange = (_event: React.SyntheticEvent, newValue: number) => {
setTab(newValue)
}

const handleAddGoal = () => {
setGoals([...goals, { title: "", status: "", description: "" }])
}

const handleGoalChange = (index: number, field: keyof Goal, value: string) => {
const updatedGoals = [...goals]
updatedGoals[index][field] = value
setGoals(updatedGoals)
}

return (
<>
<Backdrop isOpen={isOpen} />
Expand Down Expand Up @@ -155,22 +173,14 @@ export const ReportOverlay: React.FC<ReportOverlayProps> = ({ isOpen, onClose })

{tab === 1 && (
<>
<TextField
fullWidth
label="Цель 1"
variant="outlined"
placeholder="Введите цель 1"
multiline
rows={4}
/>
<TextField
fullWidth
label="Цель 2"
variant="outlined"
placeholder="Введите цель 2"
multiline
rows={4}
/>
<Grid item xs={12}>
<Button variant="text" color="primary" onClick={handleAddGoal}>
+ Добавить цель
</Button>
</Grid>
<Grid item xs={12}>
<GoalsTable goals={goals} onGoalChange={handleGoalChange} />
</Grid>
</>
)}
</Grid>
Expand Down

0 comments on commit 6d1c99d

Please sign in to comment.