@@ -329,7 +347,7 @@ export default function RequestStep2() {
)}
/>
-
+
+ {/* {!error ? (
+
+
+ حجم هر فایل حداکثر می بایست{" "}
+ {formatSize(optionsData?.maxFileSize)} مگابایت باشد
+ {" "}
+ و{" "}
+ {`تعداد فایل های پیوست شده می بایست حداکثر ${optionsData?.maxFileCount} تا باشد.`}
+
+ ) : (
+
+ )} */}
);
}}
diff --git a/lib/utils.ts b/lib/utils.ts
index 5e4d5ee..277d104 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -20,7 +20,6 @@ export function convertDate(date: string) {
return convertedDate;
}
-
export function convertFullTime(date: string) {
const convertedDate = dayjs(date + "Z")
.calendar("jalali")
@@ -29,29 +28,13 @@ export function convertFullTime(date: string) {
return convertedDate;
}
-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-----`;
+export function Decrypt(encryptedData: string, privateKey: string) {
const decryptor = new JSEncrypt();
decryptor.setPrivateKey(privateKey);
const decrypted = decryptor.decrypt(encryptedData);
return decrypted;
}
-
export function isAuthorized() {
const token = getCookie("Sootzani_Token");
if (token) {
@@ -60,3 +43,41 @@ 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]}`;
+}
diff --git a/utils/authenticateApi.ts b/utils/authenticateApi.ts
index 2f4a8c4..aa5cc8a 100644
--- a/utils/authenticateApi.ts
+++ b/utils/authenticateApi.ts
@@ -23,8 +23,8 @@ axios.interceptors.response.use(
originalRequest._retry = true;
const accessToken = getCookie("Sootzani_Token");
const refreshToken = getCookie("Sootzani_Refresh_Token");
-
- if (accessToken && refreshToken && !isRefreshing) {
+ //accessToken && refreshToken && !isRefreshing
+ if (!isRefreshing) {
isRefreshing = true;
try {
diff --git a/utils/commonApi.ts b/utils/commonApi.ts
index 25ac97a..80ecb38 100644
--- a/utils/commonApi.ts
+++ b/utils/commonApi.ts
@@ -43,3 +43,8 @@ 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;
+}