diff --git a/apps/app/src/app/(main-layout)/questions/[technology]/[page]/loading.tsx b/apps/app/src/app/(main-layout)/questions/[technology]/[page]/loading.tsx index 189c0339..768f4716 100644 --- a/apps/app/src/app/(main-layout)/questions/[technology]/[page]/loading.tsx +++ b/apps/app/src/app/(main-layout)/questions/[technology]/[page]/loading.tsx @@ -1,5 +1,5 @@ import { Loading } from "../../../../../components/Loading"; export default function LoadingQuestions() { - return ; + return ; } diff --git a/apps/app/src/components/AddQuestionModal.tsx b/apps/app/src/components/AddQuestionModal.tsx index 0a192068..1cf51461 100644 --- a/apps/app/src/components/AddQuestionModal.tsx +++ b/apps/app/src/components/AddQuestionModal.tsx @@ -54,7 +54,7 @@ export const AddQuestionModal = (props: ComponentProps) => { onSuccess: () => { setSelectData({}); setContent(""); - modalData ? closeModal() : openModal("AddQuestionConfirmationModal"); + modalData ? handleCloseModal() : openModal("AddQuestionConfirmationModal"); }, onError: () => setIsError(true), }; @@ -78,8 +78,15 @@ export const AddQuestionModal = (props: ComponentProps) => { } }; + const handleCloseModal = () => { + closeModal(); + if (modalData?.additionalActionOnClose) { + modalData.additionalActionOnClose(); + } + }; + return ( - + {modalData ? "Edytuj" : "Nowe"} pytanie @@ -135,7 +142,7 @@ export const AddQuestionModal = (props: ComponentProps) => { + + + ); +}; diff --git a/apps/app/src/components/SingleQuestion.tsx b/apps/app/src/components/SingleQuestion.tsx index e8a3b6b3..347584a6 100644 --- a/apps/app/src/components/SingleQuestion.tsx +++ b/apps/app/src/components/SingleQuestion.tsx @@ -1,19 +1,29 @@ "use client"; -import { Question } from "../types"; +import dynamic from "next/dynamic"; +import { AdminQuestion } from "../types"; import { useGetQuestionVotesById } from "../hooks/useQuestionVoting"; import { QuestionItem } from "./QuestionItem/QuestionItem"; import { QuestionVoting } from "./QuestionsList/QuestionVoting"; import { QuestionTechnology } from "./QuestionItem/QuestionTechnology"; import { QuestionLevel } from "./QuestionItem/QuestionLevel"; +const QuestionsManagement = dynamic( + () => + import( + /* webpackChunkName: "QuestionsManagement" */ "../components/QuestionsList/QuestionsManagment" + ).then((mod) => mod.QuestionsManagement), + { + ssr: false, + }, +); + type SingleQuestionProps = Readonly<{ - question: Question; + question: AdminQuestion; }>; -export const SingleQuestion = ({ - question: { id, mdxContent, _levelId, _categoryId, acceptedAt }, -}: SingleQuestionProps) => { +export const SingleQuestion = ({ question }: SingleQuestionProps) => { + const { id, mdxContent, _levelId, _categoryId, acceptedAt } = question; const { votes, voted, refetch } = useGetQuestionVotesById(id); return ( @@ -24,14 +34,17 @@ export const SingleQuestion = ({ technology={_categoryId} acceptedAt={acceptedAt} leftSection={ - { - void refetch(); - }} - /> +
+ { + void refetch(); + }} + /> + +
} rightSection={
diff --git a/apps/app/src/components/UserQuestions/UserQuestionLeftSection.tsx b/apps/app/src/components/UserQuestions/UserQuestionLeftSection.tsx index 3c3b4026..bdd1f4e0 100644 --- a/apps/app/src/components/UserQuestions/UserQuestionLeftSection.tsx +++ b/apps/app/src/components/UserQuestions/UserQuestionLeftSection.tsx @@ -1,3 +1,4 @@ +import { useEffect } from "react"; import { useUIContext } from "../../providers/UIProvider"; import { AdminQuestion } from "../../types"; import PencilIcon from "../../../public/icons/pencil.svg"; @@ -5,17 +6,26 @@ import { Button } from "../Button/Button"; type UserQuestionLeftSectionProps = Readonly<{ question: AdminQuestion; + refetchQuestions: () => void; }>; -export const UserQuestionLeftSection = ({ question }: UserQuestionLeftSectionProps) => { - const { openModal } = useUIContext(); +export const UserQuestionLeftSection = ({ + question, + refetchQuestions, +}: UserQuestionLeftSectionProps) => { + const { openModal, openedModal } = useUIContext(); return (