Compare commits
No commits in common. "7c2493dcb32eba703eee734fc1f5b3040e2ab51d" and "c423d5ef84d9832538a99f0a07decac9d980827a" have entirely different histories.
7c2493dcb3
...
c423d5ef84
|
|
@ -1,474 +1,7 @@
|
||||||
"use client";
|
import React from 'react'
|
||||||
|
|
||||||
import React, { useState, useRef, useEffect } from "react";
|
|
||||||
import { useMutation, useQuery, RefetchOptions } from "@tanstack/react-query";
|
|
||||||
import {
|
|
||||||
GetAllCategories,
|
|
||||||
GetSingleCategory,
|
|
||||||
SubmitCategory,
|
|
||||||
UpdateCategory,
|
|
||||||
DeleteCategory,
|
|
||||||
} from "@/utils/adminApi";
|
|
||||||
import { FaRegEdit } from "react-icons/fa";
|
|
||||||
import { IoMdClose } from "react-icons/io";
|
|
||||||
import { RiDeleteBin6Line } from "react-icons/ri";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { ThreeDots } from "react-loader-spinner";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
|
|
||||||
import {
|
|
||||||
AlertDialog,
|
|
||||||
AlertDialogAction,
|
|
||||||
AlertDialogCancel,
|
|
||||||
AlertDialogContent,
|
|
||||||
AlertDialogDescription,
|
|
||||||
AlertDialogFooter,
|
|
||||||
AlertDialogHeader,
|
|
||||||
AlertDialogTitle,
|
|
||||||
AlertDialogTrigger,
|
|
||||||
} from "@/components/ui/alert-dialog";
|
|
||||||
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import * as z from "zod";
|
|
||||||
import { Textarea } from "./ui/textarea";
|
|
||||||
import { Switch } from "@/components/ui/switch";
|
|
||||||
|
|
||||||
// Form Validation
|
|
||||||
const EditCatFormSchema = z.object({
|
|
||||||
titleCat: z
|
|
||||||
.string()
|
|
||||||
.min(2, {
|
|
||||||
message: "عنوان باید حداقل 2 کاراکتر باشد.",
|
|
||||||
})
|
|
||||||
.max(30, {
|
|
||||||
message: "عنوان نباید بیشتر از 30 کاراکتر باشد.",
|
|
||||||
}),
|
|
||||||
description: z.string().max(160),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add Key Form
|
|
||||||
const AddCatFormSchema = z.object({
|
|
||||||
titleCategory: z.string().min(2, {
|
|
||||||
message: "عنوان را وارد کنید",
|
|
||||||
}),
|
|
||||||
description: z.string(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function AdminCategories() {
|
export default function AdminCategories() {
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const [keyId, setKeyId] = useState("");
|
|
||||||
const [keyIdDel, setKeyIdDel] = useState("");
|
|
||||||
const [titleCat, setTitleCat] = useState("");
|
|
||||||
const [descCat, setDescCat] = useState("");
|
|
||||||
|
|
||||||
const [openAdd, setOpenAdd] = React.useState(false);
|
|
||||||
const [openEdit, setOpenEdit] = React.useState(false);
|
|
||||||
|
|
||||||
const [delCat, setDelCat] = React.useState(false);
|
|
||||||
|
|
||||||
// List Categories
|
|
||||||
const {
|
|
||||||
data: data1,
|
|
||||||
error: Error1,
|
|
||||||
isLoading: isListLoading,
|
|
||||||
refetch: refetch1,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: ["CategoriesList"],
|
|
||||||
queryFn: () => GetAllCategories(),
|
|
||||||
// refetchOnWindowFocus: false,
|
|
||||||
});
|
|
||||||
console.log(data1);
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
const handleClickEdit = (id: string, title: string, description: string) => {
|
|
||||||
// Set state variables
|
|
||||||
setKeyId(id);
|
|
||||||
setTitleCat(title);
|
|
||||||
setDescCat(description);
|
|
||||||
|
|
||||||
// Reset the form with new default values
|
|
||||||
formEdit.reset({
|
|
||||||
titleCat: title,
|
|
||||||
description: description,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Form Edit
|
|
||||||
type EditCatFormValues = z.infer<typeof EditCatFormSchema>;
|
|
||||||
// This can come from your database or API.
|
|
||||||
const defaultValuesEdit: Partial<EditCatFormValues> = {
|
|
||||||
titleCat: "",
|
|
||||||
description: "",
|
|
||||||
};
|
|
||||||
|
|
||||||
const formEdit = useForm<EditCatFormValues>({
|
|
||||||
resolver: zodResolver(EditCatFormSchema),
|
|
||||||
defaultValues: defaultValuesEdit,
|
|
||||||
mode: "onChange",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Form Add
|
|
||||||
type AddCatFormValues = z.infer<typeof AddCatFormSchema>;
|
|
||||||
// This can come from your database or API.
|
|
||||||
const defaultValuesAdd: Partial<AddCatFormValues> = {
|
|
||||||
titleCategory: "",
|
|
||||||
description: "",
|
|
||||||
};
|
|
||||||
|
|
||||||
const formAdd = useForm<AddCatFormValues>({
|
|
||||||
resolver: zodResolver(AddCatFormSchema),
|
|
||||||
defaultValues: defaultValuesAdd,
|
|
||||||
mode: "onChange",
|
|
||||||
});
|
|
||||||
// Edit Submit
|
|
||||||
|
|
||||||
// ............'Mutation' Change Key Submit
|
|
||||||
const ChangeCatMutation = useMutation({
|
|
||||||
mutationKey: ["ChangeCat"],
|
|
||||||
mutationFn: UpdateCategory,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
console.log(res);
|
|
||||||
console.log("Success ChangeCat");
|
|
||||||
setOpenEdit(false);
|
|
||||||
|
|
||||||
refetch1();
|
|
||||||
|
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
console.log(error);
|
|
||||||
console.log(error?.message);
|
|
||||||
|
|
||||||
setOpenEdit(false);
|
|
||||||
|
|
||||||
toast(error?.message, {
|
|
||||||
className: "!bg-red-500 !text-black",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
//Delete
|
|
||||||
const DeleteCatMutation = useMutation({
|
|
||||||
mutationKey: ["DeleteCat"],
|
|
||||||
mutationFn: DeleteCategory,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
console.log(res);
|
|
||||||
console.log("Success ChangeCat");
|
|
||||||
setOpenEdit(false);
|
|
||||||
refetch1();
|
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
console.log(error);
|
|
||||||
console.log(error?.message);
|
|
||||||
|
|
||||||
toast(error?.message, {
|
|
||||||
className: "!bg-red-500 !text-black",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add
|
|
||||||
// ............'Mutation' Change Key Submit
|
|
||||||
const AddCatMutation = useMutation({
|
|
||||||
mutationKey: ["AddCat"],
|
|
||||||
mutationFn: SubmitCategory,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
console.log(res);
|
|
||||||
console.log("Success ChangeCat");
|
|
||||||
setOpenAdd(false);
|
|
||||||
|
|
||||||
refetch1();
|
|
||||||
|
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
console.log(error);
|
|
||||||
console.log(error?.message);
|
|
||||||
|
|
||||||
setOpenAdd(false);
|
|
||||||
|
|
||||||
toast(error?.message, {
|
|
||||||
className: "!bg-red-500 !text-black",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function onSubmitEdit(data: EditCatFormValues) {
|
|
||||||
ChangeCatMutation.mutate({
|
|
||||||
id: keyId,
|
|
||||||
payload: {
|
|
||||||
title: data.titleCat,
|
|
||||||
description: data.description,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
function onSubmitAdd(data: AddCatFormValues) {
|
|
||||||
AddCatMutation.mutate({
|
|
||||||
title: data.titleCategory,
|
|
||||||
description: data.description,
|
|
||||||
});
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full bg-[#F5F5F5] min-h-[85vh] flex justify-center">
|
<div>AdminCategories</div>
|
||||||
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
|
)
|
||||||
<div className="flex w-full justify-between flex-row ">
|
|
||||||
{/* 1 */}
|
|
||||||
<div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
|
|
||||||
لیست دسته بندی ها
|
|
||||||
</div>
|
|
||||||
{/* 2 */}
|
|
||||||
|
|
||||||
{/* 1 */}
|
|
||||||
<AlertDialog open={openAdd} onOpenChange={setOpenAdd}>
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
// onClick={handleClickAddCat}
|
|
||||||
className="bg-orange-500 text-white"
|
|
||||||
// disabled={isNewKeyLoading}
|
|
||||||
>
|
|
||||||
افزودن دسته بندی
|
|
||||||
</Button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[26em] max-h-[24em]">
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>
|
|
||||||
<p className="text-[#464646] text-base font-bold">
|
|
||||||
افزودن دسته بندی
|
|
||||||
</p>
|
|
||||||
<AlertDialogCancel className="p-0 border-0 h-auto">
|
|
||||||
<IoMdClose />
|
|
||||||
</AlertDialogCancel>
|
|
||||||
</AlertDialogTitle>
|
|
||||||
|
|
||||||
<AlertDialogDescription>
|
|
||||||
<div className="w-full ">
|
|
||||||
<div className="w-full text-right text-neutral-600 text-lg font-bold mb-2">
|
|
||||||
افزودن دسته بندی
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Form {...formAdd}>
|
|
||||||
<form
|
|
||||||
onSubmit={formAdd.handleSubmit(onSubmitAdd)}
|
|
||||||
className="w-full flex flex-col mt-6 "
|
|
||||||
>
|
|
||||||
<div className="flex flex-col flex-wrap justify-between">
|
|
||||||
<FormField
|
|
||||||
control={formAdd.control}
|
|
||||||
name="titleCategory"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full ">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium">
|
|
||||||
عنوان دسته بندی
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="عنوان دسته بندی را وارد نمایید"
|
|
||||||
{...field}
|
|
||||||
className="bg-white"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={formAdd.control}
|
|
||||||
name="description"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full ">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium ">
|
|
||||||
توضیحات
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder=" توضیحات را وارد کنید"
|
|
||||||
{...field}
|
|
||||||
className="bg-white"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
className="bg-blue text-white min-w-max rounded-xl text-center hover:bg-white hover:text-slate-800"
|
|
||||||
>
|
|
||||||
افزودن
|
|
||||||
</Button>
|
|
||||||
<AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
|
|
||||||
بستن
|
|
||||||
</AlertDialogCancel>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</div>
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
{/* <AlertDialogCancel>بستن</AlertDialogCancel> */}
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
<div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
|
|
||||||
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}>
|
|
||||||
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[25em] max-h-[23em]">
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>
|
|
||||||
<p className="text-[#464646] text-base font-bold">
|
|
||||||
تغییر کلید
|
|
||||||
</p>
|
|
||||||
<AlertDialogCancel className="p-0 border-0 h-auto">
|
|
||||||
<IoMdClose />
|
|
||||||
</AlertDialogCancel>
|
|
||||||
</AlertDialogTitle>
|
|
||||||
|
|
||||||
<AlertDialogDescription>
|
|
||||||
<Form {...formEdit}>
|
|
||||||
<form
|
|
||||||
onSubmit={formEdit.handleSubmit(onSubmitEdit)}
|
|
||||||
className="w-full flex flex-col"
|
|
||||||
>
|
|
||||||
<div className="flex flex-col flex-wrap justify-between">
|
|
||||||
<FormField
|
|
||||||
control={formEdit.control}
|
|
||||||
name="titleCat"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full ">
|
|
||||||
<FormLabel>عنوان</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="عنوان"
|
|
||||||
{...field}
|
|
||||||
className=" bg-white"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={formEdit.control}
|
|
||||||
name="description"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full ">
|
|
||||||
<FormLabel>توضیحات</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Textarea
|
|
||||||
placeholder="توضیحات"
|
|
||||||
className="resize-none bg-white"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
|
|
||||||
>
|
|
||||||
تغییر دسته بندی
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
|
|
||||||
بستن
|
|
||||||
</AlertDialogCancel>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter></AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
{data1?.map((item: any) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={item.id}
|
|
||||||
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<p className=" text-slate-500 text-sm font-normal leading-normal">
|
|
||||||
عنوان :
|
|
||||||
<span className=" text-slate-800">{item.title}</span>
|
|
||||||
</p>
|
|
||||||
<p className=" text-slate-500 text-sm font-normal leading-normal">
|
|
||||||
توضیحات:
|
|
||||||
<span className=" text-slate-800 self-end">
|
|
||||||
{item.description}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div className="w-full flex justify-end items-end gap-2">
|
|
||||||
<Switch
|
|
||||||
dir="ltr"
|
|
||||||
checked={item.isDeleted}
|
|
||||||
onCheckedChange={() => {
|
|
||||||
DeleteCatMutation.mutate({
|
|
||||||
id: item.id,
|
|
||||||
payload: !item.isDeleted,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
id={item.id}
|
|
||||||
|
|
||||||
// onClick={() => handleClickDelete(item?.id)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
{/* <Button variant="outline">Show Dialog</Button> */}
|
|
||||||
<FaRegEdit
|
|
||||||
aria-hidden="true"
|
|
||||||
className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end"
|
|
||||||
// onClick={() => setKeyId(item?.id)}
|
|
||||||
onClick={() =>
|
|
||||||
handleClickEdit(
|
|
||||||
item?.id,
|
|
||||||
item?.title,
|
|
||||||
item?.description
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import React from "react";
|
||||||
import BoxDashboard from "./BoxDashboard";
|
import BoxDashboard from "./BoxDashboard";
|
||||||
import LineChart from "./LineChart";
|
import LineChart from "./LineChart";
|
||||||
import { HorizontalChart } from "./HorizontalChart";
|
import { HorizontalChart } from "./HorizontalChart";
|
||||||
import VerticalChart from "./VerticalChart";
|
import { VerticalChart } from "./VerticalChart";
|
||||||
import { PieChart } from "./PieChart";
|
import { PieChart } from "./PieChart";
|
||||||
|
|
||||||
export default function AdminDashboard() {
|
export default function AdminDashboard() {
|
||||||
|
|
|
||||||
|
|
@ -196,7 +196,7 @@ export default function AdminKeysManagement() {
|
||||||
publicKey: data.publicKey,
|
publicKey: data.publicKey,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// const { resetField } = useForm();
|
const { resetField } = useForm();
|
||||||
|
|
||||||
// List Keys
|
// List Keys
|
||||||
const {
|
const {
|
||||||
|
|
|
||||||
|
|
@ -1,475 +1,7 @@
|
||||||
"use client";
|
import React from 'react'
|
||||||
|
|
||||||
import React, { useState, useRef, useEffect } from "react";
|
|
||||||
import { useMutation, useQuery, RefetchOptions } from "@tanstack/react-query";
|
|
||||||
import {
|
|
||||||
GetAllOrganizations,
|
|
||||||
GetSingleOrganization,
|
|
||||||
SubmitOrganization,
|
|
||||||
UpdateOrganization,
|
|
||||||
DeleteOrganization,
|
|
||||||
} from "@/utils/adminApi";
|
|
||||||
import { FaRegEdit } from "react-icons/fa";
|
|
||||||
import { IoMdClose } from "react-icons/io";
|
|
||||||
import { RiDeleteBin6Line } from "react-icons/ri";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { ThreeDots } from "react-loader-spinner";
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import { toast } from "sonner";
|
|
||||||
|
|
||||||
import {
|
|
||||||
AlertDialog,
|
|
||||||
AlertDialogAction,
|
|
||||||
AlertDialogCancel,
|
|
||||||
AlertDialogContent,
|
|
||||||
AlertDialogDescription,
|
|
||||||
AlertDialogFooter,
|
|
||||||
AlertDialogHeader,
|
|
||||||
AlertDialogTitle,
|
|
||||||
AlertDialogTrigger,
|
|
||||||
} from "@/components/ui/alert-dialog";
|
|
||||||
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import * as z from "zod";
|
|
||||||
import { Textarea } from "./ui/textarea";
|
|
||||||
import { Switch } from "@/components/ui/switch";
|
|
||||||
|
|
||||||
// Form Validation
|
|
||||||
const EditOrgFormSchema = z.object({
|
|
||||||
titleOrg: z
|
|
||||||
.string()
|
|
||||||
.min(2, {
|
|
||||||
message: "عنوان باید حداقل 2 کاراکتر باشد.",
|
|
||||||
})
|
|
||||||
.max(30, {
|
|
||||||
message: "عنوان نباید بیشتر از 30 کاراکتر باشد.",
|
|
||||||
}),
|
|
||||||
description: z.string().max(200),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add Key Form
|
|
||||||
const AddOrgFormSchema = z.object({
|
|
||||||
titleOrg: z.string().min(2, {
|
|
||||||
message: "عنوان را وارد کنید",
|
|
||||||
}),
|
|
||||||
// description: z.string().min(4, {
|
|
||||||
// message: " توضیحات را وارد کنید",
|
|
||||||
// }),
|
|
||||||
description: z.string(),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function AdminOrganizations() {
|
export default function AdminOrganizations() {
|
||||||
const router = useRouter();
|
|
||||||
const [keyId, setKeyId] = useState("");
|
|
||||||
const [keyIdDel, setKeyIdDel] = useState("");
|
|
||||||
const [titleOrg, setTitleOrg] = useState("");
|
|
||||||
const [descOrg, setDescOrg] = useState("");
|
|
||||||
|
|
||||||
const [openAdd, setOpenAdd] = React.useState(false);
|
|
||||||
const [openEdit, setOpenEdit] = React.useState(false);
|
|
||||||
|
|
||||||
const [delOrg, setDelOrg] = React.useState(false);
|
|
||||||
|
|
||||||
// List Categories
|
|
||||||
const {
|
|
||||||
data: data1,
|
|
||||||
error: Error1,
|
|
||||||
isLoading: isListLoading,
|
|
||||||
refetch: refetch1,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: ["OrganizationList"],
|
|
||||||
queryFn: () => GetAllOrganizations(),
|
|
||||||
// refetchOnWindowFocus: false,
|
|
||||||
});
|
|
||||||
console.log(data1);
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
const handleClickEdit = (id: string, title: string, description: string) => {
|
|
||||||
// Set state variables
|
|
||||||
setKeyId(id);
|
|
||||||
setTitleOrg(title);
|
|
||||||
setDescOrg(description);
|
|
||||||
|
|
||||||
// Reset the form with new default values
|
|
||||||
formEdit.reset({
|
|
||||||
titleOrg: title,
|
|
||||||
description: description,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Form Edit
|
|
||||||
type EditOrgFormValues = z.infer<typeof EditOrgFormSchema>;
|
|
||||||
// This can come from your database or API.
|
|
||||||
const defaultValuesEdit: Partial<EditOrgFormValues> = {
|
|
||||||
titleOrg: "",
|
|
||||||
description: "",
|
|
||||||
};
|
|
||||||
|
|
||||||
const formEdit = useForm<EditOrgFormValues>({
|
|
||||||
resolver: zodResolver(EditOrgFormSchema),
|
|
||||||
defaultValues: defaultValuesEdit,
|
|
||||||
mode: "onChange",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Form Add
|
|
||||||
type AddOrgFormValues = z.infer<typeof AddOrgFormSchema>;
|
|
||||||
// This can come from your database or API.
|
|
||||||
const defaultValuesAdd: Partial<AddOrgFormValues> = {
|
|
||||||
titleOrg: "",
|
|
||||||
description: "",
|
|
||||||
};
|
|
||||||
|
|
||||||
const formAdd = useForm<AddOrgFormValues>({
|
|
||||||
resolver: zodResolver(AddOrgFormSchema),
|
|
||||||
defaultValues: defaultValuesAdd,
|
|
||||||
mode: "onChange",
|
|
||||||
});
|
|
||||||
// Edit Submit
|
|
||||||
|
|
||||||
// ............'Mutation' Change Key Submit
|
|
||||||
const ChangeOrgMutation = useMutation({
|
|
||||||
mutationKey: ["ChangeOrg"],
|
|
||||||
mutationFn: UpdateOrganization,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
console.log(res);
|
|
||||||
console.log("Success ChangeCat");
|
|
||||||
setOpenEdit(false);
|
|
||||||
|
|
||||||
refetch1();
|
|
||||||
|
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
console.log(error);
|
|
||||||
console.log(error?.message);
|
|
||||||
|
|
||||||
setOpenEdit(false);
|
|
||||||
|
|
||||||
toast(error?.message, {
|
|
||||||
className: "!bg-red-500 !text-black",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
//Delete
|
|
||||||
const DeleteOrgMutation = useMutation({
|
|
||||||
mutationKey: ["DeleteOrg"],
|
|
||||||
mutationFn: DeleteOrganization,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
console.log(res);
|
|
||||||
console.log("Success ChangeCat");
|
|
||||||
setOpenEdit(false);
|
|
||||||
refetch1();
|
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
console.log(error);
|
|
||||||
console.log(error?.message);
|
|
||||||
|
|
||||||
toast(error?.message, {
|
|
||||||
className: "!bg-red-500 !text-black",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add
|
|
||||||
// ............'Mutation' Change Key Submit
|
|
||||||
const AddOrgMutation = useMutation({
|
|
||||||
mutationKey: ["AddOrg"],
|
|
||||||
mutationFn: SubmitOrganization,
|
|
||||||
onSuccess: (res) => {
|
|
||||||
console.log(res);
|
|
||||||
console.log("Success ChangeCat");
|
|
||||||
setOpenAdd(false);
|
|
||||||
|
|
||||||
refetch1();
|
|
||||||
|
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
|
||||||
className: "!bg-green-500 !text-white",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
console.log(error);
|
|
||||||
console.log(error?.message);
|
|
||||||
|
|
||||||
setOpenAdd(false);
|
|
||||||
|
|
||||||
toast(error?.message, {
|
|
||||||
className: "!bg-red-500 !text-black",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function onSubmitEdit(data: EditOrgFormValues) {
|
|
||||||
ChangeOrgMutation.mutate({
|
|
||||||
id: keyId,
|
|
||||||
payload: {
|
|
||||||
title: data.titleOrg,
|
|
||||||
description: data.description,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
function onSubmitAdd(data: AddOrgFormValues) {
|
|
||||||
AddOrgMutation.mutate({
|
|
||||||
title: data.titleOrg,
|
|
||||||
description: data.description,
|
|
||||||
});
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full bg-[#F5F5F5] min-h-[85vh] flex justify-center">
|
<div>AdminOrganizations</div>
|
||||||
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
|
)
|
||||||
<div className="flex w-full justify-between flex-row ">
|
|
||||||
{/* 1 */}
|
|
||||||
<div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
|
|
||||||
لیست سازمان ها
|
|
||||||
</div>
|
|
||||||
{/* 2 */}
|
|
||||||
|
|
||||||
{/* 1 */}
|
|
||||||
<AlertDialog open={openAdd} onOpenChange={setOpenAdd}>
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
// onClick={handleClickAddCat}
|
|
||||||
className="bg-orange-500 text-white"
|
|
||||||
// disabled={isNewKeyLoading}
|
|
||||||
>
|
|
||||||
افزودن دسته بندی
|
|
||||||
</Button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[26em] max-h-[24em]">
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>
|
|
||||||
<p className="text-[#464646] text-base font-bold">
|
|
||||||
افزودن دسته بندی
|
|
||||||
</p>
|
|
||||||
<AlertDialogCancel className="p-0 border-0 h-auto">
|
|
||||||
<IoMdClose />
|
|
||||||
</AlertDialogCancel>
|
|
||||||
</AlertDialogTitle>
|
|
||||||
|
|
||||||
<AlertDialogDescription>
|
|
||||||
<div className="w-full ">
|
|
||||||
<div className="w-full text-right text-neutral-600 text-lg font-bold mb-2">
|
|
||||||
افزودن دسته بندی
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Form {...formAdd}>
|
|
||||||
<form
|
|
||||||
onSubmit={formAdd.handleSubmit(onSubmitAdd)}
|
|
||||||
className="w-full flex flex-col mt-6 "
|
|
||||||
>
|
|
||||||
<div className="flex flex-col flex-wrap justify-between">
|
|
||||||
<FormField
|
|
||||||
control={formAdd.control}
|
|
||||||
name="titleOrg"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full ">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium">
|
|
||||||
عنوان سازمان
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="عنوان سازمان را وارد نمایید"
|
|
||||||
{...field}
|
|
||||||
className="bg-white"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={formAdd.control}
|
|
||||||
name="description"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full ">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium ">
|
|
||||||
توضیحات
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder=" توضیحات را وارد کنید"
|
|
||||||
{...field}
|
|
||||||
className="bg-white"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
className="bg-blue text-white min-w-max rounded-xl text-center hover:bg-white hover:text-slate-800"
|
|
||||||
>
|
|
||||||
افزودن
|
|
||||||
</Button>
|
|
||||||
<AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
|
|
||||||
بستن
|
|
||||||
</AlertDialogCancel>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</div>
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
{/* <AlertDialogCancel>بستن</AlertDialogCancel> */}
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
<div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
|
|
||||||
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}>
|
|
||||||
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[25em] max-h-[23em]">
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>
|
|
||||||
<p className="text-[#464646] text-base font-bold">
|
|
||||||
تغییر کلید
|
|
||||||
</p>
|
|
||||||
<AlertDialogCancel className="p-0 border-0 h-auto">
|
|
||||||
<IoMdClose />
|
|
||||||
</AlertDialogCancel>
|
|
||||||
</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>
|
|
||||||
<Form {...formEdit}>
|
|
||||||
<form
|
|
||||||
onSubmit={formEdit.handleSubmit(onSubmitEdit)}
|
|
||||||
className="w-full flex flex-col"
|
|
||||||
>
|
|
||||||
<div className="flex flex-col flex-wrap justify-between">
|
|
||||||
<FormField
|
|
||||||
control={formEdit.control}
|
|
||||||
name="titleOrg"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full ">
|
|
||||||
<FormLabel>عنوان</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="عنوان"
|
|
||||||
{...field}
|
|
||||||
className=" bg-white"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={formEdit.control}
|
|
||||||
name="description"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full ">
|
|
||||||
<FormLabel>توضیحات</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Textarea
|
|
||||||
placeholder="توضیحات"
|
|
||||||
className="resize-none bg-white"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
|
|
||||||
>
|
|
||||||
تغییر سازمان
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
|
|
||||||
بستن
|
|
||||||
</AlertDialogCancel>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter></AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
|
|
||||||
|
|
||||||
{data1?.map((item: any) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={item.id}
|
|
||||||
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start
|
|
||||||
`}
|
|
||||||
>
|
|
||||||
<p className=" text-slate-500 text-sm font-normal leading-normal">
|
|
||||||
عنوان :
|
|
||||||
<span className=" text-slate-800">{item.title}</span>
|
|
||||||
</p>
|
|
||||||
<p className=" text-slate-500 text-sm font-normal leading-normal">
|
|
||||||
توضیحات:
|
|
||||||
<span className=" text-slate-800 self-end">
|
|
||||||
{item.description}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div className="w-full flex justify-end items-end gap-2">
|
|
||||||
<Switch
|
|
||||||
dir="ltr"
|
|
||||||
checked={item.isDeleted}
|
|
||||||
onCheckedChange={() => {
|
|
||||||
DeleteOrgMutation.mutate({
|
|
||||||
id: item.id,
|
|
||||||
payload: !item.isDeleted,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
id={item.id}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
{/* <Button variant="outline">Show Dialog</Button> */}
|
|
||||||
<FaRegEdit
|
|
||||||
aria-hidden="true"
|
|
||||||
className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end"
|
|
||||||
// onClick={() => setKeyId(item?.id)}
|
|
||||||
onClick={() =>
|
|
||||||
handleClickEdit(
|
|
||||||
item?.id,
|
|
||||||
item?.title,
|
|
||||||
item?.description
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
"use client"
|
|
||||||
|
|
||||||
import * as React from "react"
|
|
||||||
import * as SwitchPrimitives from "@radix-ui/react-switch"
|
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
|
||||||
|
|
||||||
const Switch = React.forwardRef<
|
|
||||||
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
|
|
||||||
>(({ className, ...props }, ref) => (
|
|
||||||
<SwitchPrimitives.Root
|
|
||||||
className={cn(
|
|
||||||
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
ref={ref}
|
|
||||||
>
|
|
||||||
<SwitchPrimitives.Thumb
|
|
||||||
className={cn(
|
|
||||||
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</SwitchPrimitives.Root>
|
|
||||||
))
|
|
||||||
Switch.displayName = SwitchPrimitives.Root.displayName
|
|
||||||
|
|
||||||
export { Switch }
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
"use client"
|
|
||||||
|
|
||||||
import * as React from "react"
|
|
||||||
import * as TogglePrimitive from "@radix-ui/react-toggle"
|
|
||||||
import { cva, type VariantProps } from "class-variance-authority"
|
|
||||||
|
|
||||||
import { cn } from "@/lib/utils"
|
|
||||||
|
|
||||||
const toggleVariants = cva(
|
|
||||||
"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",
|
|
||||||
{
|
|
||||||
variants: {
|
|
||||||
variant: {
|
|
||||||
default: "bg-transparent",
|
|
||||||
outline:
|
|
||||||
"border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
default: "h-9 px-3",
|
|
||||||
sm: "h-8 px-2",
|
|
||||||
lg: "h-10 px-3",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
defaultVariants: {
|
|
||||||
variant: "default",
|
|
||||||
size: "default",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const Toggle = React.forwardRef<
|
|
||||||
React.ElementRef<typeof TogglePrimitive.Root>,
|
|
||||||
React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> &
|
|
||||||
VariantProps<typeof toggleVariants>
|
|
||||||
>(({ className, variant, size, ...props }, ref) => (
|
|
||||||
<TogglePrimitive.Root
|
|
||||||
ref={ref}
|
|
||||||
className={cn(toggleVariants({ variant, size, className }))}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
|
|
||||||
Toggle.displayName = TogglePrimitive.Root.displayName
|
|
||||||
|
|
||||||
export { Toggle, toggleVariants }
|
|
||||||
|
|
@ -20,10 +20,8 @@
|
||||||
"@radix-ui/react-select": "^2.0.0",
|
"@radix-ui/react-select": "^2.0.0",
|
||||||
"@radix-ui/react-separator": "^1.0.3",
|
"@radix-ui/react-separator": "^1.0.3",
|
||||||
"@radix-ui/react-slot": "^1.0.2",
|
"@radix-ui/react-slot": "^1.0.2",
|
||||||
"@radix-ui/react-switch": "^1.0.3",
|
|
||||||
"@radix-ui/react-tabs": "^1.0.4",
|
"@radix-ui/react-tabs": "^1.0.4",
|
||||||
"@radix-ui/react-toast": "^1.1.5",
|
"@radix-ui/react-toast": "^1.1.5",
|
||||||
"@radix-ui/react-toggle": "^1.0.3",
|
|
||||||
"@tanstack/react-query": "^5.8.7",
|
"@tanstack/react-query": "^5.8.7",
|
||||||
"@tanstack/react-query-devtools": "^5.14.7",
|
"@tanstack/react-query-devtools": "^5.14.7",
|
||||||
"@uidotdev/usehooks": "^2.4.1",
|
"@uidotdev/usehooks": "^2.4.1",
|
||||||
|
|
@ -1195,35 +1193,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@radix-ui/react-switch": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-switch/-/react-switch-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-mxm87F88HyHztsI7N+ZUmEoARGkC22YVW5CaC+Byc+HRpuvCrOBPTAnXgf+tZ/7i0Sg/eOePGdMhUKhPaQEqow==",
|
|
||||||
"dependencies": {
|
|
||||||
"@babel/runtime": "^7.13.10",
|
|
||||||
"@radix-ui/primitive": "1.0.1",
|
|
||||||
"@radix-ui/react-compose-refs": "1.0.1",
|
|
||||||
"@radix-ui/react-context": "1.0.1",
|
|
||||||
"@radix-ui/react-primitive": "1.0.3",
|
|
||||||
"@radix-ui/react-use-controllable-state": "1.0.1",
|
|
||||||
"@radix-ui/react-use-previous": "1.0.1",
|
|
||||||
"@radix-ui/react-use-size": "1.0.1"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": "*",
|
|
||||||
"@types/react-dom": "*",
|
|
||||||
"react": "^16.8 || ^17.0 || ^18.0",
|
|
||||||
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@types/react-dom": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@radix-ui/react-tabs": {
|
"node_modules/@radix-ui/react-tabs": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-tabs/-/react-tabs-1.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-tabs/-/react-tabs-1.0.4.tgz",
|
||||||
|
|
@ -1288,31 +1257,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@radix-ui/react-toggle": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-toggle/-/react-toggle-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-Pkqg3+Bc98ftZGsl60CLANXQBBQ4W3mTFS9EJvNxKMZ7magklKV69/id1mlAlOFDDfHvlCms0fx8fA4CMKDJHg==",
|
|
||||||
"dependencies": {
|
|
||||||
"@babel/runtime": "^7.13.10",
|
|
||||||
"@radix-ui/primitive": "1.0.1",
|
|
||||||
"@radix-ui/react-primitive": "1.0.3",
|
|
||||||
"@radix-ui/react-use-controllable-state": "1.0.1"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@types/react": "*",
|
|
||||||
"@types/react-dom": "*",
|
|
||||||
"react": "^16.8 || ^17.0 || ^18.0",
|
|
||||||
"react-dom": "^16.8 || ^17.0 || ^18.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"@types/react": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@types/react-dom": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@radix-ui/react-use-callback-ref": {
|
"node_modules/@radix-ui/react-use-callback-ref": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-use-callback-ref/-/react-use-callback-ref-1.0.1.tgz",
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,8 @@
|
||||||
"@radix-ui/react-select": "^2.0.0",
|
"@radix-ui/react-select": "^2.0.0",
|
||||||
"@radix-ui/react-separator": "^1.0.3",
|
"@radix-ui/react-separator": "^1.0.3",
|
||||||
"@radix-ui/react-slot": "^1.0.2",
|
"@radix-ui/react-slot": "^1.0.2",
|
||||||
"@radix-ui/react-switch": "^1.0.3",
|
|
||||||
"@radix-ui/react-tabs": "^1.0.4",
|
"@radix-ui/react-tabs": "^1.0.4",
|
||||||
"@radix-ui/react-toast": "^1.1.5",
|
"@radix-ui/react-toast": "^1.1.5",
|
||||||
"@radix-ui/react-toggle": "^1.0.3",
|
|
||||||
"@tanstack/react-query": "^5.8.7",
|
"@tanstack/react-query": "^5.8.7",
|
||||||
"@tanstack/react-query-devtools": "^5.14.7",
|
"@tanstack/react-query-devtools": "^5.14.7",
|
||||||
"@uidotdev/usehooks": "^2.4.1",
|
"@uidotdev/usehooks": "^2.4.1",
|
||||||
|
|
|
||||||
|
|
@ -65,18 +65,8 @@ export async function UpdateCategory({
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function DeleteCategory({
|
export async function DeleteCategory({ id }: { id: string }) {
|
||||||
id,
|
const data = await axios.delete(`api/ComplaintCategories/${id}`);
|
||||||
payload,
|
|
||||||
}: {
|
|
||||||
id: string;
|
|
||||||
payload: any;
|
|
||||||
}) {
|
|
||||||
const data = await axios.delete(`api/ComplaintCategories/${id}`, {
|
|
||||||
data: payload,
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
});
|
|
||||||
|
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,17 +103,7 @@ export async function UpdateOrganization({
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function DeleteOrganization({
|
export async function DeleteOrganization({ id }: { id: string }) {
|
||||||
id,
|
const data = await axios.delete(`api/ComplaintOrganizations/${id}`);
|
||||||
payload,
|
|
||||||
}: {
|
|
||||||
id: string;
|
|
||||||
payload: any;
|
|
||||||
}){
|
|
||||||
const data = await axios.delete(`api/ComplaintOrganizations/${id}`, {
|
|
||||||
data: payload,
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
});
|
|
||||||
|
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue