diff --git a/package.json b/package.json index e89f543..c685cf4 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "private": true, "version": "0.0.0", "type": "module", - "packageManager": "pnpm@9.12.3", + "packageManager": "pnpm@9.12.1", "scripts": { "dev": "vite --port 4000 --host 0.0.0.0", "build": "tsc && vite build", diff --git a/src/pages/lectures/LectureDetails.tsx b/src/pages/lectures/LectureDetails.tsx index 52a599c..2b01fa0 100644 --- a/src/pages/lectures/LectureDetails.tsx +++ b/src/pages/lectures/LectureDetails.tsx @@ -60,8 +60,8 @@ function LectureDetails() { }); const [activeValue, setActiveValue] = useState({ - label: topics?.[0].title, - value: topics?.[0].id.toString(), + label: topics?.[0]?.title, + value: topics?.[0]?.id.toString(), }); const topicOptions = useMemo( @@ -145,8 +145,8 @@ function LectureDetails() { useEffect(() => { if (!existingLecture || !id) { setActiveValue({ - label: topics?.[0].title, - value: topics?.[0].id.toString(), + label: topics?.[0]?.title, + value: topics?.[0]?.id.toString(), }); } diff --git a/src/pages/methodologies/MethodologyDetails.tsx b/src/pages/methodologies/MethodologyDetails.tsx index 33e1ede..0a155e6 100644 --- a/src/pages/methodologies/MethodologyDetails.tsx +++ b/src/pages/methodologies/MethodologyDetails.tsx @@ -75,8 +75,8 @@ export default function MethodologyDetails() { const { data: topics, isLoading: isTopicsLoading } = useTopicsQuery({}); const [activeTopic, setActiveTopic] = useState({ - label: topics?.[0].title, - value: topics?.[0].id.toString(), + label: topics?.[0]?.title, + value: topics?.[0]?.id.toString(), }); const topicOptions = useMemo( @@ -121,8 +121,8 @@ export default function MethodologyDetails() { useEffect(() => { if (!methodology || !id) { setActiveTopic({ - label: topics?.[0].title, - value: topics?.[0].id.toString(), + label: topics?.[0]?.title, + value: topics?.[0]?.id.toString(), }); } diff --git a/src/pages/presentations/PresentationDetails.tsx b/src/pages/presentations/PresentationDetails.tsx index 9a56d5d..3d47efe 100644 --- a/src/pages/presentations/PresentationDetails.tsx +++ b/src/pages/presentations/PresentationDetails.tsx @@ -77,8 +77,8 @@ export default function PresentationDetails() { const { data: topics, isLoading: isTopicsLoading } = useTopicsQuery({}); const [activeTopic, setActiveTopic] = useState({ - label: topics?.[0].title, - value: topics?.[0].id.toString(), + label: topics?.[0]?.title, + value: topics?.[0]?.id.toString(), }); const topicOptions = useMemo( @@ -123,8 +123,8 @@ export default function PresentationDetails() { useEffect(() => { if (!presentation || !id) { setActiveTopic({ - label: topics?.[0].title, - value: topics?.[0].id.toString(), + label: topics?.[0]?.title, + value: topics?.[0]?.id.toString(), }); } diff --git a/src/pages/sections/SectionDetails.tsx b/src/pages/sections/SectionDetails.tsx index e98bbca..b96af6a 100644 --- a/src/pages/sections/SectionDetails.tsx +++ b/src/pages/sections/SectionDetails.tsx @@ -37,8 +37,8 @@ function SectionDetails() { const { data: subjects, isFetching } = useSubjectsQuery({}); const [activeValue, setActiveValue] = useState({ - label: subjects?.[0].title, - value: subjects?.[0].id.toString(), + label: subjects?.[0]?.title, + value: subjects?.[0]?.id.toString(), }); const subjectOptions = useMemo( @@ -122,13 +122,13 @@ function SectionDetails() { useEffect(() => { if (!existingSection || !id) { setActiveValue({ - label: subjects?.[0].title, - value: subjects?.[0].id.toString(), + label: subjects?.[0]?.title, + value: subjects?.[0]?.id.toString(), }); } if (subjects) { - sectionForm.setValue("subjectId", subjects[0].id); + sectionForm.setValue("subjectId", subjects[0]?.id); } }, [subjects, sectionForm, existingSection, id]); diff --git a/src/pages/tasks/TaskDetails.tsx b/src/pages/tasks/TaskDetails.tsx index a963edd..0f69ce8 100644 --- a/src/pages/tasks/TaskDetails.tsx +++ b/src/pages/tasks/TaskDetails.tsx @@ -54,8 +54,8 @@ function TaskDetails() { const { data: topics, isLoading: isTopicsLoading } = useTopicsQuery({}); const [activeValue, setActiveValue] = useState({ - label: topics?.[0].title, - value: topics?.[0].id.toString(), + label: topics?.[0]?.title, + value: topics?.[0]?.id.toString(), }); const topicOptions = useMemo( @@ -150,13 +150,13 @@ function TaskDetails() { useEffect(() => { if (!existingTask || !id) { setActiveValue({ - label: topics?.[0].title, - value: topics?.[0].id.toString(), + label: topics?.[0]?.title, + value: topics?.[0]?.id.toString(), }); } if (topics) { - taskForm.setValue("topicId", topics[0].id); + taskForm.setValue("topicId", topics[0]?.id); } }, [topics, taskForm, existingTask, id]); diff --git a/src/pages/topics/TopicDetails.tsx b/src/pages/topics/TopicDetails.tsx index 01b6020..114b1bb 100644 --- a/src/pages/topics/TopicDetails.tsx +++ b/src/pages/topics/TopicDetails.tsx @@ -62,8 +62,8 @@ function TopicDetails() { >(topicContent || []); const [activeValue, setActiveValue] = useState({ - label: sections?.[0].title, - value: sections?.[0].id.toString(), + label: sections?.[0]?.title, + value: sections?.[0]?.id.toString(), }); const topicContentIds = useMemo( @@ -170,13 +170,13 @@ function TopicDetails() { useEffect(() => { if (!existingTopic || !id) { setActiveValue({ - label: sections?.[0].title, - value: sections?.[0].id.toString(), + label: sections?.[0]?.title, + value: sections?.[0]?.id.toString(), }); } if (sections) { - topicForm.setValue("sectionId", sections[0].id); + topicForm.setValue("sectionId", sections[0]?.id); } }, [sections, topicForm, existingTopic, id]);