Compare commits

..

No commits in common. "d39ca17f6128f590ac0ee6025279804256907558" and "4d1f2a6082159486b5fae174deac0f02d91bf71c" have entirely different histories.

11 changed files with 192 additions and 418 deletions

View File

@ -7,8 +7,6 @@ import NavbarSm from "@/components/NavbarSm";
import Provider from "../utils/Provider";
import { Toaster as SonnerToaster } from "@/components/ui/sonner";
import ProgressBarProviders from "@/components/ProgressBar";
import { unstable_noStore as noStore } from "next/cache";
import { EnvScript, PublicEnvScript } from "next-runtime-env";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
@ -20,13 +18,9 @@ export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
noStore();
}) {
return (
<html lang="fa" dir="rtl">
<head>
<PublicEnvScript />
</head>
<body className="font-[yekan] ">
<Provider>
<Navbar />

View File

@ -1,57 +0,0 @@
import React from "react";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { X } from "lucide-react";
export default function AttachmentsDialog({
children,
attachments,
deleteFile,
}: {
children: React.ReactNode;
attachments: File[] | [];
deleteFile: (file: any) => void;
}) {
return (
<Dialog>
{children}
<DialogContent>
<DialogHeader>
<DialogTitle>پیوست‌ها</DialogTitle>
<DialogDescription>
{attachments.length == 0 ? (
<div className=" text-center my-5">هیج پیوستی وجود ندارد.</div>
) : (
<div className=" flex flex-col gap-2 mt-2">
{attachments?.map((item,index) => {
return (
<div key={index} className=" flex gap-2 w-full items-center">
<div className=" p-2 bg-blue w-10 grid place-content-center rounded-lg text-white">
{index + 1}
</div>
<div className="bg-gray-200 p-2 rounded-lg max-w-full justify-between flex flex-1">
<div className="">
<p className=" truncate">{item.name}</p>
</div>
<X
onClick={() => deleteFile(item.name)}
className=" cursor-pointer hover:drop-shadow-md"
/>
</div>
</div>
);
})}
</div>
)}
</DialogDescription>
</DialogHeader>
</DialogContent>
</Dialog>
);
}

View File

@ -116,6 +116,8 @@ export default function ComplainsDetails({
mutationFn: postComplaintTracking,
onSuccess: (res) => {
setOpen(false);
localStorage.removeItem("trackingNumber2");
localStorage.removeItem("password2");
},
onError: (err: any | string) => {
toast(<>{err.response.data.detail}</>, {
@ -143,15 +145,10 @@ export default function ComplainsDetails({
getComplaintMutation.mutate({
Data: { trackingNumber: tk, password: pw },
});
}
}
}, []);
data = getComplaintMutation?.data;
const possibleOperations = data?.possibleOperationsWithDescription;
if (possibleOperations?.length == 0) {
localStorage.removeItem("trackingNumber2");
localStorage.removeItem("password2");
}
return (
<>
@ -204,11 +201,11 @@ export default function ComplainsDetails({
)} */}
{/* Editt */}
<div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col mb-10">
<div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col">
{/* 1 */}
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28 lg:h-[80vh] max-lg:order-3">
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28 lg:h-[80vh]">
{/* ***** */}
<div className=" bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col lg:h-full">
<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>
@ -343,21 +340,21 @@ export default function ComplainsDetails({
key={item.id}
className="p-4 bg-white rounded-lg shadow-md "
>
<div className="flex items-center gap-4 justify-between">
<div className="flex items-center gap-4 ">
<p className="">
<Badge>
{item.operationWithDescription.description} توسط{" "}
{item.sender == 0 ? "شهروند" : "بازرس"}
</Badge>
</p>
<p className="">
<span className="text-[#7C838A] text-sm">
{convertFullTime(item.dateTime)}
تاریخ :
<span className="text-[#7C838A]">
{convertDate(item.dateTime)}
</span>
</p>
</div>
<div className=" text-[#464646] mt-2">
<span className="text-[#7C838A] text-sm">
<span className="text-[#7C838A]">
{item.text ? item.text : "-"}
</span>
</div>
@ -411,6 +408,16 @@ export default function ComplainsDetails({
{/* 3 */}
{/* ****** */}
<div className="lg:hidden order-2 w-full bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col mt-2">
<p className="text-[#464646] text-base font-bold mb-1">
انجام عملیات
</p>
<InspectorOperations
updateData={() => getComplaintMutation.mutate(storeData)}
role={role}
complaintData={data}
/>
</div>
</div>
</>
) : (

View File

@ -29,16 +29,10 @@ import {
} from "@/components/ui/select";
import { Operations } from "@/constants";
import useData from "@/store/useData";
import { useMutation, useQuery } from "@tanstack/react-query";
import { useMutation } from "@tanstack/react-query";
import { OperateByInspector } from "@/utils/inspectorApi";
import { toast } from "sonner";
import { postComplaintsDetails } from "@/utils/citizenApi";
import { useState } from "react";
import { DialogTrigger } from "./ui/dialog";
import AttachmentsDialog from "./AttachmentsDialog";
import { Eye, Upload } from "lucide-react";
import { getOptions } from "@/utils/commonApi";
import { bytesToMB, formatBytes } from "@/lib/utils";
export default function InspectorOperations({
complaintData,
@ -51,63 +45,18 @@ export default function InspectorOperations({
updateData: (data: any) => any;
password?: string;
}) {
const [first, setfirst] = useState<File[]>([]);
// Queries
const { data, isLoading, refetch } = useQuery({
queryKey: ["Options"],
queryFn: () => getOptions(),
refetchOnWindowFocus: false,
});
const OperationMutation = useMutation({
mutationKey: ["Operation"],
mutationFn: postComplaintsDetails,
onSuccess: (res) => {
toast("عملیات شما با موفقیت انجام شد. ", {
className: "!bg-green-500 !text-white",
});
updateData({
trackingNumber: complaintData.trackingNumber,
password: password
? password
: (localStorage.getItem("password2") as string),
});
localStorage.removeItem("trackingNumber2");
localStorage.removeItem("password2");
},
onError: (err: any | string) => {
toast(<>{err.response.data.detail}</>, {
className: "!bg-red-500 !text-white",
});
},
});
const FormSchema = z.object({
text: z
.string({ required_error: "لطفا متن خود را وارد نمایید." })
.max(
data?.maxTextLength,
`حداکثر ${data?.maxTextLength} کاراکتر می توانید وارد کنید.`
),
text: z.string({ required_error: "لطفا متن خود را وارد نمایید." }),
operation: z.string({
required_error: "لطفا نوع عملیات را انتخاب نمایید.",
}),
media: z
.custom<File[]>()
.custom<FileList>((val) => val instanceof FileList, "Required")
// .refine((files) => files.length > 0, `Required`)
.refine(
(files) => files.length <= data?.maxFileCount,
`تعداد فایل های پیوست شده می بایست حداکثر ${data?.maxFileCount} عدد باشد.`
)
.refine(
(files) => files.every((item) => item.size < data?.maxFileSize),
`حجم هر فایل حداکثر می بایست ${data?.maxFileSize} باشد.`
)
.refine((files) => files.length <= 5, `Maximum of 5 File are allowed.`)
.nullish(),
});
const possibleOperations = complaintData?.possibleOperationsWithDescription;
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: {
@ -118,7 +67,29 @@ export default function InspectorOperations({
},
});
//Functions
const OperationMutation = useMutation({
mutationKey: ["Operation"],
mutationFn: postComplaintsDetails,
onSuccess: (res) => {
toast("عملیات شما با موفقیت انجام شد. ", {
className: "!bg-green-500 !text-white",
});
console.log(complaintData.trackingNumber);
console.log(localStorage.getItem("password2") as string);
updateData({
trackingNumber: complaintData.trackingNumber,
password: password
? password
: (localStorage.getItem("password2") as string),
});
},
onError: (err: any | string) => {
toast(<>{err.response.data.detail}</>, {
className: "!bg-red-500 !text-white",
});
},
});
function onSubmit(data: z.infer<typeof FormSchema>) {
const formData = new FormData();
formData.append("text", data.text);
@ -136,113 +107,54 @@ export default function InspectorOperations({
OperationMutation.mutate(formData);
}
const deleteFileFromAttachments = (file: any) => {
const filtered = first?.filter((item) => item.name !== file);
setfirst(filtered);
form.setValue("media", filtered);
};
const allowedExtensions = data?.allowedExtensions;
const split = allowedExtensions?.split(",");
const withDot = split?.map((item: string) => "." + item);
const newAllowedExtensions = withDot?.join(",");
const formatSize = (size: number) => {
const string = formatBytes(size);
return (
<span className="" dir="ltr">
{string}
</span>
);
};
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="">
<FormField
control={form.control}
name="text"
render={({ field, fieldState: { error } }) => (
render={({ field }) => (
<FormItem>
<FormLabel className="">متن</FormLabel>
<FormControl>
<Textarea
placeholder="متن خود را وارد نمایید"
className="resize-none bg-white lg:min-h-[20em]"
{...field}
// disabled={possibleOperations.length == 0}
readOnly={possibleOperations.length == 0}
/>
</FormControl>
{!error ? (
<FormDescription className=" text-xs my-1 ">
حداکثر {data?.maxTextLength} کاراکتر می توانید وارد کنید.
</FormDescription>
) : (
<FormMessage />
)}
{/* <FormDescription>
You can <span>@mention</span> other users and organizations.
</FormDescription> */}
<FormMessage />
</FormItem>
)}
/>
{/* <div className="grid w-full max-w-sm items-center gap-1.5 mt-1">
<Label htmlFor="picture">پیوست</Label>
<Input multiple id="picture" type="file" className="bg-white " />
</div> */}
<FormField
control={form.control}
name="media"
render={({ field, fieldState: { error } }) => (
render={({ field }) => (
<FormItem>
<FormLabel>
پیوست‌ها ({field?.value?.length ? field.value.length : 0})
</FormLabel>
<div className="flex gap-2 w-full items-center mt-1 mb-2">
<AttachmentsDialog
attachments={first}
deleteFile={(item) => deleteFileFromAttachments(item)}
>
<DialogTrigger className=" bg-white rounded-md h-9 text-xs flex-1 flex gap-2 items-center justify-center">
<Eye className=" w-4 h-4" />
<p>مشاهده</p>
</DialogTrigger>
</AttachmentsDialog>
<label
htmlFor="fileInput"
className="cursor-pointer text-sm rounded-md grid place-content-center h-9 px-2 bg-white w-1/2 items-center"
>
<div className=" flex gap-2 justify-center items-center">
<p className="text-xs flex gap-2 items-center">
<Upload className=" w-4 h-4" />
<span>افزودن</span>
</p>
</div>
</label>
<input
id="fileInput"
<FormLabel>پیوست</FormLabel>
<FormControl>
<Input
accept=".jpg, .jpeg, .png, .svg, .gif, .mp4 , .pdf"
type="file"
className="hidden"
accept={newAllowedExtensions}
multiple
onChange={(e) => {
// field.onChange(e.target.files ? e.target.files : null);
if (first && e.target.files) {
const fileArray1 = Array.from(first);
const fileArray2 = Array.from(e.target.files);
const mergedArray = fileArray1.concat(fileArray2);
setfirst(mergedArray);
field.onChange(mergedArray);
} else if (!first && e.target.files) {
const fileArray2 = Array.from(e.target.files);
setfirst(fileArray2);
field.onChange(fileArray2);
}
field.onChange(e.target.files ? e.target.files : null);
}}
multiple
className="bg-white "
disabled={possibleOperations.length == 0}
/>
</div>
{!error ? (
<FormDescription className=" text-xs my-1 ">
<span>
حجم هر فایل حداکثر می بایست {formatSize(data?.maxFileSize)}{" "}
مگابایت باشد
</span>{" "}
و{" "}
{`تعداد فایل های پیوست شده می بایست حداکثر ${data?.maxFileCount} تا باشد.`}
</FormDescription>
) : (
<FormMessage />
)}
</FormControl>
<FormMessage />
</FormItem>
)}
/>

View File

@ -40,20 +40,60 @@ import {
postComplaintSubmit,
} from "@/utils/citizenApi";
import { useRouter } from "next/navigation";
import {
getCaptcha,
getCategory,
getOptions,
getOrganizations,
} from "@/utils/commonApi";
import { getCaptcha, getCategory, getOrganizations } from "@/utils/commonApi";
import { Oval, ThreeDots } from "react-loader-spinner";
import useToken from "@/store/useToken";
import { toast } from "sonner";
import { Eye, RefreshCcw, Upload } from "lucide-react";
import { RefreshCcw } from "lucide-react";
import { getCookie } from "cookies-next";
import { formatBytes } from "@/lib/utils";
import AttachmentsDialog from "./AttachmentsDialog";
import { DialogTrigger } from "./ui/dialog";
const MAX_IMAGE_SIZE = 5242880; // 5 MB
const ALLOWED_IMAGE_TYPES = [
"image/jpeg",
"image/png",
"image/webp",
"image/jpg",
];
const FormSchema = z.object({
title: z.string().min(1, {
message: "لطفا موضوع شکایت را وارد نمایید.",
}),
OrganizationId: z.string({
required_error: "لطفا دستگاه مربوطه را انتخاب نمایید.",
}),
person: z.string().optional(),
description: z
.string()
.min(1, {
message: "لطفا توضیحات خود را بنویسید.",
})
.max(300, {
message: "تعداد کاراکترها بیشتر از حد مجاز میباشد.",
}),
uploadFile: z
.custom<FileList>((val) => val instanceof FileList, "Required")
// .refine((files) => files.length > 0, `Required`)
.refine((files) => files.length <= 5, `Maximum of 5 File are allowed.`)
.refine(
(files) => Array.from(files).every((file) => file.size <= MAX_IMAGE_SIZE),
`Each file size should be less than 5 MB.`
)
.nullish(),
// .refine(
// (files) =>
// Array.from(files).every((file) =>
// ALLOWED_IMAGE_TYPES.includes(file.type)
// ),
// "Only these types are allowed .jpg, .jpeg, .png and .webp"
// ),
categoryId: z.string({
required_error: "لطفا دسته بندی را انتخاب نمایید.",
}),
captchaValue: z.string().min(1, {
message: "لطفا کد امنیتی را وارد نمایید.",
}),
});
interface Organization {
title: string;
@ -62,53 +102,14 @@ interface Organization {
id: string;
}
// Form Hook
export default function RequestStep2() {
// const [trackingComplaint, setTrackingComplaint] = useState({});
const isAuth = useToken((state) => state.token);
const router = useRouter();
const [file, setFile] = useState<File[]>([]);
// Queries
const { data: optionsData, isLoading: isLoadingData } = useQuery({
queryKey: ["Options"],
queryFn: () => getOptions(),
refetchOnWindowFocus: false,
});
const FormSchema = z.object({
title: z.string().min(1, {
message: "لطفا موضوع شکایت را وارد نمایید.",
}),
OrganizationId: z.string({
required_error: "لطفا دستگاه مربوطه را انتخاب نمایید.",
}),
person: z.string().optional(),
description: z
.string()
.min(1, {
message: "لطفا توضیحات خود را بنویسید.",
})
.max(300, {
message: "تعداد کاراکترها بیشتر از حد مجاز میباشد.",
}),
uploadFile: z
.custom<File[]>()
// .refine((files) => files.length > 0, `Required`)
.refine(
(files) => files.length <= optionsData?.maxFileCount,
`تعداد فایل های پیوست شده می بایست حداکثر ${optionsData?.maxFileCount} عدد باشد.`
)
.refine(
(files) => files.every((item) => item.size < optionsData?.maxFileSize),
`حجم هر فایل حداکثر می بایست ${optionsData?.maxFileSize} مگابایت باشد.`
)
.nullish(),
categoryId: z.string({
required_error: "لطفا دسته بندی را انتخاب نمایید.",
}),
captchaValue: z.string().min(1, {
message: "لطفا کد امنیتی را وارد نمایید.",
}),
});
useEffect(() => {
useToken.persist.rehydrate();
}, []);
const complaintSubmitMutation = useMutation({
mutationKey: ["complaintSubmit"],
mutationFn: postComplaintSubmit,
@ -216,25 +217,6 @@ export default function RequestStep2() {
const { resetField } = useForm();
const deleteFileFromAttachments = (File: any) => {
const filtered = file?.filter((item) => item.name !== File);
setFile(filtered);
form.setValue("uploadFile", filtered);
};
const allowedExtensions = optionsData?.allowedExtensions;
const split = allowedExtensions?.split(",");
const withDot = split?.map((item: string) => "." + item);
const newAllowedExtensions = withDot?.join(",");
const formatSize = (size: number) => {
const string = formatBytes(size);
return (
<span className="" dir="ltr">
{string}
</span>
);
};
return (
<div className="w-full h-full pt-12 sm:w-2/3 md:w-2/4 max-sm:p-8">
<div className="flex flex-col justify-center h-full space-y-3 md:space-y-4">
@ -347,7 +329,7 @@ export default function RequestStep2() {
)}
/>
<div className="flex flex-row flex-wrap justify-between mb-2">
<div className="flex flex-row flex-wrap justify-between">
{/* Select Option */}
<FormField
control={form.control}
@ -384,7 +366,7 @@ export default function RequestStep2() {
<FormField
control={form.control}
name="uploadFile"
render={({ fieldState: { error }, field }) => {
render={({ field: { onChange }, ...field }) => {
// Get current uploadFile value (always watched updated)
const uploadFile = form.watch("uploadFile");
@ -398,65 +380,44 @@ export default function RequestStep2() {
return (
<FormItem className="w-full sm:w-[48%]">
<FormLabel className=" text-[#7C838A] text-sm mt-7">
پیوست‌ها (
{field?.value?.length ? field.value.length : 0})
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
پیوست
</FormLabel>
<div className="flex gap-2 w-full items-center">
<AttachmentsDialog
attachments={file}
deleteFile={(item) => deleteFileFromAttachments(item)}
>
<DialogTrigger className=" bg-slate-200 rounded-md h-9 text-xs flex-1 flex gap-2 items-center justify-center">
<Eye className=" w-4 h-4" />
<p>مشاهده</p>
</DialogTrigger>
</AttachmentsDialog>
<label
htmlFor="fileInput"
className="cursor-pointer text-sm rounded-md grid place-content-center h-9 px-2 bg-slate-200 w-1/2 items-center"
>
<div className=" flex gap-2 justify-center items-center">
<p className="text-xs flex gap-2 items-center">
<Upload className=" w-4 h-4" />
<span>افزودن</span>
</p>
</div>
</label>
<input
id="fileInput"
{/* File Upload */}
<FormControl>
<Input
type="file"
className="hidden"
accept={newAllowedExtensions}
multiple
onChange={(e) => {
// field.onChange(e.target.files ? e.target.files : null);
if (file && e.target.files) {
const fileArray1 = Array.from(file);
const fileArray2 = Array.from(e.target.files);
const mergedArray = fileArray1.concat(fileArray2);
setFile(mergedArray);
field.onChange(mergedArray);
} else if (!file && e.target.files) {
const fileArray2 = Array.from(e.target.files);
setFile(fileArray2);
field.onChange(fileArray2);
}
className="mb-3"
accept="image/* , .pdf"
multiple={true}
disabled={form.formState.isSubmitting}
{...field}
onChange={(event) => {
// Triggered when user uploaded a new file
// FileList is immutable, so we need to create a new one
const dataTransfer = new DataTransfer();
// Add old images
// if (images) {
// Array.from(images).forEach((image) =>
// dataTransfer.items.add(image)
// );
// }
// Add newly uploaded images
Array.from(event.target.files!).forEach((image) =>
dataTransfer.items.add(image)
);
// Validate and update uploaded file
const newFiles = dataTransfer.files;
onChange(newFiles);
}}
/>
</div>
{/* {!error ? (
<FormDescription className=" text-xs my-1 ">
<span>
حجم هر فایل حداکثر می بایست{" "}
{formatSize(optionsData?.maxFileSize)} مگابایت باشد
</span>{" "}
و{" "}
{`تعداد فایل های پیوست شده می بایست حداکثر ${optionsData?.maxFileCount} تا باشد.`}
</FormDescription>
) : (
<FormMessage />
)} */}
</FormControl>
{/* Show File Name */}
{/* <FormDescription>{`${filenames}`}</FormDescription> */}
<FormMessage />
</FormItem>
);
}}

View File

@ -13,28 +13,45 @@ export function cn(...inputs: ClassValue[]) {
}
export function convertDate(date: string) {
const convertedDate = dayjs(date + "Z")
const convertedDate = dayjs(date)
.calendar("jalali")
.locale("fa")
.format("YYYY/M/DD");
return convertedDate;
}
export function convertFullTime(date: string) {
const convertedDate = dayjs(date + "Z")
const convertedDate = dayjs(date)
.calendar("jalali")
.locale("fa")
.format(" HH:mm - YYYY/M/DD");
return convertedDate;
}
export function Decrypt(encryptedData: string, privateKey: string) {
export function Decrypt(encryptedData: string , privateKey: string) {
const Key = `-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCfmb1aGcWsqJPp+v6e72CPngE6P6FoCZCJESwDTXUXiJiAKshB
WZ9nlN+IIpQr6h8gmxi8SWbofPWmSKZgTyU2MddxUanneuywPTTUj4HQ6/DUaDwF
0Vr6Fk0x4yi1GKpBzhRFPyOYBWVXKIw23j0l+EWw6+JIpR9Kwu0TezHHFQIDAQAB
AoGBAIVxegy3t7vhR6s/HV2uMEJkjgox4banKJ4yKWapgNmocDnZi454bPuiUjP1
FYaSPmx4wXnMtap1sL7Tx6iHBEi10KB1AghDZP5wJHz6nm9ugcrGSSWhVJM74x6C
ThVztAV/rydaZ6/DLaqsBg5lHlo1DjMKq4sxnqrw/LUMGtOBAkEAzt8bnM1Ij/rF
i8oSP3gI0H914vf/0N2xxGGdQvMmJK0oijIm5j8dFDZf02Ft34SFeVJfXyVPapDE
vQ6TRw+1HQJBAMWAwvbypbtl65Dn4qCj3oJUmmnjjxm5080idF1S6ufo34p2gHMF
qLtWjmnGqjh2Shs7ahnfbLF+cxzgBg7yEFkCQFYGl1/0Sel9uepwpHf6PYgeiPJS
ePHtTwBAK3pszH7R9xrI0j5LHpeKKP0o9dzOKgcShxB03nqNKxMHXZ1eXc0CQFhD
Ot3xgm9FFQklF/qCQSYtePRpZcIxcZ3zD93E+IW7ZGsUmkLM/KL8A5jx15B0DJou
6zO0zXZk9DyrQQnc08ECQGy5ti89HmQ6I6Wqq5ADglCY6YPISsNwScVyvu/WxQsX
dEqG/38xFdYTFEekexcHnT/Vt1MW4/j76vBJHYWuAJU=
-----END RSA PRIVATE KEY-----`;
const decryptor = new JSEncrypt();
decryptor.setPrivateKey(privateKey);
const decrypted = decryptor.decrypt(encryptedData);
return decrypted;
}
export function isAuthorized() {
const token = getCookie("Sootzani_Token");
if (token) {
@ -43,41 +60,3 @@ export function isAuthorized() {
false;
}
}
export function bytesToMB(bytes: number) {
return Math.floor(bytes / (1024 * 1024));
}
export function formatBytes(bytes: number, decimals = 2) {
console.log(bytes);
if (!+bytes) return "0 Bytes";
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = [
"Bytes",
"KB",
"MB",
"GiB",
"TiB",
"PiB",
"EiB",
"ZiB",
"YiB",
];
// const sizes = [
// "Bytes",
// "KB",
// "MB",
// "GiB",
// "TiB",
// "PiB",
// "EiB",
// "ZiB",
// "YiB",
// ];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
}

18
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "sootzani",
"version": "0.1.16",
"version": "0.1.13",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sootzani",
"version": "0.1.16",
"version": "0.1.13",
"dependencies": {
"@hookform/resolvers": "^3.3.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
@ -40,7 +40,6 @@
"lucide-react": "^0.292.0",
"next": "14.0.3",
"next-nprogress-bar": "^2.1.2",
"next-runtime-env": "^3.2.0",
"next-themes": "^0.2.1",
"npm": "^10.2.5",
"react": "^18.2.0",
@ -4835,19 +4834,6 @@
"nprogress": "^0.2.0"
}
},
"node_modules/next-runtime-env": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/next-runtime-env/-/next-runtime-env-3.2.0.tgz",
"integrity": "sha512-rwe3flUgSRm51hzRN4Vt5MMSYMS4aDMEPJa0r+CMONA3UyUZl8Y5O8zjHSIlaNb3yquTCttZ0ahObPyPprBj9g==",
"dependencies": {
"next": "^14",
"react": "^18"
},
"peerDependencies": {
"next": "^14",
"react": "^18"
}
},
"node_modules/next-themes": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.2.1.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "sootzani",
"version": "0.1.16",
"version": "0.1.13",
"private": true,
"scripts": {
"dev": "next dev",
@ -41,7 +41,6 @@
"lucide-react": "^0.292.0",
"next": "14.0.3",
"next-nprogress-bar": "^2.1.2",
"next-runtime-env": "^3.2.0",
"next-themes": "^0.2.1",
"npm": "^10.2.5",
"react": "^18.2.0",

View File

@ -5,9 +5,8 @@ import {
getCookie,
setCookie,
} from "cookies-next";
import { env } from "next-runtime-env";
const NEXT_PUBLIC_BASE_URL_APP = env("NEXT_PUBLIC_BASE_URL_APP");
axios.defaults.baseURL = NEXT_PUBLIC_BASE_URL_APP;
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
let isRefreshing = false;
axios.interceptors.response.use(
@ -23,8 +22,8 @@ axios.interceptors.response.use(
originalRequest._retry = true;
const accessToken = getCookie("Sootzani_Token");
const refreshToken = getCookie("Sootzani_Refresh_Token");
//accessToken && refreshToken && !isRefreshing
if (!isRefreshing) {
if (accessToken && refreshToken && !isRefreshing) {
isRefreshing = true;
try {

View File

@ -1,8 +1,7 @@
import axios from "axios";
import { CookieValueTypes, getCookie } from "cookies-next";
import { env } from "next-runtime-env";
const NEXT_PUBLIC_BASE_URL_APP = env("NEXT_PUBLIC_BASE_URL_APP");
axios.defaults.baseURL = NEXT_PUBLIC_BASE_URL_APP;
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
axios.interceptors.request.use(function (config) {
const token = getCookie("Sootzani_Token");

View File

@ -43,8 +43,3 @@ export async function getNewsById(id: number) {
const data = await axios.get(`api/Common/News/${id}`);
return data.data;
}
export async function getOptions() {
const data = await axios.get("/api/Common/Options");
return data.data;
}