Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
VJagiasi committed Jul 20, 2024
1 parent 735e888 commit 22e635d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 32 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ services:
- ./db-init:/docker-entrypoint-initdb.d

volumes:
postgres_data:
postgres_data:
17 changes: 9 additions & 8 deletions src/components/InputForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Input,
FormControl,
FormLabel,
Text
Text,
} from '@chakra-ui/react';

interface Absence {
Expand Down Expand Up @@ -36,7 +36,7 @@ const InputForm: React.FC<InputFormProps> = ({
const [substituteTeacherId, setSubstituteTeacherId] = useState('');
const [locationId, setLocationId] = useState('');
const [subjectId, setSubjectId] = useState('');
const [error, setError] = useState('')
const [error, setError] = useState('');

const handleAddAbsence = async (e: React.FormEvent) => {
e.preventDefault();
Expand All @@ -51,7 +51,7 @@ const InputForm: React.FC<InputFormProps> = ({
locationId: parseInt(locationId, 10),
subjectId: parseInt(subjectId, 10),
};
const success = await onAddAbsence(newAbsence);
const success = await onAddAbsence(newAbsence);
if (success) {
setLessonPlan('');
setReasonOfAbsence('');
Expand All @@ -60,10 +60,9 @@ const InputForm: React.FC<InputFormProps> = ({
setLocationId('');
setSubjectId('');
onClose();
}
else {
} else {
setError('Invalid input. Please enter correct details.');
}
}
};

return (
Expand Down Expand Up @@ -130,10 +129,12 @@ const InputForm: React.FC<InputFormProps> = ({
onChange={(e) => setSubjectId(e.target.value)}
required
color="black"
/>
/>
</FormControl>
{error && (
<Text color="red.500" mt={2}>{error}</Text>
<Text color="red.500" mt={2}>
{error}
</Text>
)}
<Button type="submit">Add Absence</Button>
</Box>
Expand Down
6 changes: 3 additions & 3 deletions src/pages/api/absence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default async function handler(
if (req.method === 'GET') {
try {
const absences = await prisma.absence.findMany();

res.status(200).json({ absences });
} catch (error) {
res
Expand All @@ -25,7 +25,7 @@ export default async function handler(
absentTeacherId,
substituteTeacherId,
locationId,
subjectId
subjectId,
} = req.body;
try {
const newAbsence = await prisma.absence.create({
Expand All @@ -36,7 +36,7 @@ export default async function handler(
absentTeacherId,
substituteTeacherId,
locationId,
subjectId
subjectId,
},
});

Expand Down
12 changes: 6 additions & 6 deletions src/pages/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface Absence {
reasonOfAbsence: string;
absentTeacherId: number;
substituteTeacherId: number | null;
subjectId: number,
subjectId: number;
locationId: number;
newAbsence?: Omit<Absence, 'id'>;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ function CalendarView() {
},
body: JSON.stringify(absence),
});

if (response.ok) {
const newAbsence = await response.json();
setAbsences([
Expand All @@ -169,18 +169,17 @@ function CalendarView() {
},
]);
setIsFormOpen(false);
return true;
return true;
} else {
const errorResponse = await response.json();
console.error('Error response:', response.status, errorResponse);
return false;
return false;
}
} catch (error) {
console.error('Error adding absence:', error);
return false;
}
};


const renderWeekView = (date: Date) => {
const startOfWeek = new Date(date);
Expand Down Expand Up @@ -232,7 +231,8 @@ function CalendarView() {
<Text as="h2">{date.toDateString()}</Text>
{absences
.filter(
(absence) => absence.lessonDate.toDateString() === date.toDateString()
(absence) =>
absence.lessonDate.toDateString() === date.toDateString()
)
.map((absence, index) => (
<Box key={index} p={4} borderWidth="1px" borderRadius="lg" mb={4}>
Expand Down
17 changes: 3 additions & 14 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
Expand All @@ -26,13 +22,6 @@
],
"strictNullChecks": true
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}

0 comments on commit 22e635d

Please sign in to comment.