Skip to content

Commit

Permalink
Fix input select options
Browse files Browse the repository at this point in the history
  • Loading branch information
akmatoff committed Nov 5, 2024
1 parent a16a6ec commit 02b2bde
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/pages/lectures/LectureDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function LectureDetails() {
});

const [activeValue, setActiveValue] = useState<IOption>({
label: topics?.[0].title,
value: topics?.[0].id.toString(),
label: topics?.[0]?.title,
value: topics?.[0]?.id.toString(),
});

const topicOptions = useMemo(
Expand Down Expand Up @@ -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(),
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/pages/methodologies/MethodologyDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export default function MethodologyDetails() {
const { data: topics, isLoading: isTopicsLoading } = useTopicsQuery({});

const [activeTopic, setActiveTopic] = useState<IOption>({
label: topics?.[0].title,
value: topics?.[0].id.toString(),
label: topics?.[0]?.title,
value: topics?.[0]?.id.toString(),
});

const topicOptions = useMemo(
Expand Down Expand Up @@ -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(),
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/pages/presentations/PresentationDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export default function PresentationDetails() {
const { data: topics, isLoading: isTopicsLoading } = useTopicsQuery({});

const [activeTopic, setActiveTopic] = useState<IOption>({
label: topics?.[0].title,
value: topics?.[0].id.toString(),
label: topics?.[0]?.title,
value: topics?.[0]?.id.toString(),
});

const topicOptions = useMemo(
Expand Down Expand Up @@ -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(),
});
}

Expand Down
10 changes: 5 additions & 5 deletions src/pages/sections/SectionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function SectionDetails() {
const { data: subjects, isFetching } = useSubjectsQuery({});

const [activeValue, setActiveValue] = useState<IOption>({
label: subjects?.[0].title,
value: subjects?.[0].id.toString(),
label: subjects?.[0]?.title,
value: subjects?.[0]?.id.toString(),
});

const subjectOptions = useMemo(
Expand Down Expand Up @@ -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]);

Expand Down
10 changes: 5 additions & 5 deletions src/pages/tasks/TaskDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function TaskDetails() {
const { data: topics, isLoading: isTopicsLoading } = useTopicsQuery({});

const [activeValue, setActiveValue] = useState<IOption>({
label: topics?.[0].title,
value: topics?.[0].id.toString(),
label: topics?.[0]?.title,
value: topics?.[0]?.id.toString(),
});

const topicOptions = useMemo(
Expand Down Expand Up @@ -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]);

Expand Down
10 changes: 5 additions & 5 deletions src/pages/topics/TopicDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ function TopicDetails() {
>(topicContent || []);

const [activeValue, setActiveValue] = useState<IOption>({
label: sections?.[0].title,
value: sections?.[0].id.toString(),
label: sections?.[0]?.title,
value: sections?.[0]?.id.toString(),
});

const topicContentIds = useMemo(
Expand Down Expand Up @@ -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]);

Expand Down

0 comments on commit 02b2bde

Please sign in to comment.