/
opt
/
canhelp
/
apps
/
web
/
.next
/
static
/
chunks
/
app
/
notifications
/
/opt/canhelp/apps/web/.next/static/chunks/app/notifications
mkdir
upload
Name
Size
Mode
Actions
page-60aa586eb8f8d602.js
8753
0644
edit
dl
rm
Edit:
/opt/canhelp/apps/web/.next/static/chunks/app/notifications/page-60aa586eb8f8d602.js
(8753B)
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6173],{1592:(e,t,r)=>{"use strict";r.d(t,{CI:()=>i,Hh:()=>o,Jv:()=>s,wV:()=>a,yK:()=>n});let n=(0,r(6504).M)({baseURL:"https://api.canhelp.gr"}),{signIn:s,signOut:i,signUp:o,useSession:a}=n},3854:(e,t,r)=>{Promise.resolve().then(r.bind(r,8666))},8666:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>x});var n=r(4568),s=r(7620),i=r(7541),o=r(1592),a=r(9906),l=r(2982);function c(e){let{type:t}=e,r="w-5 h-5";switch(t){case"new_offer":return(0,n.jsxs)("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("rect",{x:"2",y:"7",width:"20",height:"14",rx:"2"}),(0,n.jsx)("path",{d:"M16 21V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v16"})]});case"offer_accepted":return(0,n.jsxs)("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("polyline",{points:"9 12 11 14 15 10"})]});case"offer_declined":return(0,n.jsxs)("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,n.jsx)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,n.jsx)("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]});case"task_completed":return(0,n.jsx)("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polyline",{points:"20 6 9 17 4 12"})});case"task_cancelled":return(0,n.jsxs)("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),(0,n.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,n.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]});case"new_message":return(0,n.jsx)("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})});case"new_review":return(0,n.jsx)("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})});case"task_invite":return(0,n.jsxs)("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M16 4h2a2 2 0 012 2v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2h2"}),(0,n.jsx)("rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",ry:"1"})]});default:return(0,n.jsxs)("svg",{className:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("path",{d:"M18 8A6 6 0 006 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,n.jsx)("path",{d:"M13.73 21a2 2 0 01-3.46 0"})]})}}let d={new_offer:"bg-green-100 text-green-600",offer_accepted:"bg-green-100 text-green-600",offer_declined:"bg-red-100 text-red-600",task_completed:"bg-emerald-100 text-emerald-600",task_cancelled:"bg-amber-100 text-amber-600",new_message:"bg-purple-100 text-purple-600",new_review:"bg-yellow-100 text-yellow-600",task_invite:"bg-indigo-100 text-indigo-600",referral_reward:"bg-cyan-100 text-cyan-700",specialist_card_submitted:"bg-amber-100 text-amber-700",specialist_card_approved:"bg-green-100 text-green-700",specialist_card_rejected:"bg-rose-100 text-rose-700"};function u(e){var t;if(!e)return null;let r=e.match(/[«""](.+?)[»""]/);return null!=(t=null==r?void 0:r[1])?t:null}function x(){let{data:e,isPending:t}=(0,o.wV)(),r=(0,i.useRouter)(),{t:x,locale:f}=(0,a.Y)(),[h,p]=(0,s.useState)([]),[m,y]=(0,s.useState)(!0);async function g(){await (0,l.NL)(),p(e=>e.map(e=>({...e,isRead:!0})))}async function k(e){await (0,l.Ip)(e),p(t=>t.map(t=>t.id===e?{...t,isRead:!0}:t))}async function w(e,t){e.stopPropagation(),await (0,l.yk)(t).catch(()=>{}),p(e=>e.filter(e=>e.id!==t))}if((0,s.useEffect)(()=>{t||e||r.push("/login")},[e,t]),(0,s.useEffect)(()=>{e&&(0,l.Tr)().then(p).catch(()=>{}).finally(()=>y(!1))},[e]),t||m)return(0,n.jsx)("div",{className:"text-center py-20 text-white",children:x("common.loading")});let j=h.filter(e=>!e.isRead).length,v="ru"===f?"ru-RU":"uk"===f?"uk-UA":"en"===f?"en-US":"el-GR";return(0,n.jsxs)("div",{className:"max-w-2xl mx-auto px-4 py-8",children:[(0,n.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,n.jsxs)("h1",{className:"text-2xl font-bold text-white",children:[x("notif.title")," ",j>0&&(0,n.jsxs)("span",{className:"text-white/70 font-normal text-xl",children:["(",j,")"]})]}),j>0&&(0,n.jsx)("button",{onClick:g,className:"text-sm text-white/80 hover:text-white hover:underline transition",children:x("notif.mark_all")})]}),0===h.length?(0,n.jsx)("div",{className:"text-center py-20 text-white/60",children:x("notif.empty")}):(0,n.jsx)("div",{className:"space-y-2",children:h.map(e=>{var t;let s="referral_reward"===e.type?"/profile?tab=referral":e.referenceId?"new_message"===e.type?"/chat?room=".concat(e.referenceId):"/tasks/".concat(e.referenceId):null,i=async()=>{e.isRead||await k(e.id),s&&r.push(s)};return(0,n.jsxs)("div",{onClick:i,className:"flex items-start gap-3 p-4 rounded-xl border transition ".concat(s?"cursor-pointer":"cursor-default"," ").concat(e.isRead?"bg-white/90 border-white/20 hover:bg-white":"bg-white border-green-300 shadow-sm hover:bg-green-50"),children:[(0,n.jsx)("div",{className:"p-2.5 rounded-xl flex-shrink-0 ".concat(null!=(t=d[e.type])?t:"bg-gray-100 text-gray-500"),children:(0,n.jsx)(c,{type:e.type})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("p",{className:"font-medium ".concat(e.isRead?"text-gray-600":"text-gray-900"),children:x("notif.type.".concat(e.type),x("notif.type.generic","Notification"))}),e.body&&(0,n.jsx)("p",{className:"text-sm text-gray-500 mt-0.5 truncate",children:(()=>{if("new_message"===e.type)return e.body;if("new_review"===e.type){let t=function(e){var t;if(!e)return null;let r=e.match(/(\d+)\s*[★\*]/);return null!=(t=null==r?void 0:r[1])?t:null}(e.body),r=x("notif.body.new_review","");return t&&r?r.replace("{rating}",t):e.body}if("referral_reward"===e.type){let t=function(e){var t;if(!e)return null;let r=e.match(/(\d+)/);return null!=(t=null==r?void 0:r[1])?t:null}(e.body),r=u(e.body),n=x("notif.body.referral_reward","");return n&&t&&r?n.replace("{days}",t).replace("{plan}",r):n||e.body}let t=u(e.body),r=x("notif.body.".concat(e.type),"");return r&&t?r.replace("{title}",t):r||e.body})()}),(0,n.jsx)("p",{className:"text-xs text-gray-400 mt-1",children:function(e){let t=Math.floor((Date.now()-new Date(e).getTime())/1e3),r=Math.floor(t/60),n=Math.floor(r/60),s=Math.floor(n/24);if("ru"===f){if(t<60)return"только что";if(r<60)return"".concat(r," мин. назад");if(n<24)return"".concat(n," ч. назад");if(1===s)return"вчера";if(s<7)return"".concat(s," дн. назад")}else if("uk"===f){if(t<60)return"щойно";if(r<60)return"".concat(r," хв. тому");if(n<24)return"".concat(n," год. тому");if(1===s)return"вчора";if(s<7)return"".concat(s," дн. тому")}else if("en"===f){if(t<60)return"just now";if(r<60)return"".concat(r,"m ago");if(n<24)return"".concat(n,"h ago");if(1===s)return"yesterday";if(s<7)return"".concat(s,"d ago")}else{if(t<60)return"μόλις τώρα";if(r<60)return"".concat(r," λ. πριν");if(n<24)return"".concat(n," ω. πριν");if(1===s)return"χθες";if(s<7)return"".concat(s," μ. πριν")}return new Date(e).toLocaleDateString(v,{day:"numeric",month:"short",year:s>365?"numeric":void 0})}(e.createdAt)})]}),(0,n.jsxs)("div",{className:"flex flex-col items-end gap-2 shrink-0",onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("button",{onClick:t=>w(t,e.id),className:"p-1 rounded-md text-gray-300 hover:text-red-400 hover:bg-red-50 transition",title:x("common.delete","Delete"),children:(0,n.jsxs)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,n.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,n.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),(0,n.jsx)("div",{className:"flex items-center gap-1.5",children:!e.isRead&&(0,n.jsx)("span",{className:"w-2 h-2 bg-green-500 rounded-full"})})]})]},e.id)})})]})}}},e=>{e.O(0,[1516,9906,2982,587,18,7358],()=>e(e.s=3854)),_N_E=e.O()}]);
Save
cmd:
run