Bugs Fixed
parent
dae4ec5264
commit
08872f04b9
|
|
@ -1,18 +1,18 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState, useRef, useEffect } from "react";
|
import React, { useState, useRef, useEffect } from "react";
|
||||||
import { useMutation, useQuery, RefetchOptions } from "@tanstack/react-query";
|
import {
|
||||||
|
useMutation,
|
||||||
|
useQuery,
|
||||||
|
RefetchOptions,
|
||||||
|
useQueryClient,
|
||||||
|
} from "@tanstack/react-query";
|
||||||
import {
|
import {
|
||||||
GetAllNews,
|
GetAllNews,
|
||||||
GetSingleNews,
|
GetSingleNews,
|
||||||
SubmitNews,
|
SubmitNews,
|
||||||
UpdateNews,
|
UpdateNews,
|
||||||
DeleteNews,
|
DeleteNews,
|
||||||
GetAllOrganizations,
|
|
||||||
GetSingleOrganization,
|
|
||||||
SubmitOrganization,
|
|
||||||
UpdateOrganization,
|
|
||||||
DeleteOrganization,
|
|
||||||
} from "@/utils/adminApi";
|
} from "@/utils/adminApi";
|
||||||
import { FaRegEdit } from "react-icons/fa";
|
import { FaRegEdit } from "react-icons/fa";
|
||||||
import { IoMdClose } from "react-icons/io";
|
import { IoMdClose } from "react-icons/io";
|
||||||
|
|
@ -132,7 +132,7 @@ export default function AdminNews() {
|
||||||
const [openEdit, setOpenEdit] = React.useState(false);
|
const [openEdit, setOpenEdit] = React.useState(false);
|
||||||
|
|
||||||
const [delOrg, setDelOrg] = React.useState(false);
|
const [delOrg, setDelOrg] = React.useState(false);
|
||||||
|
const queryClient = useQueryClient();
|
||||||
// List News
|
// List News
|
||||||
const {
|
const {
|
||||||
data: data1,
|
data: data1,
|
||||||
|
|
@ -145,10 +145,18 @@ export default function AdminNews() {
|
||||||
GetAllNews({
|
GetAllNews({
|
||||||
PageNumber: page,
|
PageNumber: page,
|
||||||
}),
|
}),
|
||||||
// queryFn: () => GetAllOrganizations(),
|
|
||||||
// refetchOnWindowFocus: false,
|
|
||||||
});
|
});
|
||||||
console.log(data1);
|
|
||||||
|
const {
|
||||||
|
data: data2,
|
||||||
|
error: Error2,
|
||||||
|
isLoading: isLoading2,
|
||||||
|
refetch: refetch2,
|
||||||
|
} = useQuery({
|
||||||
|
queryKey: ["News", keyId],
|
||||||
|
queryFn: () => GetSingleNews(keyId),
|
||||||
|
enabled: false,
|
||||||
|
});
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
const handleClickEdit = (
|
const handleClickEdit = (
|
||||||
|
|
@ -160,23 +168,30 @@ export default function AdminNews() {
|
||||||
image: string
|
image: string
|
||||||
) => {
|
) => {
|
||||||
// Set state variables
|
// Set state variables
|
||||||
|
console.log(id);
|
||||||
setKeyId(id);
|
setKeyId(id);
|
||||||
setTitleNews(title);
|
setTitleNews(title);
|
||||||
setDescNews(description);
|
setDescNews(description);
|
||||||
setUrlNews(url);
|
setUrlNews(url);
|
||||||
setContentNews(content);
|
setContentNews(content);
|
||||||
setImageNews(image);
|
setImageNews(image);
|
||||||
|
|
||||||
// Reset the form with new default values
|
// Reset the form with new default values
|
||||||
formEdit.reset({
|
|
||||||
titleNews: title,
|
|
||||||
description: description,
|
|
||||||
urlNews: url,
|
|
||||||
content: content,
|
|
||||||
// uploadImg:image
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
if (keyId) {
|
||||||
|
refetch2();
|
||||||
|
}
|
||||||
|
}, [keyId]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (data2) {
|
||||||
|
formEdit.reset({
|
||||||
|
titleNews: data2.title,
|
||||||
|
description: data2.description,
|
||||||
|
urlNews: data2.url,
|
||||||
|
content: data2.content,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [data2]);
|
||||||
// Form Edit
|
// Form Edit
|
||||||
type EditNewsFormValues = z.infer<typeof EditNewsFormSchema>;
|
type EditNewsFormValues = z.infer<typeof EditNewsFormSchema>;
|
||||||
// This can come from your database or API.
|
// This can come from your database or API.
|
||||||
|
|
@ -324,15 +339,15 @@ export default function AdminNews() {
|
||||||
setPage(headersData.CurrentPage);
|
setPage(headersData.CurrentPage);
|
||||||
}
|
}
|
||||||
}, [data1]);
|
}, [data1]);
|
||||||
|
|
||||||
const resetFormAdd = () => {
|
const resetFormAdd = () => {
|
||||||
formAdd.reset({
|
formAdd.reset({
|
||||||
titleNews: "",
|
titleNews: "",
|
||||||
urlNews: "",
|
urlNews: "",
|
||||||
content: "",
|
content: "",
|
||||||
description: "",
|
description: "",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-[85vh] flex justify-center pb-4">
|
<div className="w-full min-h-[85vh] flex justify-center pb-4">
|
||||||
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
|
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
|
||||||
|
|
@ -361,7 +376,12 @@ const resetFormAdd = () => {
|
||||||
<p className="text-[#464646] text-base font-bold">
|
<p className="text-[#464646] text-base font-bold">
|
||||||
افزودن خبر
|
افزودن خبر
|
||||||
</p>
|
</p>
|
||||||
<AlertDialogCancel className="h-auto p-0 border-0" onClick={() => { resetFormAdd(); }}>
|
<AlertDialogCancel
|
||||||
|
className="h-auto p-0 border-0"
|
||||||
|
onClick={() => {
|
||||||
|
resetFormAdd();
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IoMdClose />
|
<IoMdClose />
|
||||||
</AlertDialogCancel>
|
</AlertDialogCancel>
|
||||||
</AlertDialogTitle>
|
</AlertDialogTitle>
|
||||||
|
|
@ -514,7 +534,12 @@ const resetFormAdd = () => {
|
||||||
>
|
>
|
||||||
افزودن
|
افزودن
|
||||||
</Button>
|
</Button>
|
||||||
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl" onClick={() => { resetFormAdd(); }}>
|
<AlertDialogCancel
|
||||||
|
className="mt-0 text-white bg-blue rounded-xl"
|
||||||
|
onClick={() => {
|
||||||
|
resetFormAdd();
|
||||||
|
}}
|
||||||
|
>
|
||||||
بستن
|
بستن
|
||||||
</AlertDialogCancel>
|
</AlertDialogCancel>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -726,16 +751,10 @@ const resetFormAdd = () => {
|
||||||
</p>
|
</p>
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
توضیحات:
|
توضیحات:
|
||||||
<span className="self-end text-slate-800 line-clamp-2">
|
<span className="self-end text-slate-800 line-clamp-4">
|
||||||
{item.description}
|
{item.description}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
|
||||||
محتوا:
|
|
||||||
<span className="self-end text-slate-800">
|
|
||||||
{item.content}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-end justify-end w-full gap-2">
|
<div className="flex items-end justify-end w-full gap-2">
|
||||||
<Switch
|
<Switch
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { ClipboardList, EyeOff, Info, User, UserCheck } from "lucide-react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default function BoxDashboard({
|
export default function BoxDashboard({
|
||||||
|
|
@ -7,17 +8,32 @@ export default function BoxDashboard({
|
||||||
value: string;
|
value: string;
|
||||||
title: string;
|
title: string;
|
||||||
}) {
|
}) {
|
||||||
|
const boxIcons = {
|
||||||
|
"درخواست ناشناس": <EyeOff className=" mb-2 mx-auto" />,
|
||||||
|
"درخواست شناس": <UserCheck className=" mb-2 mx-auto" />,
|
||||||
|
درخواست: <ClipboardList className=" mb-2 mx-auto" />,
|
||||||
|
کاربر: <User className=" mb-2 mx-auto" />,
|
||||||
|
};
|
||||||
|
const handelIcon = (item: keyof typeof boxIcons) => {
|
||||||
|
const icon = boxIcons[item];
|
||||||
|
return icon;
|
||||||
|
};
|
||||||
|
const checkIcon = boxIcons[title as keyof typeof boxIcons] ? (
|
||||||
|
boxIcons[title as keyof typeof boxIcons]
|
||||||
|
) : (
|
||||||
|
<Info className=" mb-2 mx-auto" />
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className=" px-7 py-8 bg-zinc-100 rounded-lg shadow flex flex-col justify-end items-center text-black
|
className=" px-7 py-8 bg-zinc-100 rounded-lg shadow flex flex-col justify-evenly items-center text-black
|
||||||
transition duration-200
|
transition duration-200
|
||||||
hover:text-white hover:bg-blue
|
hover:text-white hover:bg-blue
|
||||||
group h-44 w-44"
|
group h-44 w-44"
|
||||||
>
|
>
|
||||||
<div className="group-hover:-translate-y-2 transition-all duration-300">
|
{checkIcon ? checkIcon : <Info className=" mb-2 mx-auto" />}
|
||||||
<p className="text-center text-xs font-medium">
|
{/* <EyeOff className=" mb-2 mx-auto" /> */}
|
||||||
{value}
|
<div className="group-hover:-translate-y-2 flex flex-col justify-center transition-all duration-300">
|
||||||
</p>
|
<p className="text-center text-sm font-medium">{value}</p>
|
||||||
<p className="text-center text-xs font-medium">{title}</p>
|
<p className="text-center text-xs font-medium">{title}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,6 @@ export default function ControllerDashboard() {
|
||||||
queryFn: () => getInfo(),
|
queryFn: () => getInfo(),
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
});
|
});
|
||||||
const [decryptedMessage, errorMessage] = useDecrypt(
|
|
||||||
"gJoT9AqK7wk1MZFSD04yXXfF36fzsOL+RYtJfySrEnQeJ7VoaL7pmOU6nB3+0+PQcaxIi3hf1AHjzIB0Cn5oHgKROeoI4XslhAezZk23QhtIU4HUF1wpeOJfA+4hWyRfbh4fI9774sa/KL47VaBbrNM/rvBxk6hjlKx5mTb3hqM="
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-12 pt-9 mx-auto px-2">
|
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-12 pt-9 mx-auto px-2">
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.2.5",
|
"version": "0.2.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.2.5",
|
"version": "0.2.6",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.3.2",
|
"@hookform/resolvers": "^3.3.2",
|
||||||
"@radix-ui/react-alert-dialog": "^1.0.5",
|
"@radix-ui/react-alert-dialog": "^1.0.5",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.2.5",
|
"version": "0.2.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ export async function GetAllNews({
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function GetSingleNews({ id }: { id: string }) {
|
export async function GetSingleNews(id: string) {
|
||||||
const data = await axios.get(`api/News/${id}`);
|
const data = await axios.get(`api/News/${id}`);
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue