Change Key improved + Runtime Environment Variable added

Kahdooie
Hossein Rahmani 2024-02-03 01:12:12 +03:30
parent 45099f1dac
commit bc1b30bc9a
20 changed files with 531 additions and 127 deletions

View File

@ -1,9 +1,10 @@
import type { Metadata } from "next"; import type { Metadata } from "next";
import "./globals.css"; import "./globals.css";
import { Toaster } from "@/components/ui/toaster"; import { Toaster } from "@/components/ui/toaster";
import Provider from "../utils/Provider"; import Provider from "../utils/ReactQuery/Provider";
import { Toaster as SonnerToaster } from "@/components/ui/sonner"; import { Toaster as SonnerToaster } from "@/components/ui/sonner";
import ProgressBarProviders from "@/components/PrograssBar"; import ProgressBarProviders from "@/components/PrograssBar";
import { EnvScript, PublicEnvScript } from "next-runtime-env";
export const metadata: Metadata = { export const metadata: Metadata = {
title: "عیون", title: "عیون",
@ -17,11 +18,14 @@ export default function RootLayout({
}) { }) {
return ( return (
<html lang="fa" dir="rtl"> <html lang="fa" dir="rtl">
<head>
<PublicEnvScript />
</head>
<body className="font-[yekan] bg-white"> <body className="font-[yekan] bg-white">
<Provider> <Provider>
<ProgressBarProviders>{children}</ProgressBarProviders> <ProgressBarProviders>{children}</ProgressBarProviders>
<Toaster /> <Toaster />
<SonnerToaster /> <SonnerToaster richColors />
</Provider> </Provider>
</body> </body>
</html> </html>

View File

@ -1,7 +1,12 @@
"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 { GenerateKeyPair, GetKeys, AddKey, ChangeKey } from "@/utils/adminApi"; import { GenerateKeyPair, GetKeys, AddKey, ChangeKey } 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";
@ -37,6 +42,8 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import * as z from "zod"; import * as z from "zod";
import { Textarea } from "./ui/textarea"; import { Textarea } from "./ui/textarea";
import { Check } from "lucide-react";
import { Progress } from "./ui/progress";
const MAX_FILE_SIZE = 5242880; // 5 MB const MAX_FILE_SIZE = 5242880; // 5 MB
// Edit Key Form // Edit Key Form
@ -71,16 +78,19 @@ const FormSchemaAddKey = z.object({
}), }),
}); });
export default function AdminKeysManagement() { export default function AdminKeysManagement() {
const router = useRouter(); const router = useRouter();
const queryClient = useQueryClient();
const [keyId, setKeyId] = useState(""); const [keyId, setKeyId] = useState("");
const [done, setDone] = useState<number>(0);
const [total, setTotal] = useState<number>(0);
const [polling, setPolling] = useState<boolean>(false);
const [openAdd, setOpenAdd] = React.useState(false); const [openAdd, setOpenAdd] = React.useState(false);
const [openEdit, setOpenEdit] = React.useState(false); const [openEdit, setOpenEdit] = React.useState(false);
const inputPubRef = useRef<HTMLTextAreaElement | null>(null); const inputPubRef = useRef<HTMLTextAreaElement | null>(null);
const inputPrvRef = useRef<HTMLTextAreaElement | null>(null); const inputPrvRef = useRef<HTMLTextAreaElement | null>(null);
const intervalRef = useRef<NodeJS.Timeout | null>(null);
// ..............Read .txt // ..............Read .txt
const [selectedFile, setSelectedFile] = useState<any>(null); const [selectedFile, setSelectedFile] = useState<any>(null);
const handleFileChange = (event: any) => { const handleFileChange = (event: any) => {
@ -108,11 +118,27 @@ export default function AdminKeysManagement() {
mutationKey: ["ChangeKey"], mutationKey: ["ChangeKey"],
mutationFn: ChangeKey, mutationFn: ChangeKey,
onSuccess: (res) => { onSuccess: (res) => {
if (res.total == res.done) {
localStorage.removeItem("isChangingKey");
setPolling(false);
queryClient.invalidateQueries({ queryKey: ["KeysList"] });
if (res.failed == 0) {
refetch1();
toast("عملیات شما با موفقیت انجام شد. ", {
className: "!bg-green-500 !text-white",
});
}
if (intervalRef.current !== null) {
clearInterval(intervalRef.current);
intervalRef.current = null; // Reset the ref value after clearing
}
} else {
localStorage.setItem("isChangingKey", "true");
setPolling(true);
}
setOpenEdit(false); setOpenEdit(false);
setDone(res.done);
toast("عملیات شما با موفقیت انجام شد. ", { setTotal(res.total);
className: "!bg-green-500 !text-white",
});
// router.refresh() // router.refresh()
}, },
@ -127,6 +153,7 @@ export default function AdminKeysManagement() {
ChangeKeyMutation.mutate({ ChangeKeyMutation.mutate({
privateKey: selectedFile, privateKey: selectedFile,
publicKeyId: keyId, publicKeyId: keyId,
isPolling: false,
}); });
} }
@ -221,6 +248,37 @@ export default function AdminKeysManagement() {
} }
}, [handleClickGenerate]); }, [handleClickGenerate]);
// useEffect(() => {
// const isChangingKey = localStorage.getItem("isChangingKey");
// if (isChangingKey) {
// setPolling(true);
// ChangeKeyMutation.mutate({
// privateKey: "",
// publicKeyId: "cb7258da-64b0-4f43-b4f7-8ee11799d643",
// isPolling: true,
// });
// }
// }, [polling]);
const refethKey = () => {
ChangeKeyMutation.mutate({
privateKey: "",
publicKeyId: "cb7258da-64b0-4f43-b4f7-8ee11799d643",
isPolling: true,
});
};
useEffect(() => {
const isChangingKey = localStorage.getItem("isChangingKey");
if (isChangingKey) {
setTimeout(() => {}, 10000);
intervalRef.current = setInterval(refethKey, 10000);
return () => {
if (intervalRef.current !== null) {
clearInterval(intervalRef.current);
intervalRef.current = null; // Reset the ref value after clearing
}
};
}
}, [polling]);
const saveTextFile = () => { const saveTextFile = () => {
const textToSave = data2?.privateKey ?? ""; const textToSave = data2?.privateKey ?? "";
const fileName = "privateKey.txt"; const fileName = "privateKey.txt";
@ -249,7 +307,6 @@ export default function AdminKeysManagement() {
} }
}, [AddKeyMutation.isSuccess]); }, [AddKeyMutation.isSuccess]);
const resetFormAdd = () => { const resetFormAdd = () => {
formAdd.reset({ formAdd.reset({
title: "", title: "",
@ -260,6 +317,12 @@ export default function AdminKeysManagement() {
return ( return (
<div className="w-full min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<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 ">
{polling && (
<div className=" w-full md:w-1/2 mx-auto mt-2">
<p className=" font-bold test-sm">درحال تغییر کلید ...</p>
<Progress className=" mt-5" value={(done * 100) / total} />
</div>
)}
{/* 1 */} {/* 1 */}
<AlertDialog open={openAdd} onOpenChange={setOpenAdd}> <AlertDialog open={openAdd} onOpenChange={setOpenAdd}>
<AlertDialogContent className=""> <AlertDialogContent className="">
@ -268,7 +331,12 @@ export default function AdminKeysManagement() {
<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>
@ -370,118 +438,98 @@ export default function AdminKeysManagement() {
</Button> </Button>
</AlertDialogTrigger> </AlertDialogTrigger>
</div> </div>
<div className="flex flex-row flex-wrap justify-between w-full gap-8 md:gap-4 "> <div className="flex flex-row flex-wrap w-full gap-8 md:gap-4">
{data1?.map((item: any) => { {data1?.map((item: any) => {
return ( return (
<div <div
key={item.id} 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 bg-[#F5F5F5] className={`flex flex-col justify-center gap-2 w-full md:w-[31%] lg:w-[23%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
`} `}
> >
<p className="text-sm font-normal leading-normal text-slate-500"> <p className="text-sm font-normal leading-normal text-slate-500">
عنوان کلید:{" "} عنوان کلید:{" "}
<span className=" text-slate-800">{item.title}</span> <span className=" text-slate-800">{item.title}</span>
</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"> <span className="self-end text-slate-800">
{item.inspectorId} {item.inspectorId}
</span> </span>
</p> </p> */}
{item?.isActive ? (
<Check className="self-end w-6 h-6 text-green-600" />
) : (
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}>
<AlertDialogTrigger asChild>
{/* <Button variant="outline">Show Dialog</Button> */}
<FaRegEdit
aria-hidden="true"
className="self-end w-6 h-6 text-slate-600 hover:cursor-pointer"
onClick={() => setKeyId(item?.id)}
/>
</AlertDialogTrigger>
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[20em] max-h-[23em]">
<AlertDialogHeader>
<AlertDialogTitle>تغییر کلید</AlertDialogTitle>
<AlertDialogDescription>
<Form {...formEdit}>
<form
onSubmit={formEdit.handleSubmit(onSubmitEdit)}
className="flex flex-col w-full mt-6 "
>
<div className="flex flex-row flex-wrap justify-between">
<FormField
control={formEdit.control}
name="uploadPrivateKey"
render={({ field }) => (
<FormItem className="w-full ">
<FormLabel className="text-[#7C838A] text-sm font-medium mb-2">
پیوست (کلید خصوصی)
</FormLabel>
<FormControl>
<Input
required={true}
type="file"
accept=".txt"
className="mt-2 bg-slate-300"
// {...field}
onChange={handleFileChange}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end">
<Button
type="submit"
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
>
ویرایش کلید
</Button>
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}> {/* <AlertDialogAction
<AlertDialogTrigger asChild>
{/* <Button variant="outline">Show Dialog</Button> */}
<FaRegEdit
aria-hidden="true"
className="self-end w-6 h-6 text-slate-600 hover:cursor-pointer"
onClick={() => setKeyId(item?.id)}
/>
</AlertDialogTrigger>
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[20em] max-h-[23em]">
<AlertDialogHeader>
<AlertDialogTitle>تغییر کلید</AlertDialogTitle>
<AlertDialogDescription>
<Form {...formEdit}>
<form
onSubmit={formEdit.handleSubmit(onSubmitEdit)}
className="flex flex-col w-full mt-6 "
>
<div className="flex flex-row flex-wrap justify-between">
<FormField
control={formEdit.control}
name="uploadPrivateKey"
render={({ field }) => (
<FormItem className="w-full ">
<FormLabel className="text-[#7C838A] text-sm font-medium mb-2">
پیوست (کلید خصوصی)
</FormLabel>
<FormControl>
<Input
required={true}
type="file"
accept=".txt"
className="mt-2 bg-slate-300"
// {...field}
onChange={handleFileChange}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* <FormField
control={formEdit.control}
name="publicKeyId"
render={({ field }) => (
<FormItem className=" w-full lg:w-[48%]">
<FormLabel className="text-[#7C838A] text-sm font-medium ">
آی دی کلید عمومی
</FormLabel>
<FormControl>
<Input
className="mt-2 bg-slate-300"
value={item?.id}
readOnly={true}
// {...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/> */}
</div>
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end">
<Button
// href="/FollowResult"
type="submit"
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
>
ویرایش کلید
</Button>
{/* <AlertDialogAction
type="submit" type="submit"
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800" className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
> >
تغییر کلید تغییر کلید
</AlertDialogAction> */} </AlertDialogAction> */}
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl">
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>
</form> </form>
</Form> </Form>
</AlertDialogDescription> </AlertDialogDescription>
</AlertDialogHeader> </AlertDialogHeader>
<AlertDialogFooter> <AlertDialogFooter>
{/* <AlertDialogAction>Continue</AlertDialogAction> */} {/* <AlertDialogAction>Continue</AlertDialogAction> */}
</AlertDialogFooter> </AlertDialogFooter>
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>
)}
</div> </div>
); );
})} })}

View File

@ -166,7 +166,6 @@ export default function ComplainsDetails({
const checkKey2 = (item: any) => { const checkKey2 = (item: any) => {
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile); const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
console.log(dcKey);
if (dcKey != false && dcKey != null) { if (dcKey != false && dcKey != null) {
if (check) { if (check) {
localStorage.setItem("privateKey", selectedFile); localStorage.setItem("privateKey", selectedFile);
@ -425,7 +424,7 @@ export default function ComplainsDetails({
روند شکایت روند شکایت
</p> </p>
<div <div
className="flex flex-col mt-4 gap-y-4 overflow-auto className="flex flex-col mt-4 gap-y-4 overflow-y-auto
scrollbar-thin scrollbar-thumb-gray-500 scrollbar-track-gray-100 " scrollbar-thin scrollbar-thumb-gray-500 scrollbar-track-gray-100 "
> >
{data.contents?.map((item: any) => { {data.contents?.map((item: any) => {
@ -447,11 +446,9 @@ export default function ComplainsDetails({
</span> </span>
</p> </p>
</div> </div>
<div className=" text-[#464646] mt-2"> <p className="text-[#7C838A] text-sm flex flex-wrap whitespace-normal break-all mt-2">
<span className="text-[#7C838A] text-sm"> {item.text ? item.text : "-"}
{item.text ? item.text : "-"} </p>
</span>
</div>
{item.media.length !== 0 && ( {item.media.length !== 0 && (
<Separator className="mt-2 mb-1 " /> <Separator className="mt-2 mb-1 " />
)} )}

View File

@ -157,6 +157,7 @@ export default function InspectorOperations({
const deleteFileFromAttachments = (File: any) => { const deleteFileFromAttachments = (File: any) => {
const filtered = file?.filter((item) => item.name !== File); const filtered = file?.filter((item) => item.name !== File);
setFile(filtered); setFile(filtered);
// @ts-expect-error
form.setValue("media", filtered); form.setValue("media", filtered);
}; };

View File

@ -9,6 +9,8 @@ import { getProfile, revoke } from "@/utils/authenticateApi";
import { useMutation, useQuery } from "@tanstack/react-query"; import { useMutation, useQuery } from "@tanstack/react-query";
import { DoorOpen, LogOut } from "lucide-react"; import { DoorOpen, LogOut } from "lucide-react";
import { deleteCookie, getCookie } from "cookies-next"; import { deleteCookie, getCookie } from "cookies-next";
import useSignalR from "@/hooks/useSignalR";
export default function NavbarPanel() { export default function NavbarPanel() {
const [isOpen, setOpen] = useState(false); const [isOpen, setOpen] = useState(false);
const ref = useRef(null); const ref = useRef(null);
@ -53,6 +55,7 @@ export default function NavbarPanel() {
localStorage.removeItem("privatePassword"); localStorage.removeItem("privatePassword");
router.push("/"); router.push("/");
}; };
const signalr = useSignalR();
return ( return (
<div className="fixed top-0 z-10 flex flex-row items-center justify-between w-full gap-3 px-8 py-4 shadow-md sm:items-center sm:gap-0 bg-blue max-md:px-4 "> <div className="fixed top-0 z-10 flex flex-row items-center justify-between w-full gap-3 px-8 py-4 shadow-md sm:items-center sm:gap-0 bg-blue max-md:px-4 ">

View File

@ -0,0 +1,28 @@
"use client"
import * as React from "react"
import * as ProgressPrimitive from "@radix-ui/react-progress"
import { cn } from "@/lib/utils"
const Progress = React.forwardRef<
React.ElementRef<typeof ProgressPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
>(({ className, value, ...props }, ref) => (
<ProgressPrimitive.Root
ref={ref}
className={cn(
"relative h-4 w-full overflow-hidden rounded-full bg-secondary",
className
)}
{...props}
>
<ProgressPrimitive.Indicator
className="h-full w-full flex-1 bg-primary transition-all"
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
/>
</ProgressPrimitive.Root>
))
Progress.displayName = ProgressPrimitive.Root.displayName
export { Progress }

View File

@ -10,7 +10,7 @@ const Toaster = ({ ...props }: ToasterProps) => {
return ( return (
<Sonner <Sonner
theme={theme as ToasterProps["theme"]} // theme={theme as ToasterProps["theme"]}
className="toaster group !font-[yekan]" className="toaster group !font-[yekan]"
toastOptions={{ toastOptions={{
classNames: { classNames: {

84
hooks/useSignalR.jsx Normal file
View File

@ -0,0 +1,84 @@
import { useCallback, useEffect } from "react";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import {
HttpTransportType,
HubConnectionBuilder,
JsonHubProtocol,
LogLevel,
} from "@microsoft/signalr";
import connection from "../utils/signalrConnection";
import { postConnectionId } from "@/utils/inspectorApi";
import { toast } from "sonner";
import { useParams, usePathname } from "next/navigation";
const useSignalR = () => {
const queryClient = useQueryClient();
const pathname = usePathname();
const param = useParams();
const isInComplaintDetailPage = pathname.includes(
"/UserPanel/ControllerDashboard/Complaints/"
);
const postConnectionIdMutation = useMutation({
mutationKey: ["connectionId"],
mutationFn: postConnectionId,
onSuccess: (res) => {},
onError: (err) => {},
});
useEffect(() => {
const role = localStorage.getItem("Sootzani_Role");
if (role != "Admin") {
const startConnection = async () => {
try {
await connection.start();
console.log("SignalR connected");
console.log(connection.connectionId);
postConnectionIdMutation.mutate(connection.connectionId);
connection.on("Created", (message) => {
queryClient.invalidateQueries(["ComplaintsList"]);
toast.info("یک درخواست جدید دارید.");
});
connection.on("Updated", (message, id) => {
toast.info(`${message}`);
if (param.id == id) {
queryClient.invalidateQueries(["Complaint", id]);
}
});
} catch (err) {
console.error("SignalR connection failed: ", err);
}
};
startConnection();
}
// console.log(connection.connectionId);
// return () => {
// if (connection.state === "Connected") {
// connection.stop();
// console.log("SignalR disconnected");
// }
// };
}, []);
useEffect(() => {
if (connection.connectionId) {
console.log(connection.connectionId);
}
}, [connection]);
// console.log(connection.state);
// useEffect(() => {
// console.log(11111);
// console.log(connection.state);
// // Subscribe to events and update query data accordingly
// // Example: Listen for a "newMessage" event and update a query with the new message data
// console.log(connection.state);
// }, [queryClient]);
// return connection;
};
export default useSignalR;

View File

@ -39,7 +39,6 @@ export function Decrypt(encryptedData: any, privateKey: any) {
} }
export function formatBytes(bytes: number, decimals = 2) { export function formatBytes(bytes: number, decimals = 2) {
console.log(bytes);
if (!+bytes) return "0 Bytes"; if (!+bytes) return "0 Bytes";
const k = 1024; const k = 1024;

198
package-lock.json generated
View File

@ -9,12 +9,14 @@
"version": "0.2.14", "version": "0.2.14",
"dependencies": { "dependencies": {
"@hookform/resolvers": "^3.3.2", "@hookform/resolvers": "^3.3.2",
"@microsoft/signalr": "^8.0.0",
"@radix-ui/react-alert-dialog": "^1.0.5", "@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2", "@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-radio-group": "^1.1.3", "@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-select": "^2.0.0", "@radix-ui/react-select": "^2.0.0",
@ -46,6 +48,7 @@
"lucide-react": "^0.292.0", "lucide-react": "^0.292.0",
"next": "14.0.3", "next": "14.0.3",
"next-nprogress-bar": "^2.1.2", "next-nprogress-bar": "^2.1.2",
"next-runtime-env": "^3.2.0",
"next-themes": "^0.2.1", "next-themes": "^0.2.1",
"nextjs-toploader": "^1.6.4", "nextjs-toploader": "^1.6.4",
"npm": "^10.2.5", "npm": "^10.2.5",
@ -341,6 +344,18 @@
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz", "resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz",
"integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==" "integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw=="
}, },
"node_modules/@microsoft/signalr": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/@microsoft/signalr/-/signalr-8.0.0.tgz",
"integrity": "sha512-K/wS/VmzRWePCGqGh8MU8OWbS1Zvu7DG7LSJS62fBB8rJUXwwj4axQtqrAAwKGUZHQF6CuteuQR9xMsVpM2JNA==",
"dependencies": {
"abort-controller": "^3.0.0",
"eventsource": "^2.0.2",
"fetch-cookie": "^2.0.3",
"node-fetch": "^2.6.7",
"ws": "^7.4.5"
}
},
"node_modules/@next/env": { "node_modules/@next/env": {
"version": "14.0.3", "version": "14.0.3",
"resolved": "https://registry.npmjs.org/@next/env/-/env-14.0.3.tgz", "resolved": "https://registry.npmjs.org/@next/env/-/env-14.0.3.tgz",
@ -1021,6 +1036,30 @@
} }
} }
}, },
"node_modules/@radix-ui/react-progress": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-progress/-/react-progress-1.0.3.tgz",
"integrity": "sha512-5G6Om/tYSxjSeEdrb1VfKkfZfn/1IlPWd731h2RfPuSbIfNUgfqAwbKfJCg/PP6nuUCTrYzalwHSpSinoWoCag==",
"dependencies": {
"@babel/runtime": "^7.13.10",
"@radix-ui/react-context": "1.0.1",
"@radix-ui/react-primitive": "1.0.3"
},
"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-radio-group": { "node_modules/@radix-ui/react-radio-group": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-radio-group/-/react-radio-group-1.1.3.tgz", "resolved": "https://registry.npmjs.org/@radix-ui/react-radio-group/-/react-radio-group-1.1.3.tgz",
@ -1759,6 +1798,17 @@
"resolved": "https://registry.npmjs.org/@xobotyi/scrollbar-width/-/scrollbar-width-1.9.5.tgz", "resolved": "https://registry.npmjs.org/@xobotyi/scrollbar-width/-/scrollbar-width-1.9.5.tgz",
"integrity": "sha512-N8tkAACJx2ww8vFMneJmaAgmjAG1tnVBZJRLRcx061tmsLRZHSEZSLuGWnwPtunsSLvSqXQ2wfp7Mgqg1I+2dQ==" "integrity": "sha512-N8tkAACJx2ww8vFMneJmaAgmjAG1tnVBZJRLRcx061tmsLRZHSEZSLuGWnwPtunsSLvSqXQ2wfp7Mgqg1I+2dQ=="
}, },
"node_modules/abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"dependencies": {
"event-target-shim": "^5.0.0"
},
"engines": {
"node": ">=6.5"
}
},
"node_modules/acorn": { "node_modules/acorn": {
"version": "8.11.2", "version": "8.11.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz",
@ -3326,11 +3376,27 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
"engines": {
"node": ">=6"
}
},
"node_modules/eventemitter3": { "node_modules/eventemitter3": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz",
"integrity": "sha512-jLN68Dx5kyFHaePoXWPsCGW5qdyZQtLYHkxkg02/Mz6g0kYpDx4FyP6XfArhQdlOC4b8Mv+EMxPo/8La7Tzghg==" "integrity": "sha512-jLN68Dx5kyFHaePoXWPsCGW5qdyZQtLYHkxkg02/Mz6g0kYpDx4FyP6XfArhQdlOC4b8Mv+EMxPo/8La7Tzghg=="
}, },
"node_modules/eventsource": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-2.0.2.tgz",
"integrity": "sha512-IzUmBGPR3+oUG9dUeXynyNmf91/3zUSJg1lCktzKw47OXuhco54U3r9B7O4XX+Rb1Itm9OZ2b0RkTs10bICOxA==",
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/extend": { "node_modules/extend": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
@ -3420,6 +3486,15 @@
"reusify": "^1.0.4" "reusify": "^1.0.4"
} }
}, },
"node_modules/fetch-cookie": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-2.2.0.tgz",
"integrity": "sha512-h9AgfjURuCgA2+2ISl8GbavpUdR+WGAM2McW/ovn4tVccegp8ZqCKWSBR8uRdM8dDNlx5WdKRWxBYUwteLDCNQ==",
"dependencies": {
"set-cookie-parser": "^2.4.8",
"tough-cookie": "^4.0.0"
}
},
"node_modules/figures": { "node_modules/figures": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
@ -4866,6 +4941,19 @@
"nprogress": "^0.2.0" "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": { "node_modules/next-themes": {
"version": "0.2.1", "version": "0.2.1",
"resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.2.1.tgz", "resolved": "https://registry.npmjs.org/next-themes/-/next-themes-0.2.1.tgz",
@ -4891,6 +4979,25 @@
"react-dom": ">= 16.0.0" "react-dom": ">= 16.0.0"
} }
}, },
"node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-releases": { "node_modules/node-releases": {
"version": "2.0.13", "version": "2.0.13",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz",
@ -8139,15 +8246,24 @@
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
}, },
"node_modules/psl": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
"integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag=="
},
"node_modules/punycode": { "node_modules/punycode": {
"version": "2.3.1", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
"integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
"dev": true,
"engines": { "engines": {
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/querystringify": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
},
"node_modules/queue-microtask": { "node_modules/queue-microtask": {
"version": "1.2.3", "version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@ -8539,6 +8655,11 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
},
"node_modules/resize-observer-polyfill": { "node_modules/resize-observer-polyfill": {
"version": "1.5.1", "version": "1.5.1",
"resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz", "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
@ -8750,6 +8871,11 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/set-cookie-parser": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz",
"integrity": "sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ=="
},
"node_modules/set-function-length": { "node_modules/set-function-length": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz", "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.1.1.tgz",
@ -9334,6 +9460,25 @@
"resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz", "resolved": "https://registry.npmjs.org/toggle-selection/-/toggle-selection-1.0.6.tgz",
"integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==" "integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ=="
}, },
"node_modules/tough-cookie": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz",
"integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==",
"dependencies": {
"psl": "^1.1.33",
"punycode": "^2.1.1",
"universalify": "^0.2.0",
"url-parse": "^1.5.3"
},
"engines": {
"node": ">=6"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"node_modules/ts-api-utils": { "node_modules/ts-api-utils": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz",
@ -9496,6 +9641,14 @@
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
"dev": true "dev": true
}, },
"node_modules/universalify": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
"engines": {
"node": ">= 4.0.0"
}
},
"node_modules/update-browserslist-db": { "node_modules/update-browserslist-db": {
"version": "1.0.13", "version": "1.0.13",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz",
@ -9535,6 +9688,15 @@
"punycode": "^2.1.0" "punycode": "^2.1.0"
} }
}, },
"node_modules/url-parse": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
"integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
"dependencies": {
"querystringify": "^2.1.1",
"requires-port": "^1.0.0"
}
},
"node_modules/use-callback-ref": { "node_modules/use-callback-ref": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.0.tgz", "resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.0.tgz",
@ -9609,6 +9771,20 @@
"defaults": "^1.0.3" "defaults": "^1.0.3"
} }
}, },
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/which": { "node_modules/which": {
"version": "2.0.2", "version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@ -9718,6 +9894,26 @@
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="
}, },
"node_modules/ws": {
"version": "7.5.9",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
"engines": {
"node": ">=8.3.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/yallist": { "node_modules/yallist": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",

View File

@ -10,12 +10,14 @@
}, },
"dependencies": { "dependencies": {
"@hookform/resolvers": "^3.3.2", "@hookform/resolvers": "^3.3.2",
"@microsoft/signalr": "^8.0.0",
"@radix-ui/react-alert-dialog": "^1.0.5", "@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2", "@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-radio-group": "^1.1.3", "@radix-ui/react-radio-group": "^1.1.3",
"@radix-ui/react-scroll-area": "^1.0.5", "@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-select": "^2.0.0", "@radix-ui/react-select": "^2.0.0",
@ -47,6 +49,7 @@
"lucide-react": "^0.292.0", "lucide-react": "^0.292.0",
"next": "14.0.3", "next": "14.0.3",
"next-nprogress-bar": "^2.1.2", "next-nprogress-bar": "^2.1.2",
"next-runtime-env": "^3.2.0",
"next-themes": "^0.2.1", "next-themes": "^0.2.1",
"nextjs-toploader": "^1.6.4", "nextjs-toploader": "^1.6.4",
"npm": "^10.2.5", "npm": "^10.2.5",

View File

@ -1,7 +1,8 @@
import axios from "axios"; import axios from "axios";
import { CookieValueTypes, getCookie } from "cookies-next"; import { CookieValueTypes, getCookie } from "cookies-next";
import { env } from "next-runtime-env";
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP; const NEXT_PUBLIC_BASE_URL_APP = env("NEXT_PUBLIC_BASE_URL_APP");
axios.defaults.baseURL = NEXT_PUBLIC_BASE_URL_APP;
axios.interceptors.request.use(function (config) { axios.interceptors.request.use(function (config) {
const token = getCookie("Sootzani_Admin_Token"); const token = getCookie("Sootzani_Admin_Token");
@ -27,6 +28,7 @@ export async function AddKey(payload: { title: string; publicKey: string }) {
export async function ChangeKey(payload: { export async function ChangeKey(payload: {
privateKey: string; privateKey: string;
publicKeyId: string; publicKeyId: string;
isPolling: boolean;
}) { }) {
const data = await axios.post("api/Admin/ChangeKey", payload); const data = await axios.post("api/Admin/ChangeKey", payload);
return data.data; return data.data;

View File

@ -5,8 +5,9 @@ import {
getCookie, getCookie,
setCookie, setCookie,
} from "cookies-next"; } from "cookies-next";
import { env } from "next-runtime-env";
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP; const NEXT_PUBLIC_BASE_URL_APP = env("NEXT_PUBLIC_BASE_URL_APP");
axios.defaults.baseURL = NEXT_PUBLIC_BASE_URL_APP;
let isRefreshing = false; let isRefreshing = false;

View File

@ -23,3 +23,5 @@ export async function getOptions() {
const data = await axios.get("/api/Common/Options"); const data = await axios.get("/api/Common/Options");
return data.data; return data.data;
} }

View File

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

View File

@ -3,8 +3,9 @@
import axios from "axios"; import axios from "axios";
import { CookieValueTypes, getCookie } from "cookies-next"; import { CookieValueTypes, getCookie } from "cookies-next";
import { RefreshToken } from "./authenticateApi"; import { RefreshToken } from "./authenticateApi";
import { env } from "next-runtime-env";
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP; const NEXT_PUBLIC_BASE_URL_APP = env("NEXT_PUBLIC_BASE_URL_APP");
axios.defaults.baseURL = NEXT_PUBLIC_BASE_URL_APP;
axios.interceptors.request.use(function (config) { axios.interceptors.request.use(function (config) {
const token = getCookie("Sootzani_Admin_Token"); const token = getCookie("Sootzani_Admin_Token");
@ -50,3 +51,10 @@ export async function OperateByInspector(payload: FormData) {
}); });
return data.data; return data.data;
} }
export async function postConnectionId(id: string) {
const data = await axios.post("/api/Common/ConnectionId", id, {
headers: { "Content-Type": "application/json" },
});
return data.data;
}

View File

@ -0,0 +1,27 @@
import {
HttpTransportType,
HubConnectionBuilder,
JsonHubProtocol,
LogLevel,
} from "@microsoft/signalr";
import { getCookie } from "cookies-next";
const token = getCookie("Sootzani_Admin_Token");
const connection = new HubConnectionBuilder()
.withUrl("https://sootzaniapi.shetabdahi.ir/notifhub", {
headers: {
Authorization: `Bearer ${token}`,
},
})
.withAutomaticReconnect()
.withHubProtocol(new JsonHubProtocol())
.configureLogging(LogLevel.Debug)
.build();
// Optional: Configure connection options, such as access token or headers
// connection.on("your-event", (data) => {
// // Handle incoming events
// });
export default connection;