diff --git a/components/AdminWebContents.tsx b/components/AdminWebContents.tsx index b70f2dd..ea4af67 100644 --- a/components/AdminWebContents.tsx +++ b/components/AdminWebContents.tsx @@ -9,7 +9,6 @@ import { getContents } from "@/utils/commonApi"; import { toast } from "sonner"; export default function AdminWebContents() { - const [contentValueCall, setContentValueCall] = useState(""); const [contentValueAbout, setContentValueAbout] = useState(""); const [contentValueAfter, setContentValueAfter] = useState(""); @@ -25,7 +24,7 @@ export default function AdminWebContents() { const [contentTitle, setContentTitle] = useState(""); const [contentDesc, setContentDesc] = useState(""); - + var toolbarOptions = [ ["bold", "italic", "underline", "strike"], // toggled buttons ["blockquote", "code-block"], @@ -75,40 +74,38 @@ export default function AdminWebContents() { queryFn: () => getContents(), refetchOnWindowFocus: false, }); - - + useEffect(() => { // if (isInitialRender2 && isSuccess1) { - if (isSuccess1) { + if (isSuccess1) { // { - data1?.map((item: any) => { - if (item.title === "CallUs") { - setContentValueCall(item.content); - setCallId(item.id); - setCallBtn("Edit"); - } + data1?.map((item: any) => { + if (item.title === "CallUs") { + setContentValueCall(item.content); + setCallId(item.id); + setCallBtn("Edit"); + } - if (item.title === "AboutUs") { - setContentValueAbout(item.content); - setAboutId(item.id); - setAboutBtn("Edit"); - } + if (item.title === "AboutUs") { + setContentValueAbout(item.content); + setAboutId(item.id); + setAboutBtn("Edit"); + } - if (item.title === "AfterRegistration") { - setContentValueAfter(item.content); - setAfterId(item.id); - setAfterBtn("Edit"); - } + if (item.title === "AfterRegistration") { + setContentValueAfter(item.content); + setAfterId(item.id); + setAfterBtn("Edit"); + } - if (item.title === "BeforeRegistration") { - setContentValueBefore(item.content); - setBeforeId(item.id); - setBeforeBtn("Edit"); - } - }); + if (item.title === "BeforeRegistration") { + setContentValueBefore(item.content); + setBeforeId(item.id); + setBeforeBtn("Edit"); + } + }); } - }, [isSuccess1 , refetch1]); - + }, [isSuccess1, refetch1]); // Add // ............'Mutation' Change Key Submit @@ -131,7 +128,6 @@ export default function AdminWebContents() { className: "!bg-red-500 !text-white", }); refetch1(); - }, }); @@ -140,7 +136,6 @@ export default function AdminWebContents() { mutationKey: ["EditWebContents"], mutationFn: UpdateWebContents, onSuccess: (res) => { - toast("عملیات ویرایش شما با موفقیت انجام شد . ", { className: "!bg-green-500 !text-white", }); @@ -216,7 +211,7 @@ export default function AdminWebContents() { formData.append("title", "AfterRegistration"); formData.append("description", "AfterRegistration...."); formData.append("Content", contentValueAfter); - EditWebContents.mutate({ id: afterId, payload: formData }); + EditWebContents.mutate({ id: afterId, payload: formData }); } function onEditBeforeText() { @@ -229,7 +224,7 @@ export default function AdminWebContents() { return (