From 389ac492c204285304a6ac1671d4cfc29a3a243c Mon Sep 17 00:00:00 2001 From: Mahyar Khanbolooki Date: Sun, 10 Aug 2025 17:54:21 +0330 Subject: [PATCH] refactor: modals --- public/sw.js | 2 +- src/app/[name]/(Main)/chat/page.tsx | 54 +++---- src/components/menu/SideMenu.tsx | 138 ++++++------------ .../overlays/BlurredOverlayContainer.tsx | 1 + src/components/utils/Modal.tsx | 32 ++++ src/components/utils/Prompt.tsx | 47 ++++++ src/features/general/LogoutPrompt.tsx | 46 ++++++ src/hooks/helpers/useToggle.tsx | 17 +++ src/locales/fa/common.json | 6 + 9 files changed, 214 insertions(+), 129 deletions(-) create mode 100644 src/components/utils/Modal.tsx create mode 100644 src/components/utils/Prompt.tsx create mode 100644 src/features/general/LogoutPrompt.tsx create mode 100644 src/hooks/helpers/useToggle.tsx diff --git a/public/sw.js b/public/sw.js index 89f2ef8..96068cc 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1 +1 @@ -if(!self.define){let e,s={};const a=(a,n)=>(a=new URL(a+".js",n).href,s[a]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=a,e.onload=s,document.head.appendChild(e)}else e=a,importScripts(a),s()}).then(()=>{let e=s[a];if(!e)throw new Error(`Module ${a} didn’t register its module`);return e}));self.define=(n,t)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(s[i])return;let c={};const r=e=>a(e,i),d={module:{uri:i},exports:c,require:r};s[i]=Promise.all(n.map(e=>d[e]||r(e))).then(e=>(t(...e),c))}}define(["./workbox-4754cb34"],function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"b5321e205a1a4073b70fe1a02e098012"},{url:"/_next/static/MDjUdUv1dkMz5Dz4Vwtfu/_buildManifest.js",revision:"67ca8384d76b1163a1ecf8412d9d6e1c"},{url:"/_next/static/MDjUdUv1dkMz5Dz4Vwtfu/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/1144-171ce621aabae165.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/1684-ffcaef4aa0c3922b.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/2113.f3779f78993185a6.js",revision:"f3779f78993185a6"},{url:"/_next/static/chunks/2389-0657d56665b1f5b8.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/2467-c6ef6bfe1ee94b6b.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/2617.b8837c5676152b99.js",revision:"b8837c5676152b99"},{url:"/_next/static/chunks/3342-24c32b3c4de17f46.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/3463-2cd6c2977b4d5bee.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/3629-d4af4d56bc54c929.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/3686.f3530ed9b494a670.js",revision:"f3530ed9b494a670"},{url:"/_next/static/chunks/4262-2d530de20fa4ecfb.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/472.a3826d29d6854395.js",revision:"a3826d29d6854395"},{url:"/_next/static/chunks/4bd1b696-a38a8be7401e6000.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/5070.7a5b7c95a73e3852.js",revision:"7a5b7c95a73e3852"},{url:"/_next/static/chunks/5128-333af6c0f78fbaa2.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/5413-d5f4b1b8a5ad2f7e.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/5579.8d10efcb0bcc5a99.js",revision:"8d10efcb0bcc5a99"},{url:"/_next/static/chunks/5872-aae329783ae5a534.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/6291-759ca2f746557bca.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/6418-f901248c89d581c2.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/655-32ce9af232fcaefb.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/6766-1e387420e29e20bf.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/6874-63e751b081f8e305.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/6914.4e4ece51feee1de1.js",revision:"4e4ece51feee1de1"},{url:"/_next/static/chunks/6919-e4ab9adddd8b4faa.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/6940.deea722dce835a26.js",revision:"deea722dce835a26"},{url:"/_next/static/chunks/7493.6298379ce0758927.js",revision:"6298379ce0758927"},{url:"/_next/static/chunks/7820-f97c5220c0687f86.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/8016.4099535a1f89c7a8.js",revision:"4099535a1f89c7a8"},{url:"/_next/static/chunks/8021-c4457d3d52511f40.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/8476-37b457958b167476.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/8722.6bd44e81e045a845.js",revision:"6bd44e81e045a845"},{url:"/_next/static/chunks/8736-147b18bf8e873d61.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/8777-06b19ddc57185f22.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/8905-30fda9ceec41fef5.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/9341.3de5922501c09e3c.js",revision:"3de5922501c09e3c"},{url:"/_next/static/chunks/9725-a8d96124b45b9886.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/cart/page-91e477f2d9c0fabd.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/layout-1ce0755cb235daf5.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/notifications/page-0fc0460353da360c.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/order/checkout/%5Bid%5D/page-73e05b9f4450b21b.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/order/track/%5Bid%5D/page-227ba64e4e4d0256.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/report/page-fcb6febb0cc1fd2f.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/%5Bid%5D/page-5cdef79567eea6a3.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/about/layout-1529ef92b6e5dceb.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/about/page-325905a3e90de8a1.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/chat/%5Bid%5D/page-73c0e81dc0846d10.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/chat/nearby/page-844c1c72b30779fa.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/chat/page-204e8444df7e3124.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/layout-ddb241374fc9f179.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/loading-ad8b652b8b0caa93.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/order/history/layout-0527334368f23614.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/order/history/page-1631e9e33fc097ce.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/page-7187465185590912.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/rating/%5BorderId%5D/page-20737d9c0970ff91.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/transactions/page-f244c71a1f3a708a.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/transactions/review/page-8af4483434ff266a.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Profile)/layout-1933e0236712effd.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Profile)/profile/edit/page-18a241985dc0c61e.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/%5Bname%5D/(Profile)/profile/page-3a6dc97788719fd5.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/_not-found/page-19683a9b97b3bf13.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/auth/layout-e652eddbf45deb13.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/auth/page-56a5d2de789e4285.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/layout-f5975388d871325b.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/loading-f60914b06206fe55.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/app/page-af1c7c046ff85a11.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/d0deef33.aff3d46b768f00e5.js",revision:"aff3d46b768f00e5"},{url:"/_next/static/chunks/framework-fda66049c8bbcca5.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/main-592ffda5d1d5a75d.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/main-app-4afdf4040eb15622.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/pages/_app-5eef2bc2d7659273.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/pages/_error-7c851e5682ba33fe.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-da93b9fc426f8242.js",revision:"MDjUdUv1dkMz5Dz4Vwtfu"},{url:"/_next/static/css/00bae1e936d73e11.css",revision:"00bae1e936d73e11"},{url:"/_next/static/css/85ff3e2932617f14.css",revision:"85ff3e2932617f14"},{url:"/_next/static/media/layers-2x.9859cd12.png",revision:"9859cd12"},{url:"/_next/static/media/layers.ef6db872.png",revision:"ef6db872"},{url:"/_next/static/media/marker-icon.d577052a.png",revision:"d577052a"},{url:"/apple-icon.png",revision:"0c11163d9876662afd598cdb681bb2e4"},{url:"/assets/css/fonts.css",revision:"767635567236928958c4fe946b9ddcfd"},{url:"/assets/fonts/Irancell_Bold.ttf",revision:"e5160b0c919e044bfbcf18a58dd04ad2"},{url:"/assets/fonts/Irancell_Bold.woff",revision:"ed06d53485fd8044e79894bedc597104"},{url:"/assets/fonts/Irancell_Bold.woff2",revision:"04e0058cbeb4dfe083dbf98370ae885e"},{url:"/assets/fonts/Irancell_ExtraBold.ttf",revision:"aca587f4f429c26e887e102f4d46bd27"},{url:"/assets/fonts/Irancell_ExtraBold.woff",revision:"eb70794e10fd476987930ef523ed8a33"},{url:"/assets/fonts/Irancell_ExtraBold.woff2",revision:"5f66486a89926925c4eabcb76aea6ca1"},{url:"/assets/fonts/Irancell_ExtraLight.ttf",revision:"85dd3b644afbabbea860e70d91adb665"},{url:"/assets/fonts/Irancell_ExtraLight.woff",revision:"7491ed7a70e2b9f8fa19c20eac497c12"},{url:"/assets/fonts/Irancell_ExtraLight.woff2",revision:"807b703a3924972991de43d76764f404"},{url:"/assets/fonts/Irancell_Light.ttf",revision:"911a07e375667ba6feeca9a527bc537d"},{url:"/assets/fonts/Irancell_Light.woff",revision:"9c1e83ee95bb25d5adc97011bbab2ae5"},{url:"/assets/fonts/Irancell_Light.woff2",revision:"34404e8d01d1ee40a5bc00311ae2add4"},{url:"/assets/fonts/Irancell_Medium.ttf",revision:"2b8b7463718f1930afc053208efe986e"},{url:"/assets/fonts/Irancell_Medium.woff",revision:"e952c2a8c784e1b13c606f4b9b300310"},{url:"/assets/fonts/Irancell_Medium.woff2",revision:"1955af7b1d4244b4034b793c4435a7e3"},{url:"/assets/fonts/Irancell_Regular.ttf",revision:"3c29a31eaec7ddd32d41879dfcce95b8"},{url:"/assets/fonts/Irancell_Regular.woff",revision:"c9d7d00bddfd0595b68e750574b28312"},{url:"/assets/fonts/Irancell_Regular.woff2",revision:"89eb5fb2d1409229407d1a75426acda0"},{url:"/assets/images/danak-logo.png",revision:"bfbbcd927b3e359c7ab8047211f7c3a3"},{url:"/assets/images/food-image.png",revision:"34520f66d5224a61eca7e83646bdb31e"},{url:"/assets/images/food-preview-hq.png",revision:"42968e21a3044f80db7399459768a16c"},{url:"/assets/images/food-preview.png",revision:"bfc910395c189bfc145fa950dbcca749"},{url:"/assets/images/login-banner.png",revision:"29a467b532dbf3c6e8bcd45e08ea3cde"},{url:"/assets/images/report-hero.svg",revision:"199d4622a1abea7a0d83e6b5df0caf89"},{url:"/assets/images/user-avatar.png",revision:"0d4b4612ad00442263d2a41754fcadcc"},{url:"/favicon.ico",revision:"28202080f3527f526a24b1119885536e"},{url:"/file.svg",revision:"d09f95206c3fa0bb9bd9fefabfd0ea71"},{url:"/globe.svg",revision:"2aaafa6a49b6563925fe440891e32717"},{url:"/icon0.svg",revision:"6d2cbb302b9f3ef7f2b43ae7d355f6c9"},{url:"/icon1.png",revision:"14e00a23129ccbbe02a835997ecca6c0"},{url:"/icons/web-app-manifest-192x192.png",revision:"2bd31374f516557201d060ad4c5695c4"},{url:"/icons/web-app-manifest-512x512.png",revision:"d0f9aa93e12fc2ed5b220efa3db4e689"},{url:"/manifest.json",revision:"9498454e8c03e70a4ed7fa0472e339ba"},{url:"/marker-icon-2x.png",revision:"1c824216f354218b04b25a57e0f7ab1f"},{url:"/marker-icon.png",revision:"1c824216f354218b04b25a57e0f7ab1f"},{url:"/marker-shadow.png",revision:"44014eaa598e7050354603adfb44f812"},{url:"/next.svg",revision:"8e061864f388b47f33a1c3780831193e"},{url:"/vercel.svg",revision:"c0af2f507b369b085b35ef4bbe3bcf1e"},{url:"/window.svg",revision:"a2760511c65806022ad20adf74370ff3"}],{ignoreURLParametersMatching:[]}),e.cleanupOutdatedCaches(),e.registerRoute("/",new e.NetworkFirst({cacheName:"start-url",plugins:[{cacheWillUpdate:async({request:e,response:s,event:a,state:n})=>s&&"opaqueredirect"===s.type?new Response(s.body,{status:200,statusText:"OK",headers:s.headers}):s}]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,new e.CacheFirst({cacheName:"google-fonts-webfonts",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:31536e3})]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,new e.StaleWhileRevalidate({cacheName:"google-fonts-stylesheets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,new e.StaleWhileRevalidate({cacheName:"static-font-assets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,new e.StaleWhileRevalidate({cacheName:"static-image-assets",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/image\?url=.+$/i,new e.StaleWhileRevalidate({cacheName:"next-image",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp3|wav|ogg)$/i,new e.CacheFirst({cacheName:"static-audio-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp4)$/i,new e.CacheFirst({cacheName:"static-video-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:js)$/i,new e.StaleWhileRevalidate({cacheName:"static-js-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:css|less)$/i,new e.StaleWhileRevalidate({cacheName:"static-style-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/data\/.+\/.+\.json$/i,new e.StaleWhileRevalidate({cacheName:"next-data",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:json|xml|csv)$/i,new e.NetworkFirst({cacheName:"static-data-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>{if(!(self.origin===e.origin))return!1;const s=e.pathname;return!s.startsWith("/api/auth/")&&!!s.startsWith("/api/")},new e.NetworkFirst({cacheName:"apis",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:16,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>{if(!(self.origin===e.origin))return!1;return!e.pathname.startsWith("/api/")},new e.NetworkFirst({cacheName:"others",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>!(self.origin===e.origin),new e.NetworkFirst({cacheName:"cross-origin",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:3600})]}),"GET")}); +if(!self.define){let e,s={};const a=(a,n)=>(a=new URL(a+".js",n).href,s[a]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=a,e.onload=s,document.head.appendChild(e)}else e=a,importScripts(a),s()}).then(()=>{let e=s[a];if(!e)throw new Error(`Module ${a} didn’t register its module`);return e}));self.define=(n,c)=>{const i=e||("document"in self?document.currentScript.src:"")||location.href;if(s[i])return;let t={};const r=e=>a(e,i),f={module:{uri:i},exports:t,require:r};s[i]=Promise.all(n.map(e=>f[e]||r(e))).then(e=>(c(...e),t))}}define(["./workbox-4754cb34"],function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"119991156c5c9c52e49eaaf8285938fd"},{url:"/_next/static/chunks/1144-bf4fd0fb9300f10e.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/1684-11698643458643c6.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/2113.ba3b57723165769d.js",revision:"ba3b57723165769d"},{url:"/_next/static/chunks/2389-e0f67a29af8afe4d.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/2467-b93afbbb2f9943d7.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/2529-3384a83a61589047.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/2617.6b1a4c7144e9c103.js",revision:"6b1a4c7144e9c103"},{url:"/_next/static/chunks/3342-f5d4e9728e64c641.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/3463-2c1f12b3d33d3a83.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/3629-e1cafe27cb7b14a4.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/3686.a95b9fbf57e88095.js",revision:"a95b9fbf57e88095"},{url:"/_next/static/chunks/4262-69231afee4eb2eda.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/472.2c08b965bd9148e2.js",revision:"2c08b965bd9148e2"},{url:"/_next/static/chunks/4bd1b696-067377ed8fa0f8ba.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/5070.ad19d2678fe10023.js",revision:"ad19d2678fe10023"},{url:"/_next/static/chunks/5116-2d9fa3b51c1c3b27.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/5523-6ad10654e3ff43cb.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/5579.3c843649ac710d13.js",revision:"3c843649ac710d13"},{url:"/_next/static/chunks/5872-1614e8ba877e8427.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/6087-fcaeecf24c105c0a.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/6291-7ab41cb7924ac30d.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/6418-81ed7568d3f678ec.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/655-af789806e60151a0.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/6766-43a0010fecddb129.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/6874-cc313808d41764ae.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/6914.a2221be2e59a3d08.js",revision:"a2221be2e59a3d08"},{url:"/_next/static/chunks/6919-455120ee4a15c1f2.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/6940.6e534050ce72a66f.js",revision:"6e534050ce72a66f"},{url:"/_next/static/chunks/7493.5508135cff4eb902.js",revision:"5508135cff4eb902"},{url:"/_next/static/chunks/7820-f10526c9f05d66a9.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/8016.5b4d054c4c82efc6.js",revision:"5b4d054c4c82efc6"},{url:"/_next/static/chunks/8021-311f4aa8711b0e17.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/8476-ec78396d7875a485.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/8722.6f9912a46b85dd1a.js",revision:"6f9912a46b85dd1a"},{url:"/_next/static/chunks/8736-59c41023a621ac50.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/8777-eed465db8fcf6db2.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/8905-d2eeca70714b6607.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/9341.3ca6eb08eac1d97b.js",revision:"3ca6eb08eac1d97b"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/cart/page-78fdfcd6b16e44da.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/layout-392051b7c7bd6e7b.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/notifications/page-fe5c93a1d05d0a87.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/order/checkout/%5Bid%5D/page-ec106499e88789c2.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/order/track/%5Bid%5D/page-f89760076c7ab538.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/report/page-9f3704a541e44857.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Dialogs)/verify/page-455ff51575312897.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/%5Bid%5D/page-debda7c2a00ca4a5.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/about/layout-bcb49b48c4b987eb.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/about/page-d896c15ddc6cc1d6.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/chat/%5Bid%5D/page-7acade55d4aedd91.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/chat/nearby/page-3b709ac35ae9fcf8.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/chat/page-7addc6b21ffb851d.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/layout-07678e87dc1cc2db.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/loading-751a342f27893c77.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/order/history/layout-a05de77610545817.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/order/history/page-336bf2695d7a6893.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/page-251ed9f5ff489731.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/rating/%5BorderId%5D/page-53581fd3cc41b806.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/transactions/page-daa674286b6ee60f.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Main)/transactions/review/page-1a719dde5e06349c.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Profile)/layout-9b529f319dd01ddc.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Profile)/profile/address/new/page-2e08636e0766ca7e.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Profile)/profile/address/page-12c77299f4f61d7f.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Profile)/profile/edit/page-60735fc684c3b451.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Profile)/profile/page-09e482700f55e474.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/%5Bname%5D/(Profile)/profile/wallet/page-51f4e1d630bd8991.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/_not-found/page-f3096dbf2c1d54ec.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/auth/layout-f298c3cfe3a3b257.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/auth/page-fe0ec542e4712b6a.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/layout-4fb4627f2047c835.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/loading-280ca04ee0fa38be.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/app/page-24ac86fde0f9a343.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/d0deef33.a586094e67e92d1c.js",revision:"a586094e67e92d1c"},{url:"/_next/static/chunks/framework-82b67a6346ddd02b.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/main-app-9eb80f34b8b8bf12.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/main-e3fd8cee18a1626e.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/pages/_app-0b0b6e26a728d49c.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/pages/_error-f94192b14105bd76.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-704646f773aab7fe.js",revision:"pIcj2Eylg7fXFKhr7W_50"},{url:"/_next/static/css/85ff3e2932617f14.css",revision:"85ff3e2932617f14"},{url:"/_next/static/css/cebb514e7b376766.css",revision:"cebb514e7b376766"},{url:"/_next/static/media/layers-2x.9859cd12.png",revision:"9859cd12"},{url:"/_next/static/media/layers.ef6db872.png",revision:"ef6db872"},{url:"/_next/static/media/marker-icon.d577052a.png",revision:"d577052a"},{url:"/_next/static/pIcj2Eylg7fXFKhr7W_50/_buildManifest.js",revision:"865799247e2fa4847d2f29b66a0ea642"},{url:"/_next/static/pIcj2Eylg7fXFKhr7W_50/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/apple-icon.png",revision:"0c11163d9876662afd598cdb681bb2e4"},{url:"/assets/css/fonts.css",revision:"767635567236928958c4fe946b9ddcfd"},{url:"/assets/fonts/Irancell_Bold.ttf",revision:"e5160b0c919e044bfbcf18a58dd04ad2"},{url:"/assets/fonts/Irancell_Bold.woff",revision:"ed06d53485fd8044e79894bedc597104"},{url:"/assets/fonts/Irancell_Bold.woff2",revision:"04e0058cbeb4dfe083dbf98370ae885e"},{url:"/assets/fonts/Irancell_ExtraBold.ttf",revision:"aca587f4f429c26e887e102f4d46bd27"},{url:"/assets/fonts/Irancell_ExtraBold.woff",revision:"eb70794e10fd476987930ef523ed8a33"},{url:"/assets/fonts/Irancell_ExtraBold.woff2",revision:"5f66486a89926925c4eabcb76aea6ca1"},{url:"/assets/fonts/Irancell_ExtraLight.ttf",revision:"85dd3b644afbabbea860e70d91adb665"},{url:"/assets/fonts/Irancell_ExtraLight.woff",revision:"7491ed7a70e2b9f8fa19c20eac497c12"},{url:"/assets/fonts/Irancell_ExtraLight.woff2",revision:"807b703a3924972991de43d76764f404"},{url:"/assets/fonts/Irancell_Light.ttf",revision:"911a07e375667ba6feeca9a527bc537d"},{url:"/assets/fonts/Irancell_Light.woff",revision:"9c1e83ee95bb25d5adc97011bbab2ae5"},{url:"/assets/fonts/Irancell_Light.woff2",revision:"34404e8d01d1ee40a5bc00311ae2add4"},{url:"/assets/fonts/Irancell_Medium.ttf",revision:"2b8b7463718f1930afc053208efe986e"},{url:"/assets/fonts/Irancell_Medium.woff",revision:"e952c2a8c784e1b13c606f4b9b300310"},{url:"/assets/fonts/Irancell_Medium.woff2",revision:"1955af7b1d4244b4034b793c4435a7e3"},{url:"/assets/fonts/Irancell_Regular.ttf",revision:"3c29a31eaec7ddd32d41879dfcce95b8"},{url:"/assets/fonts/Irancell_Regular.woff",revision:"c9d7d00bddfd0595b68e750574b28312"},{url:"/assets/fonts/Irancell_Regular.woff2",revision:"89eb5fb2d1409229407d1a75426acda0"},{url:"/assets/images/danak-logo.png",revision:"bfbbcd927b3e359c7ab8047211f7c3a3"},{url:"/assets/images/food-image.png",revision:"34520f66d5224a61eca7e83646bdb31e"},{url:"/assets/images/food-preview-hq.png",revision:"42968e21a3044f80db7399459768a16c"},{url:"/assets/images/food-preview.png",revision:"bfc910395c189bfc145fa950dbcca749"},{url:"/assets/images/login-banner.png",revision:"29a467b532dbf3c6e8bcd45e08ea3cde"},{url:"/assets/images/report-hero.svg",revision:"199d4622a1abea7a0d83e6b5df0caf89"},{url:"/assets/images/user-avatar.png",revision:"0d4b4612ad00442263d2a41754fcadcc"},{url:"/favicon.ico",revision:"28202080f3527f526a24b1119885536e"},{url:"/file.svg",revision:"d09f95206c3fa0bb9bd9fefabfd0ea71"},{url:"/globe.svg",revision:"2aaafa6a49b6563925fe440891e32717"},{url:"/icon0.svg",revision:"6d2cbb302b9f3ef7f2b43ae7d355f6c9"},{url:"/icon1.png",revision:"14e00a23129ccbbe02a835997ecca6c0"},{url:"/icons/web-app-manifest-192x192.png",revision:"2bd31374f516557201d060ad4c5695c4"},{url:"/icons/web-app-manifest-512x512.png",revision:"d0f9aa93e12fc2ed5b220efa3db4e689"},{url:"/manifest.json",revision:"9498454e8c03e70a4ed7fa0472e339ba"},{url:"/marker-icon-2x.png",revision:"1c824216f354218b04b25a57e0f7ab1f"},{url:"/marker-icon.png",revision:"1c824216f354218b04b25a57e0f7ab1f"},{url:"/marker-shadow.png",revision:"44014eaa598e7050354603adfb44f812"},{url:"/next.svg",revision:"8e061864f388b47f33a1c3780831193e"},{url:"/vercel.svg",revision:"c0af2f507b369b085b35ef4bbe3bcf1e"},{url:"/window.svg",revision:"a2760511c65806022ad20adf74370ff3"}],{ignoreURLParametersMatching:[]}),e.cleanupOutdatedCaches(),e.registerRoute("/",new e.NetworkFirst({cacheName:"start-url",plugins:[{cacheWillUpdate:async({request:e,response:s,event:a,state:n})=>s&&"opaqueredirect"===s.type?new Response(s.body,{status:200,statusText:"OK",headers:s.headers}):s}]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:gstatic)\.com\/.*/i,new e.CacheFirst({cacheName:"google-fonts-webfonts",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:31536e3})]}),"GET"),e.registerRoute(/^https:\/\/fonts\.(?:googleapis)\.com\/.*/i,new e.StaleWhileRevalidate({cacheName:"google-fonts-stylesheets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i,new e.StaleWhileRevalidate({cacheName:"static-font-assets",plugins:[new e.ExpirationPlugin({maxEntries:4,maxAgeSeconds:604800})]}),"GET"),e.registerRoute(/\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i,new e.StaleWhileRevalidate({cacheName:"static-image-assets",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/image\?url=.+$/i,new e.StaleWhileRevalidate({cacheName:"next-image",plugins:[new e.ExpirationPlugin({maxEntries:64,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp3|wav|ogg)$/i,new e.CacheFirst({cacheName:"static-audio-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:mp4)$/i,new e.CacheFirst({cacheName:"static-video-assets",plugins:[new e.RangeRequestsPlugin,new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:js)$/i,new e.StaleWhileRevalidate({cacheName:"static-js-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:css|less)$/i,new e.StaleWhileRevalidate({cacheName:"static-style-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\/_next\/data\/.+\/.+\.json$/i,new e.StaleWhileRevalidate({cacheName:"next-data",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(/\.(?:json|xml|csv)$/i,new e.NetworkFirst({cacheName:"static-data-assets",plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>{if(!(self.origin===e.origin))return!1;const s=e.pathname;return!s.startsWith("/api/auth/")&&!!s.startsWith("/api/")},new e.NetworkFirst({cacheName:"apis",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:16,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>{if(!(self.origin===e.origin))return!1;return!e.pathname.startsWith("/api/")},new e.NetworkFirst({cacheName:"others",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:86400})]}),"GET"),e.registerRoute(({url:e})=>!(self.origin===e.origin),new e.NetworkFirst({cacheName:"cross-origin",networkTimeoutSeconds:10,plugins:[new e.ExpirationPlugin({maxEntries:32,maxAgeSeconds:3600})]}),"GET")}); diff --git a/src/app/[name]/(Main)/chat/page.tsx b/src/app/[name]/(Main)/chat/page.tsx index d1918c3..1da44f7 100644 --- a/src/app/[name]/(Main)/chat/page.tsx +++ b/src/app/[name]/(Main)/chat/page.tsx @@ -1,8 +1,6 @@ 'use client'; -import Button from '@/components/button/PrimaryButton'; import SearchBox from '@/components/input/SearchBox'; -import BlurredOverlayContainer from '@/components/overlays/BlurredOverlayContainer'; import { ScrollArea } from '@/components/ui/scrollarea'; import { Radar2, Trash } from 'iconsax-react'; import { Check, CheckCheck } from 'lucide-react'; @@ -10,10 +8,10 @@ import Image from 'next/image'; import Link from 'next/link'; import React, { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next'; -import { motion } from 'framer-motion'; import { LongPressCallbackMeta, LongPressReactEvents, useLongPress } from 'use-long-press' import { useRouter } from 'next/navigation'; -import { ef } from '@/lib/helpers/utfNumbers'; +import useToggle from '@/hooks/helpers/useToggle'; +import Prompt from '@/components/utils/Prompt'; type Props = object @@ -36,8 +34,8 @@ function ChatIndex({ }: Props) { }); const [search, setSearch] = useState(''); const [selectedChats, setSelectedChats] = useState>([]); - const [deleteModalVisible, setDeleteModalVisible] = useState(false); const router = useRouter(); + const { active: deleteModal, onToggle: onToggleDeleteModal } = useToggle(); const [chatsList, setChatList] = useState>([ { @@ -105,12 +103,10 @@ function ChatIndex({ }: Props) { const toggleDeleteModalVisiblity = (e?: React.MouseEvent) => { e?.preventDefault(); e?.stopPropagation(); - setDeleteModalVisible((state) => { - if (state) { - setSelectedChats([]); - } - return !state; - }); + if (deleteModal) { + setSelectedChats([]); + } + onToggleDeleteModal() }; const deleteSelectedChats = () => { @@ -157,7 +153,7 @@ function ChatIndex({ }: Props) { setSearch(e.target.value)} /> {selectedChats.length > 0 ? - + : @@ -222,30 +218,16 @@ function ChatIndex({ }: Props) { - -
- -

- {tDeleteModal('Heading')} -

-

- {tDeleteModal('Description').replace('{count}', ef(selectedChats.length))} -

-
- - -
-
-
-
+ ) } diff --git a/src/components/menu/SideMenu.tsx b/src/components/menu/SideMenu.tsx index ce75c49..dbbc075 100644 --- a/src/components/menu/SideMenu.tsx +++ b/src/components/menu/SideMenu.tsx @@ -1,18 +1,20 @@ 'use client'; -import React, { useMemo, useRef, useState } from 'react'; +import React, { useMemo, useRef } from 'react'; import { motion, PanInfo, Variants } from 'framer-motion'; import SideMenuItem from './SideMenuItem'; import NoteBoardIcon from '../icons/NoteBoardIcon'; import BlurredOverlayContainer from '../overlays/BlurredOverlayContainer'; import NightModeSwitch from '../button/NightModeSwitch'; import Button from '../button/PrimaryButton'; -import { useAuthStore } from '@/zustand/authStore'; -import { useParams, usePathname, useRouter } from 'next/navigation'; +import { useParams, usePathname } from 'next/navigation'; import clsx from 'clsx'; import { useTranslation } from 'react-i18next'; import { CalendarSearch, Cup, DirectboxReceive, DocumentCopy, Game, Icon, Instagram, Like1, LogoutCurve, Notification, Receipt1, Setting2, Share, TicketDiscount, Whatsapp } from 'iconsax-react'; import TelegramIcon from '../icons/TelegramIcon'; +import Modal from '../utils/Modal'; +import LogoutPrompt from '@/features/general/LogoutPrompt'; +import useToggle from '@/hooks/helpers/useToggle'; type MenuItemType = { href: string | undefined; @@ -49,21 +51,17 @@ type Props = { function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeState }: Props) { const menuStateMemo = useMemo(() => menuState, [menuState]); - const [logoutModalVisible, setLogoutModalVisible] = useState(false); - const [shareModalVisible, setShareModalVisible] = useState(false); const closeRef = useRef(null); const userIsAuthenticated = true; // useAuthStore((state) => state.isAuthenticated); - const authLogout = useAuthStore((state) => state.logout); - const router = useRouter(); + const { active: logoutModal, onToggle: onToggleLogoutModal } = useToggle(); + const { active: shareModal, onToggle: onToggleShareModal } = useToggle(); + const params = useParams(); const { name } = params; const pathname = usePathname(); const { t: tMenu } = useTranslation('common', { keyPrefix: 'SideMenu' }); - const { t: tLogoutModal } = useTranslation('common', { - keyPrefix: 'LogoutModal' - }); const { t: tShareModal } = useTranslation('common', { keyPrefix: 'ShareModal' }); @@ -79,29 +77,9 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS } }; - const toggleLogoutModalVisiblity = (e?: React.MouseEvent) => { - e?.preventDefault(); - e?.stopPropagation(); - setLogoutModalVisible((state) => !state); - }; - - const toggleShareModalVisiblity = (e?: React.MouseEvent) => { - e?.preventDefault(); - e?.stopPropagation(); - setShareModalVisible((state) => !state); - }; - - const onLogout = (e: React.MouseEvent | null) => { - if (!e) return; - if (userIsAuthenticated) { - authLogout(); - router.replace('/'); - } - }; - const hrefOnClicks = [ - { href: '?logout', handler: toggleLogoutModalVisiblity }, - { href: '?share', handler: toggleShareModalVisiblity } + { href: '?logout', handler: onToggleLogoutModal }, + { href: '?share', handler: onToggleShareModal } ]; const renderMenu = () => { @@ -210,80 +188,56 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS className="fixed top-0 bottom-0 right-0 bg-white w-[200px] h-dvh flex flex-col z-40 overflow-clip not-xl:!rounded-s-none" > {renderMenu()} + {String(logoutModal)} - {/* Logout Modal */} - -
- -

- {tLogoutModal('Heading')} -

-

- {tLogoutModal('Description')} -

-
- - -
-
-
-
+ {/* Share modal */} - -
- -

- - {tShareModal('Heading')} -

-

- {tShareModal('Description')} -

+ +

+ + {tShareModal('Heading')} +

+

+ {tShareModal('Description')} +

- + -
-
- - Telegram -
-
- - WhatsApp -
-
- - Instagram -
-
-
+
+
+ + Telegram +
+
+ + WhatsApp +
+
+ + Instagram +
- + ); } diff --git a/src/components/overlays/BlurredOverlayContainer.tsx b/src/components/overlays/BlurredOverlayContainer.tsx index 1f83cbf..7ad53cf 100644 --- a/src/components/overlays/BlurredOverlayContainer.tsx +++ b/src/components/overlays/BlurredOverlayContainer.tsx @@ -14,6 +14,7 @@ export type BlurredOverlayContainerProps = { outDuration?: number children: ReactNode noBlur?: boolean + onClick?: React.MouseEventHandler | undefined } & React.ComponentProps const BlurredOverlayContainer = ({ diff --git a/src/components/utils/Modal.tsx b/src/components/utils/Modal.tsx new file mode 100644 index 0000000..f1bab90 --- /dev/null +++ b/src/components/utils/Modal.tsx @@ -0,0 +1,32 @@ +import { motion } from 'framer-motion' +import React from 'react' +import BlurredOverlayContainer, { BlurredOverlayContainerProps } from '../overlays/BlurredOverlayContainer' + +type Props = { + +} & BlurredOverlayContainerProps + +function Modal({ visible, onClick, children, ...rest }: Props) { + return ( + +
+ + {children} + +
+
+ ) +} + +export default Modal \ No newline at end of file diff --git a/src/components/utils/Prompt.tsx b/src/components/utils/Prompt.tsx new file mode 100644 index 0000000..ee6d72d --- /dev/null +++ b/src/components/utils/Prompt.tsx @@ -0,0 +1,47 @@ +import { BlurredOverlayContainerProps } from '@/components/overlays/BlurredOverlayContainer' +import Modal from '@/components/utils/Modal' +import React from 'react' +import { useTranslation } from 'react-i18next' +import { Button } from '../ui/button' + +export type PromptProps = { + title?: string, + description?: string, + textConfirm?: string, + textCancel?: string, + onConfirm: React.MouseEventHandler | undefined, + onCancel: React.MouseEventHandler | undefined, + children?: React.ReactNode | null +} & Omit + +function Prompt({ title, description, textConfirm, textCancel, onConfirm, onCancel, visible, onClick, children = null, ...rest }: PromptProps) { + const { t } = useTranslation('common', { + keyPrefix: 'DefaultPrompt' + }); + + return ( + +

+ {title ?? t('Heading')} +

+

+ {description ?? t('Description')} +

+ {children} +
+ + +
+
+ ) +} + +export default Prompt \ No newline at end of file diff --git a/src/features/general/LogoutPrompt.tsx b/src/features/general/LogoutPrompt.tsx new file mode 100644 index 0000000..ec8efe9 --- /dev/null +++ b/src/features/general/LogoutPrompt.tsx @@ -0,0 +1,46 @@ +import Prompt, { PromptProps } from '@/components/utils/Prompt' +import { useAuthStore } from '@/zustand/authStore'; +import { useRouter } from 'next/navigation'; +import React from 'react' +import { useTranslation } from 'react-i18next' + + +function LogoutPrompt({ ...rest }: Omit) { + const { t } = useTranslation('common', { + keyPrefix: 'LogoutModal' + }); + const authLogout = useAuthStore((state) => state.logout); + const router = useRouter(); + const userIsAuthenticated = useAuthStore((state) => state.isAuthenticated); + + const onConfirmLogout = (e: React.MouseEvent) => { + if (!e) return; + if (userIsAuthenticated) { + authLogout(); + } + router.replace('/'); + }; + + const toggleShareModalVisiblity = (e: React.MouseEvent) => { + e?.preventDefault(); + e?.stopPropagation(); + console.log(e); + rest.onClick?.(e); + }; + + + return ( + + <> + + ) +} + +export default LogoutPrompt \ No newline at end of file diff --git a/src/hooks/helpers/useToggle.tsx b/src/hooks/helpers/useToggle.tsx new file mode 100644 index 0000000..2380c23 --- /dev/null +++ b/src/hooks/helpers/useToggle.tsx @@ -0,0 +1,17 @@ +import { useState } from 'react' + +const useToggle = () => { + const [active, setActive] = useState(false); + + const onToggle = (e?: React.MouseEvent | null) => { + if (e) { + e.preventDefault(); + e.stopPropagation(); + } + setActive((prev) => !prev); + } + + return { active, onToggle } +} + +export default useToggle \ No newline at end of file diff --git a/src/locales/fa/common.json b/src/locales/fa/common.json index b8f9158..5a20e92 100644 --- a/src/locales/fa/common.json +++ b/src/locales/fa/common.json @@ -23,6 +23,12 @@ "NavAriaLabel": "لینک‌های اصلی", "ControlsAriaLabel": "پایین منو" }, + "Prompt": { + "Heading": "نیازمند تایید", + "Description": "آیا ادامه میدهید؟", + "ButtonOk": "بله", + "ButtonCancel": "خیر" + }, "LogoutModal": { "Heading": "خروج از سیستم", "Description": "آیا میخواهید از سیستم خارج شوید؟",