admin/dist/assets/Notifications-62a27ebc.js

2 lines
8.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{j as e}from"./vendor-query-a3e439f2.js";import{r as s}from"./vendor-react-ac1483bd.js";import{P as a,b as r,a as t,B as i}from"./index-590deac5.js";import{P as d}from"./Pagination-ce6b4a1c.js";import{v as l,m as n,B as c,q as x,j as m}from"./vendor-ui-8a3c5c7d.js";import"./vendor-toast-598db4db.js";const o=[{id:1,title:"سفارش جدید دریافت شد",message:"سفارش شماره ۱۰۰۱ از طرف علی احمدی ثبت شد",type:"order",priority:"high",isRead:!1,date:"۱۴۰۲/۰۸/۱۵ - ۱۴:۳۰",sender:"سیستم فروش"},{id:2,title:"محصول در حال اتمام",message:"موجودی لپ‌تاپ ایسوس به کمتر از ۵ عدد رسیده است",type:"warning",priority:"medium",isRead:!1,date:"۱۴۰۲/۰۸/۱۵ - ۱۲:۱۵",sender:"سیستم انبار"},{id:3,title:"کاربر جدید عضو شد",message:"فاطمه حسینی با موفقیت در سیستم ثبت نام کرد",type:"info",priority:"low",isRead:!0,date:"۱۴۰۲/۰۸/۱۴ - ۱۶:۴۵",sender:"سیستم کاربری"},{id:4,title:"پرداخت انجام شد",message:"پرداخت سفارش ۱۰۰۲ با موفقیت تایید شد",type:"success",priority:"medium",isRead:!0,date:"۱۴۰۲/۰۸/۱۴ - ۱۰:۲۰",sender:"سیستم پرداخت"},{id:5,title:"خطا در سیستم",message:"خطا در اتصال به درگاه پرداخت - نیاز به بررسی فوری",type:"error",priority:"high",isRead:!1,date:"۱۴۰۲/۰۸/۱۴ - ۰۹:۱۰",sender:"سیستم مانیتورینگ"},{id:6,title:"بک‌آپ تکمیل شد",message:"بک‌آپ روزانه اطلاعات با موفقیت انجام شد",type:"success",priority:"low",isRead:!0,date:"۱۴۰۲/۰۸/۱۳ - ۲۳:۰۰",sender:"سیستم بک‌آپ"},{id:7,title:"بروزرسانی سیستم",message:"نسخه جدید سیستم منتشر شد - بروزرسانی در دسترس است",type:"info",priority:"medium",isRead:!1,date:"۱۴۰۲/۰۸/۱۳ - ۱۱:۳۰",sender:"تیم توسعه"},{id:8,title:"گزارش فروش آماده شد",message:"گزارش فروش ماهانه تولید و آماده دانلود است",type:"info",priority:"low",isRead:!0,date:"۱۴۰۲/۰۸/۱۲ - ۰۸:۰۰",sender:"سیستم گزارش‌گیری"}],h=()=>{const[h,g]=s.useState(o),[j,p]=s.useState(""),[u,y]=s.useState("all"),[v,N]=s.useState(1),w=s=>{switch(s){case"error":return e.jsx(l,{className:"h-5 w-5 text-red-600"});case"warning":return e.jsx(c,{className:"h-5 w-5 text-yellow-600"});case"success":return e.jsx(c,{className:"h-5 w-5 text-green-600"});case"info":return e.jsx(m,{className:"h-5 w-5 text-blue-600"});default:return e.jsx(c,{className:"h-5 w-5 text-gray-600"})}},f=e=>{switch(e){case"high":return"border-r-red-500";case"medium":return"border-r-yellow-500";case"low":return"border-r-green-500";default:return"border-r-gray-300"}},b=h.filter(e=>{const s=e.title.toLowerCase().includes(j.toLowerCase())||e.message.toLowerCase().includes(j.toLowerCase()),a="all"===u||"unread"===u&&!e.isRead||"read"===u&&e.isRead||e.type===u;return s&&a}),k=Math.ceil(b.length/6),R=6*(v-1),C=b.slice(R,R+6),P=h.filter(e=>!e.isRead).length;return e.jsxs(a,{children:[e.jsx(r,{children:"اعلانات"}),e.jsxs(t,{children:[P," اعلان خوانده نشده از ",h.length," اعلان"]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs(i,{variant:"secondary",onClick:()=>{g(e=>e.map(e=>({...e,isRead:!0})))},disabled:0===P,children:[e.jsx(l,{className:"h-4 w-4 ml-2"}),"همه را خوانده شده علامت بزن"]}),e.jsxs(i,{children:[e.jsx(n,{className:"h-4 w-4 ml-2"}),"اعلان جدید"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[e.jsx("div",{className:"bg-white dark:bg-gray-800 p-4 rounded-lg shadow",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(c,{className:"h-8 w-8 text-blue-600"}),e.jsxs("div",{className:"mr-3",children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:"کل اعلانات"}),e.jsx(t,{children:h.length})]})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 p-4 rounded-lg shadow",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(l,{className:"h-8 w-8 text-red-600"}),e.jsxs("div",{className:"mr-3",children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:"خوانده نشده"}),e.jsx(t,{children:P})]})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 p-4 rounded-lg shadow",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(l,{className:"h-8 w-8 text-red-600"}),e.jsxs("div",{className:"mr-3",children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:"خطا"}),e.jsx(t,{children:h.filter(e=>"error"===e.type).length})]})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 p-4 rounded-lg shadow",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(c,{className:"h-8 w-8 text-yellow-600"}),e.jsxs("div",{className:"mr-3",children:[e.jsx("p",{className:"text-sm font-medium text-gray-600 dark:text-gray-400",children:"هشدار"}),e.jsx(t,{children:h.filter(e=>"warning"===e.type).length})]})]})})]}),e.jsxs("div",{className:"card p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:e.jsx(x,{className:"h-5 w-5 text-gray-400"})}),e.jsx("input",{type:"text",placeholder:"جستجو در اعلانات...",value:j,onChange:e=>p(e.target.value),className:"input pr-10"})]}),e.jsxs("select",{value:u,onChange:e=>y(e.target.value),className:"input min-w-[150px]",children:[e.jsx("option",{value:"all",children:"همه اعلانات"}),e.jsx("option",{value:"unread",children:"خوانده نشده"}),e.jsx("option",{value:"read",children:"خوانده شده"}),e.jsx("option",{value:"error",children:"خطا"}),e.jsx("option",{value:"warning",children:"هشدار"}),e.jsx("option",{value:"success",children:"موفق"}),e.jsx("option",{value:"info",children:"اطلاعات"})]})]}),e.jsx("div",{className:"space-y-4",children:C.map(s=>e.jsx("div",{className:`p-4 border-r-4 ${f(s.priority)} ${s.isRead?"bg-gray-50 dark:bg-gray-700":"bg-white dark:bg-gray-800"} border border-gray-200 dark:border-gray-600 rounded-lg shadow-sm hover:shadow-md transition-shadow`,children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:w(s.type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h3",{className:"text-sm font-medium "+(s.isRead?"text-gray-600 dark:text-gray-400":"text-gray-900 dark:text-gray-100"),children:s.title}),!s.isRead&&e.jsx("div",{className:"w-2 h-2 bg-blue-600 rounded-full"})]}),e.jsx("p",{className:"mt-1 text-sm "+(s.isRead?"text-gray-500 dark:text-gray-500":"text-gray-700 dark:text-gray-300"),children:s.message}),e.jsxs("div",{className:"mt-2 flex items-center text-xs text-gray-500 dark:text-gray-500 space-x-4",children:[e.jsx("span",{children:s.date}),e.jsxs("span",{children:["از: ",s.sender]})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[!s.isRead&&e.jsx(i,{size:"sm",variant:"secondary",onClick:()=>{return e=s.id,void g(s=>s.map(s=>s.id===e?{...s,isRead:!0}:s));var e},children:e.jsx(l,{className:"h-4 w-4"})}),e.jsx(i,{size:"sm",variant:"danger",onClick:()=>{return e=s.id,void g(s=>s.filter(s=>s.id!==e));var e},children:e.jsx(l,{className:"h-4 w-4"})})]})]})},s.id))}),0===C.length&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(c,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"هیچ اعلانی یافت نشد"})]}),e.jsx(d,{currentPage:v,totalPages:k,onPageChange:N,itemsPerPage:6,totalItems:b.length})]})]})};export{h as Notifications};