a Bugs fixed
parent
cf6305b6b4
commit
85a75c8dab
|
|
@ -0,0 +1,8 @@
|
|||
import AdminNews from '@/components/AdminNews'
|
||||
import React from 'react'
|
||||
|
||||
export default function page() {
|
||||
return (
|
||||
<AdminNews />
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import AdminSlider from '@/components/AdminSlider'
|
||||
import React from 'react'
|
||||
|
||||
export default function page() {
|
||||
return (
|
||||
<AdminSlider />
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import React from 'react'
|
||||
|
||||
export default function AdminNews() {
|
||||
return (
|
||||
<div>AdminNews</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import React from 'react'
|
||||
|
||||
export default function AdminSlider() {
|
||||
return (
|
||||
<div>AdminSlider</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -4,14 +4,25 @@ import { useMutation, useQuery } from "@tanstack/react-query";
|
|||
import ReactQuill from "react-quill";
|
||||
import "react-quill/dist/quill.snow.css";
|
||||
import { Button } from "./ui/button";
|
||||
import { SubmitWebContents } from "@/utils/adminApi";
|
||||
import { SubmitWebContents, UpdateWebContents } from "@/utils/adminApi";
|
||||
import { getContents } from "@/utils/commonApi";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export default function AdminWebContents() {
|
||||
const [contentValueCull, setContentValueCull] = useState("");
|
||||
|
||||
const [contentValueCall, setContentValueCall] = useState("");
|
||||
const [contentValueAbout, setContentValueAbout] = useState("");
|
||||
const [contentValueAfter, setContentValueAfter] = useState("");
|
||||
const [contentValueBefore, setContentValueBefore] = useState("");
|
||||
const [callBtn, setCallBtn] = useState("Add");
|
||||
const [aboutBtn, setAboutBtn] = useState("Add");
|
||||
const [afterBtn, setAfterBtn] = useState("Add");
|
||||
const [beforeBtn, setBeforeBtn] = useState("Add");
|
||||
const [callId, setCallId] = useState("");
|
||||
const [aboutId, setAboutId] = useState("");
|
||||
const [afterId, setAfterId] = useState("");
|
||||
const [beforeId, setBeforeId] = useState("");
|
||||
|
||||
const [contentTitle, setContentTitle] = useState("");
|
||||
const [contentDesc, setContentDesc] = useState("");
|
||||
// console.log(value);
|
||||
|
|
@ -52,6 +63,59 @@ export default function AdminWebContents() {
|
|||
direction: "ltr",
|
||||
};
|
||||
|
||||
// Get Content
|
||||
const {
|
||||
data: data1,
|
||||
error: Error1,
|
||||
isLoading: isListLoading,
|
||||
refetch: refetch1,
|
||||
isSuccess: isSuccess1,
|
||||
} = useQuery({
|
||||
queryKey: ["WebContents"],
|
||||
queryFn: () => getContents(),
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
// console.log(data1);
|
||||
|
||||
useEffect(() => {
|
||||
// if (isInitialRender2 && isSuccess1) {
|
||||
if (isSuccess1) {
|
||||
// {
|
||||
data1?.map((item: any) => {
|
||||
if (item.title === "CallUs") {
|
||||
console.log("contetn : " + item.content);
|
||||
setContentValueCall(item.content);
|
||||
setCallId(item.id);
|
||||
setCallBtn("Edit");
|
||||
}
|
||||
|
||||
if (item.title === "AboutUs") {
|
||||
console.log("contetn : " + item.content);
|
||||
setContentValueAbout(item.content);
|
||||
setAboutId(item.id);
|
||||
setAboutBtn("Edit");
|
||||
}
|
||||
|
||||
if (item.title === "AfterRegistration") {
|
||||
console.log("contetn : " + item.content);
|
||||
setContentValueAfter(item.content);
|
||||
setAfterId(item.id);
|
||||
setAfterBtn("Edit");
|
||||
}
|
||||
|
||||
if (item.title === "BeforeRegistration") {
|
||||
console.log("contetn : " + item.content);
|
||||
setContentValueBefore(item.content);
|
||||
setBeforeId(item.id);
|
||||
setBeforeBtn("Edit");
|
||||
}
|
||||
});
|
||||
// }
|
||||
console.log("contetn : " + data1);
|
||||
}
|
||||
}, [isSuccess1]);
|
||||
|
||||
|
||||
// Add
|
||||
// ............'Mutation' Change Key Submit
|
||||
const AddWebContents = useMutation({
|
||||
|
|
@ -61,14 +125,15 @@ export default function AdminWebContents() {
|
|||
console.log(res);
|
||||
console.log("Success ChangeCat");
|
||||
|
||||
setContentValueCull("");
|
||||
setContentValueCall("");
|
||||
setContentValueAbout("");
|
||||
setContentValueAfter("");
|
||||
setContentValueBefore("");
|
||||
|
||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||
toast("عملیات ثبت شما با موفقیت انجام شد. ", {
|
||||
className: "!bg-green-500 !text-white",
|
||||
});
|
||||
refetch1();
|
||||
},
|
||||
onError: (error) => {
|
||||
console.log(error);
|
||||
|
|
@ -80,22 +145,44 @@ export default function AdminWebContents() {
|
|||
},
|
||||
});
|
||||
|
||||
// function onSubmitAdd(data: typeof contentValue) {
|
||||
// ............'Mutation' Change Web Contents
|
||||
const EditWebContents = useMutation({
|
||||
mutationKey: ["EditWebContents"],
|
||||
mutationFn: UpdateWebContents,
|
||||
onSuccess: (res) => {
|
||||
console.log(res);
|
||||
console.log("Success Change UpdateWebContents");
|
||||
|
||||
|
||||
toast("عملیات ویرایش شما با موفقیت انجام شد . ", {
|
||||
className: "!bg-green-500 !text-white",
|
||||
});
|
||||
refetch1();
|
||||
},
|
||||
onError: (error) => {
|
||||
console.log(error?.message);
|
||||
|
||||
toast(error?.message, {
|
||||
className: "!bg-red-500 !text-black",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
// Add Mutation
|
||||
function onSubmitAddCallUs() {
|
||||
const formData = new FormData();
|
||||
// formData.append("title", contentTitle);
|
||||
// formData.append("description", contentDesc);
|
||||
|
||||
formData.append("title", "Test2");
|
||||
formData.append("description", "Test2....");
|
||||
formData.append("Content", contentValueCull);
|
||||
formData.append("title", "CallUs");
|
||||
formData.append("description", "CallUs....");
|
||||
formData.append("Content", contentValueCall);
|
||||
|
||||
AddWebContents.mutate(formData);
|
||||
console.log(contentValueCull);
|
||||
console.log(contentValueCall);
|
||||
// console.log(contentTitle);
|
||||
// console.log(contentDesc);
|
||||
}
|
||||
|
||||
// AboutUs
|
||||
function onSubmitAddAboutUs() {
|
||||
const formData = new FormData();
|
||||
|
|
@ -106,7 +193,6 @@ export default function AdminWebContents() {
|
|||
AddWebContents.mutate(formData);
|
||||
console.log(contentValueAbout);
|
||||
}
|
||||
|
||||
// AboutUs
|
||||
function onSubmitAddَAfterText() {
|
||||
const formData = new FormData();
|
||||
|
|
@ -117,7 +203,6 @@ export default function AdminWebContents() {
|
|||
AddWebContents.mutate(formData);
|
||||
console.log(contentValueAfter);
|
||||
}
|
||||
|
||||
// AboutUs
|
||||
function onSubmitAddBeforeText() {
|
||||
const formData = new FormData();
|
||||
|
|
@ -129,6 +214,40 @@ export default function AdminWebContents() {
|
|||
console.log(contentValueBefore);
|
||||
}
|
||||
|
||||
// Edit Mutation
|
||||
function onEditCallUs() {
|
||||
const formData = new FormData();
|
||||
formData.append("title", "CallUs");
|
||||
formData.append("description", "CallUs....");
|
||||
formData.append("Content", contentValueCall);
|
||||
EditWebContents.mutate({ id: callId, payload: formData });
|
||||
console.log("formData"+formData);
|
||||
}
|
||||
|
||||
function onEditAboutUs() {
|
||||
const formData = new FormData();
|
||||
formData.append("title", "AboutUs");
|
||||
formData.append("description", "AboutUs....");
|
||||
formData.append("Content", contentValueAbout);
|
||||
EditWebContents.mutate({ id: aboutId, payload: formData });
|
||||
}
|
||||
|
||||
function onEditAfterText() {
|
||||
const formData = new FormData();
|
||||
formData.append("title", "AfterRegistration");
|
||||
formData.append("description", "AfterRegistration....");
|
||||
formData.append("Content", contentValueAfter);
|
||||
EditWebContents.mutate({ id: afterId, payload: formData });
|
||||
console.log("formData22"+formData);
|
||||
}
|
||||
|
||||
function onEditBeforeText() {
|
||||
const formData = new FormData();
|
||||
formData.append("title", "BeforeRegistration");
|
||||
formData.append("description", "BeforeRegistration....");
|
||||
formData.append("Content", contentValueBefore);
|
||||
EditWebContents.mutate({ id: beforeId, payload: formData });
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="w-full min-h-[85vh] flex justify-center">
|
||||
|
|
@ -142,14 +261,18 @@ export default function AdminWebContents() {
|
|||
<ReactQuill
|
||||
modules={modules}
|
||||
theme="snow"
|
||||
value={contentValueCull}
|
||||
onChange={setContentValueCull}
|
||||
value={contentValueCall}
|
||||
onChange={setContentValueCall}
|
||||
style={editorStyles}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
onClick={() => {
|
||||
if (callBtn === "Add") {
|
||||
onSubmitAddCallUs();
|
||||
} else if (callBtn === "Edit") {
|
||||
onEditCallUs();
|
||||
}
|
||||
// setContentTitle("Test");
|
||||
// setContentDesc("Test....");
|
||||
}}
|
||||
|
|
@ -175,7 +298,11 @@ export default function AdminWebContents() {
|
|||
<Button
|
||||
type="submit"
|
||||
onClick={() => {
|
||||
if (callBtn === "Add") {
|
||||
onSubmitAddAboutUs();
|
||||
} else if (callBtn === "Edit") {
|
||||
onEditAboutUs();
|
||||
}
|
||||
}}
|
||||
className="w-1/6 self-end my-2"
|
||||
>
|
||||
|
|
@ -199,7 +326,11 @@ export default function AdminWebContents() {
|
|||
<Button
|
||||
type="submit"
|
||||
onClick={() => {
|
||||
if (callBtn === "Add") {
|
||||
onSubmitAddَAfterText();
|
||||
} else if (callBtn === "Edit") {
|
||||
onEditAfterText();
|
||||
}
|
||||
}}
|
||||
className="w-1/6 self-end my-2"
|
||||
>
|
||||
|
|
@ -223,14 +354,17 @@ export default function AdminWebContents() {
|
|||
<Button
|
||||
type="submit"
|
||||
onClick={() => {
|
||||
if (callBtn === "Add") {
|
||||
onSubmitAddBeforeText();
|
||||
} else if (callBtn === "Edit") {
|
||||
onEditBeforeText();
|
||||
}
|
||||
}}
|
||||
className="w-1/6 self-end my-2"
|
||||
>
|
||||
ثبت
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -269,8 +269,8 @@ export default function ComplainsDetails({
|
|||
|
||||
<div className="w-full flex max-lg:flex-col items-start mt-2 gap-2">
|
||||
{/* 1 */}
|
||||
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28">
|
||||
<div className=" max-lg:hidden bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col">
|
||||
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28 lg:h-[80vh]">
|
||||
<div className=" max-lg:hidden bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col lg:h-full">
|
||||
<p className="text-[#464646] text-base font-bold mb-1">
|
||||
انجام عملیات
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ export default function InspectorOperations({
|
|||
<FormControl>
|
||||
<Textarea
|
||||
placeholder="متن خود را وارد نمایید"
|
||||
className="resize-none bg-white"
|
||||
className="resize-none bg-white lg:min-h-[20em]"
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
|
|
|
|||
|
|
@ -149,7 +149,9 @@ export const AdminMenuItems = [
|
|||
},
|
||||
{ id: 4, name: "سازمان ها", href: "/UserPanel/AdminDashboard/Organizations" },
|
||||
{ id: 5, name: "دسته بندی ها", href: "/UserPanel/AdminDashboard/Categories" },
|
||||
{ id: 6, name: "مدیریت محتوا", href: "/UserPanel/AdminDashboard/WebContents" },
|
||||
{ id: 6, name: "اخبار", href: "/UserPanel/AdminDashboard/News" },
|
||||
{ id: 7, name: "اسلایدر", href: "/UserPanel/AdminDashboard/Slider" },
|
||||
{ id: 8, name: "مدیریت محتوا", href: "/UserPanel/AdminDashboard/WebContents" },
|
||||
];
|
||||
|
||||
export const ControllerTableItems = [
|
||||
|
|
|
|||
|
|
@ -149,9 +149,19 @@ export async function SubmitWebContents( payload: FormData) {
|
|||
return data.data;
|
||||
}
|
||||
|
||||
export async function UpdateWebContents({ id }: { id: string } , payload: FormData) {
|
||||
export async function UpdateWebContents({
|
||||
id,
|
||||
payload,
|
||||
}: {
|
||||
id: string;
|
||||
payload: FormData
|
||||
}) {
|
||||
const data = await axios.put(`api/WebContents/${id}`, payload, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return data.data;
|
||||
}
|
||||
|
||||
// .....News.......
|
||||
|
||||
// .....Slider.......
|
||||
|
|
|
|||
Loading…
Reference in New Issue