PageSourceSearch

https://2extremetattoos.replit.app/assets/AdminEmployeeContacts-DKGlBF-M.js

js 2extremetattoos.replit.app collected 2026-10-03 03:48:38 UTC 19,079 bytes, 1 lines download raw bytes

1import{z as ie,d as ne,a3 as oe,r as n,Z as P,j as e,v as T,B as le,G as de,F as ce,S as me,H as he,J as xe,l as L,X as v,c as O}from"./index-B0KZjT76.js";import{D as pe,a as ue,b as be,c as r,d as q}from"./dropdown-menu-D8CaclTV.js";import{U as I}from"./user-iCY_JRbu.js";import{M as ge}from"./message-square-BrOvnUMA.js";import{C as we}from"./calendar-DOmYjzee.js";import{C as M}from"./calendar-days-BQRGVn-Q.js";import{D as R}from"./dollar-sign-zjO4gKz3.js";import{C as K}from"./chart-column-CAAeoptj.js";import{W as fe}from"./wallet-DtL7_nVC.js";import{B as ye}from"./briefcase-DuQN4hRn.js";import{L as je}from"./log-out-jr-pE4Jq.js";import{P as Ne}from"./plus-BOJ6JLy-.js";import{P as ve}from"./pencil-DwA7GK8q.js";import{T as Q}from"./trash-2-CVj4Yrzo.js";import{R as Ce}from"./rotate-ccw-D1FcB1j_.js";import"./index-Ilh8sr6A.js";import"./chevron-right-SolNm5nm.js";const U=[{id:"university",label:"University Mall"},{id:"wesley-chapel",label:"Wesley Chapel"}],C=[{id:"university",label:"University Mall"},{id:"wesley-chapel",label:"Wesley Chapel"},{id:"both",label:"Both Locations"}];function Ue(){const[,s]=ie(),{toast:l}=ne(),d=oe(),[x,_]=n.useState(!1),[k,B]=n.useState(""),[W,G]=n.useState(""),[c,J]=n.useState("university"),[p,H]=n.useState(!1),[Y,u]=n.useState(null),[b,F]=n.useState(""),[g,D]=n.useState(""),[z,w]=n.useState(!1),[m,f]=n.useState(""),[y,j]=n.useState(""),[A,$]=n.useState("university"),[E,S]=n.useState(""),o=k==="admin";n.useEffect(()=>{fetch("/api/auth/me",{credentials:"include"}).then(t=>t.json()).then(t=>{if(!t.isAdmin&&t.role!=="staff"){s("/admin/login");return}B(t.role||(t.isAdmin?"admin":"staff")),G(t.username||""),_(!0)}).catch(()=>s("/admin/login"))},[s]);const{data:h=[],isLoading:X}=P({queryKey:["employee-contacts",c],queryFn:async()=>{const t=await fetch(`/api/admin/employee-contacts?locationId=${c}`,{credentials:"include"});if(!t.ok)throw new Error("Failed to fetch contacts");return t.json()},enabled:x}),{data:N=[]}=P({queryKey:["employee-contacts-deleted"],queryFn:async()=>{const t=await fetch("/api/admin/employee-contacts/deleted",{credentials:"include"});if(!t.ok)throw new Error("Failed to fetch deleted contacts");return t.json()},enabled:x&&o&&p}),Z=async()=>{if(!(!m.trim()||!y.trim()))try{if(!(await fetch("/api/admin/employee-contacts",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:m.trim(),phone:y.trim(),locationId:A})})).ok)throw new Error("Failed to create contact");d.invalidateQueries({queryKey:["employee-contacts"]}),f(""),j(""),$("university"),w(!1),l({title:"Contact Added",description:`${m.trim()} has been added.`})}catch{l({title:"Error",description:"Failed to add contact",variant:"destructive"})}},V=async t=>{if(!(!b.trim()||!g.trim()))try{if(!(await fetch(`/api/admin/employee-contacts/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:b.trim(),phone:g.trim(),locationId:E})})).ok)throw new Error("Failed to update contact");d.invalidateQueries({queryKey:["employee-contacts"]}),u(null),l({title:"Contact Updated"})}catch{l({title:"Error",description:"Failed to update contact",variant:"destructive"})}},ee=async(t,a)=>{try{if(!(await fetch(`/api/admin/employee-contacts/${t}`,{method:"DELETE",credentials:"include"})).ok)throw new Error("Failed to delete contact");d.invalidateQueries({queryKey:["employee-contacts"]}),d.invalidateQueries({queryKey:["employee-contacts-deleted"]}),l({title:"Contact Deleted",description:`${a} has been removed.`})}catch{l({title:"Error",description:"Failed to delete contact",variant:"destructive"})}},te=async(t,a)=>{try{if(!(await fetch(`/api/admin/employee-contacts/${t}/restore`,{method:"POST",credentials:"include"})).ok)throw new Error("Failed to restore contact");d.invalidateQueries({queryKey:["employee-contacts"]}),d.invalidateQueries({queryKey:["employee-contacts-deleted"]}),l({title:"Contact Restored",description:`${a} has been restored.`})}catch{l({title:"Error",description:"Failed to restore contact",variant:"destructive"})}},se=async(t,a)=>{if(confirm(`Permanently delete ${a}? This cannot be undone.`))try{if(!(await fetch(`/api/admin/employee-contacts/${t}/permanent`,{method:"DELETE",credentials:"include"})).ok)throw new Error("Failed to permanently delete contact");d.invalidateQueries({queryKey:["employee-contacts-deleted"]}),l({title:"Permanently Deleted",description:`${a} has been permanently removed.`})}catch{l({title:"Error",description:"Failed to permanently delete contact",variant:"destructive"})}},ae=async()=>{await fetch("/api/admin/logout",{method:"POST",credentials:"include"}),s("/admin/login")},re=t=>{u(t.id),F(t.name),D(t.phone),S(t.locationId)};return x?e.jsx("div",{className:"min-h-screen bg-[#0a0a0a] text-white","data-testid":"page-employee-contacts",children:e.jsxs("div",{className:"max-w-[1200px] mx-auto p-4 md:p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 mb-6",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("h1",{className:"text-xl md:text-2xl font-bold","data-testid":"text-page-title",children:[e.jsx(T,{className:"w-6 h-6 inline mr-2 text-[#D4AF37]"}),e.jsx("span",{className:"text-[#D4AF37]",children:"EMPLOYEE"})," CONTACTS"]}
1)}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-white/5 border border-white/10 rounded-lg px-3 py-1.5",children:[e.jsx("span",{className:"text-sm text-gray-400","data-testid":"text-username",children:W}),e.jsx("span",{className:`text-[10px] font-bold uppercase px-2 py-0.5 rounded ${o?"bg-[#D4AF37]/20 text-[#D4AF37]":"bg-blue-500/20 text-blue-400"}`,"data-testid":"text-role",children:k})]}),e.jsxs(pe,{children:[e.jsx(ue,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-2 bg-[#4169E1] hover:bg-[#3558c4] px-4 py-2 rounded-lg text-sm font-bold transition-colors","data-testid":"button-navigate",children:[e.jsx(le,{className:"w-4 h-4"})," Navigate"]})}),e.jsxs(be,{className:"bg-[#1a1a1a] border-white/10 text-white min-w-[200px]",children:[e.jsxs(r,{onClick:()=>s("/admin/clients"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(I,{className:"w-4 h-4 text-white"})," Client Database"]}),e.jsxs(r,{onClick:()=>s("/admin/quotes"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(ge,{className:"w-4 h-4 text-[#4169E1]"})," Consultations"]}),e.jsxs(r,{onClick:()=>s("/admin/appointments"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(we,{className:"w-4 h-4 text-green-400"})," Appointments"]}),e.jsxs(r,{onClick:()=>s("/admin/events"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(M,{className:"w-4 h-4 text-pink-400"})," Events"]}),e.jsxs(r,{onClick:()=>s("/admin/gift-certificates"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(de,{className:"w-4 h-4 text-[#D4AF37]"})," Gift Certificates"]}),e.jsxs(r,{onClick:()=>s("/admin/pos"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(R,{className:"w-4 h-4 text-[#D4AF37]"})," Point of Sale"]}),e.jsxs(r,{onClick:()=>s("/admin/pos/reports"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(K,{className:"w-4 h-4 text-purple-400"})," POS Reports"]}),e.jsxs(r,{onClick:()=>s("/admin/employee-contacts"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(T,{className:"w-4 h-4 text-emerald-400"})," Employee Contacts"]}),e.jsxs(r,{onClick:()=>s("/admin/daily-tracker"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(R,{className:"w-4 h-4 text-emerald-400"})," Daily Tracker"]}),o&&e.jsxs(r,{onClick:()=>s("/admin/weekly-report"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(M,{className:"w-4 h-4 text-orange-400"})," Weekly Report"]}),o&&e.jsxs(r,{onClick:()=>s("/admin/payroll"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(fe,{className:"w-4 h-4 text-purple-400"})," Payroll"]}),o&&e.jsxs(r,{onClick:()=>s("/admin/monthly-report"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(K,{className:"w-4 h-4 text-cyan-400"})," Monthly/Yearly"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"bg-white/10"}),e.jsxs(r,{onClick:()=>s("/admin/applications"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(ye,{className:"w-4 h-4 text-purple-400"})," Job Applications"]}),e.jsxs(r,{onClick:()=>s("/admin/apprenticeship"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(ce,{className:"w-4 h-4 text-yellow-400"})," Apprenticeship"]}),e.jsx(q,{className:"bg-white/10"}),e.jsxs(r,{onClick:()=>s("/admin/promotions"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(me,{className:"w-4 h-4 text-cyan-400"})," Promotions"]}),e.jsxs(r,{onClick:()=>s("/admin/flash-gallery"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(he,{className:"w-4 h-4 text-purple-400"})," Flash Gallery"]}),e.jsxs(r,{onClick:()=>s("/admin/reviews"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(xe,{className:"w-4 h-4 text-yellow-400"})," Reviews"]}),e.jsxs(r,{onClick:()=>s("/admin/artists"),className:"flex items-center gap-2 cursor-pointer hover:bg-white/10",children:[e.jsx(I,{className:"w-4 h-4 text-orange-400"})," Artist Locations"]})]})]})]}),e.jsxs("button",{onClick:ae,className:"flex items-center gap-2 bg-red-500/20 hover:bg-red-500/30 text-red-400 px-3 py-2 rounded-lg text-sm font-medium transition-colors","data-testid":"button-logout",children:[e.jsx(je,{className:"w-4 h-4"})," Logout"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-6 bg-white/5 border border-white/10 rounded-xl p-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:U.map(t=>e.jsx("button",{onClick:()=>J(t.id),className:`px-4 py-2 rounded-lg text-sm font-bold transition-colors ${c===t.id?"bg-[#D4AF37] text-black":"bg-white/10 text-white hover:bg-white/20"}`,"data-testid":`button-location-${t.id}`,children:t.label},t.id))}),e.jsx("div",{className:"flex items-center gap-3 ml-auto",children:o&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer","data-testid":"toggle-show-deleted",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:t=>H(t.target.checked),className:"w-4 h-4 accent-[#D4AF37]"}),e.jsx("span",{className:"text-sm text-gray-400",children:"Show Deleted"})]}),e.jsxs("button",{onClick:()=>{w(!0),f(""),j("")},className:"flex items-center gap-2 bg-emerald-600 hover:bg-emerald-700 px-4 py-2 rounded-lg text-sm font-bold transition-colors","data-testid":"button-add-contact",children:[e.jsx(Ne,{className:"w-4 h-4"})," Add Contact"]})]})})]}),z&&o&&e.jsxs("div",{className:"mb-6 bg-[#1a1a1a] border border-white/10 rounded-xl p-4","data-testid":"form-add-contact",children:[e.jsx("div",{className:"text-sm font-bold text-[#D4AF37] mb-3",children:"ADD NEW CONTACT"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"text",placeholder:"Name",value:m,onChange:t=>f(t.target.value),className:"bg-black border border-white/20 rounded px-3 py-2 text-white text-sm focus:border-[#D4AF37] focu
1s:outline-none flex-1 min-w-[200px]","data-testid":"input-new-name"}),e.jsx("input",{type:"text",placeholder:"Phone Number",value:y,onChange:t=>j(t.target.value),className:"bg-black border border-white/20 rounded px-3 py-2 text-white text-sm focus:border-[#D4AF37] focus:outline-none flex-1 min-w-[150px]","data-testid":"input-new-phone"}),e.jsx("select",{value:A,onChange:t=>$(t.target.value),className:"bg-black border border-white/20 rounded px-3 py-2 text-white text-sm focus:border-[#D4AF37] focus:outline-none","data-testid":"select-new-location",children:C.map(t=>e.jsx("option",{value:t.id,children:t.label},t.id))}),e.jsxs("button",{onClick:Z,className:"flex items-center gap-1 bg-emerald-600 hover:bg-emerald-700 px-4 py-2 rounded-lg text-sm font-bold transition-colors","data-testid":"button-save-new",children:[e.jsx(L,{className:"w-4 h-4"})," Save"]}),e.jsxs("button",{onClick:()=>w(!1),className:"flex items-center gap-1 bg-white/10 hover:bg-white/20 px-4 py-2 rounded-lg text-sm font-bold transition-colors","data-testid":"button-cancel-new",children:[e.jsx(v,{className:"w-4 h-4"})," Cancel"]})]})]}),X?e.jsx("div",{className:"text-center py-12 text-gray-400",children:"Loading contacts..."}):h.length===0?e.jsx("div",{className:"text-center py-12 text-gray-400","data-testid":"text-no-contacts",children:"No contacts found for this location."}):e.jsx("div",{className:"bg-[#1a1a1a] border border-white/10 rounded-xl overflow-hidden","data-testid":"table-contacts",children:e.jsxs("div",{className:"grid grid-cols-[1fr_auto_auto] md:grid-cols-[1fr_180px_140px_auto] gap-0",children:[e.jsx("div",{className:"bg-white/5 px-4 py-3 text-xs font-bold text-gray-400 uppercase tracking-widest",children:"Name"}),e.jsx("div",{className:"bg-white/5 px-4 py-3 text-xs font-bold text-gray-400 uppercase tracking-widest",children:"Phone"}),e.jsx("div",{className:"bg-white/5 px-4 py-3 text-xs font-bold text-gray-400 uppercase tracking-widest hidden md:block",children:"Location"}),o&&e.jsx("div",{className:"bg-white/5 px-4 py-3 text-xs font-bold text-gray-400 uppercase tracking-widest text-right",children:"Actions"}),!o&&e.jsx("div",{className:"bg-white/5"}),h.map((t,a)=>e.jsx(O.Fragment,{children:Y===t.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`px-4 py-3 border-t border-white/5 ${a%2===0?"bg-white/[0.02]":""}`,children:e.jsx("input",{type:"text",value:b,onChange:i=>F(i.target.value),className:"bg-black border border-[#D4AF37]/50 rounded px-2 py-1 text-white text-sm focus:border-[#D4AF37] focus:outline-none w-full","data-testid":`input-edit-name-${t.id}`})}),e.jsx("div",{className:`px-4 py-3 border-t border-white/5 ${a%2===0?"bg-white/[0.02]":""}`,children:e.jsx("input",{type:"text",value:g,onChange:i=>D(i.target.value),className:"bg-black border border-[#D4AF37]/50 rounded px-2 py-1 text-white text-sm focus:border-[#D4AF37] focus:outline-none w-full","data-testid":`input-edit-phone-${t.id}`})}),e.jsx("div",{className:`px-4 py-3 border-t border-white/5 hidden md:block ${a%2===0?"bg-white/[0.02]":""}`,children:e.jsx("select",{value:E,onChange:i=>S(i.target.value),className:"bg-black border border-[#D4AF37]/50 rounded px-2 py-1 text-white text-sm focus:border-[#D4AF37] focus:outline-none w-full","data-testid":`select-edit-location-${t.id}`,children:C.map(i=>e.jsx("option",{value:i.id,children:i.label},i.id))})}),e.jsxs("div",{className:`px-4 py-3 border-t border-white/5 flex items-center justify-end gap-2 ${a%2===0?"bg-white/[0.02]":""}`,children:[e.jsx("button",{onClick:()=>V(t.id),className:"p-1.5 bg-emerald-600 hover:bg-emerald-700 rounded transition-colors","data-testid":`button-save-edit-${t.id}`,children:e.jsx(L,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>u(null),className:"p-1.5 bg-white/10 hover:bg-white/20 rounded transition-colors","data-testid":`button-cancel-edit-${t.id}`,children:e.jsx(v,{className:"w-3.5 h-3.5"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`px-4 py-3 border-t border-white/5 font-medium ${a%2===0?"bg-white/[0.02]":""}`,"data-testid":`text-contact-name-${t.id}`,children:[t.name,t.locationId==="both"&&e.jsx("span",{className:"ml-2 text-[10px] bg-[#D4AF37]/20 text-[#D4AF37] px-1.5 py-0.5 rounded font-bold",children:"BOTH"})]}),e.jsx("div",{className:`px-4 py-3 border-t border-white/5 ${a%2===0?"bg-white/[0.02]":""}`,children:e.jsx("a",{href:`tel:${t.phone}`,className:"text-[#D4AF37] hover:underline font-medium","data-testid":`link-phone-${t.id}`,children:t.phone})}),e.jsx("div",{className:`px-4 py-3 border-t border-white/5 text-sm text-gray-400 hidden md:block ${a%2===0?"bg-white/[0.02]":""}`,children:C.find(i=>i.id===t.locationId)?.label||t.locationId}),e.jsx("div",{className:`px-4 py-3 border-t border-white/5 flex items-center justify-end gap-2 ${a%2===0?"bg-white/[0.02]":""}`,children:o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>re(t),className:"p-1.5 bg-[#D4AF37]/20 hover:bg-[#D4AF37]/30 text-[#D4AF37] rounded transition-colors","data-testid":`button-edit-${t.id}`,children:e.jsx(ve,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>ee(t.id,t.name),className:"p-1.5 bg-red-500/20 hover:bg-red-500/30 text-red-400 rounded transition-colors","data-testid":`button-delete-${t.id}`,children:e.jsx(Q,{className:"w-3.5 h-3.5"})})]})})]})},t.id))]})}),p&&o&&N.length>0&&e.jsxs("div",{className:"mt-8","data-testid":"section-deleted-contacts",children:[e.jsxs("h2",{className:"text-lg font-bold text-red-400 mb-4",children:[e.jsx(Q,{className:"w-5 h-5 inline mr-2"}),"Deleted Contacts (",N.length,")"]}),e.jsx("div",{className:"bg-[#1a1a1a] border border-red-500/20 rounded-xl overflow-hidden",children:e.jsxs("div",{className:"grid grid-cols-[1fr_200px_auto] gap-0",children:[e.jsx("div",{className:"bg-red-500/5 px-4 py-3 text-xs font-bold text-gray-400 uppercase tracking-widest",children:"Name"}),e.jsx("div",{className:"bg-red-500/5 px-4 py-3 text-xs font-bold text-gray-400 uppercase tracking-widest",children:"Phone"}),e.jsx("div",{className:"bg-red-500/5 px-4 py-3 text-xs font-bold text-gray-400 uppercase tracking-widest text-right",children:"Actions"}),N.map((t,a)=>e.jsxs(O.Fragment,{children:[e.jsx("div",{className:`px-4 py-3 border-t border-white/5 text-gray-500 ${a%2===0?"bg-white/[0.02]":""}`,"data-testid":`text-deleted-name-${t.id}`,children:t.name}),e.jsx("div",{className:`px-4 py-3 border-t border-white/5 text-gray-500 ${a%2===0?"bg-white/[0.02]":""}`,children:t.phone}),e.jsxs("div",{className:`px-4 py-3 border-t border-white/5 flex items-center justify-end gap-2 ${a%2===0?"bg-white/[0.02]":""}`,children:[e.jsxs("button",{onClick:()=>te(t.id,t.name),className:"flex items-center gap-1 bg-emerald-600/20 hover:bg-emerald-600/30 text-emerald-400 px-3 py-1.5 rounded text-xs font-bold transition-colors","data-testid":`button-restore-${t.id}`,children:[e.jsx(Ce,{className:"w-3.5 h-3.5"})," Restore"]}),e.jsxs("button",{onClick:()=>se(t.id,t.name),className:"flex items-center gap-1 bg-red-600/20 hover:bg-red-600/30 text-red-400 px-3 py-1.5 rounded text-xs font-bold transition-colors","data-testid":`button-permanent-delete-${t.id}`,children:[e.jsx(v,{className:"w-3.5 h-3.5"})," Delete Forever"]})]})]},t.id))]})})]}),e.jsxs("div",{className:"mt-6 text-center text-xs text-gray-500","data-testid":"text-contact-count",children:[h.length," contact",h.length!==1?"s":""," • ",U.find(t=>
1t.id===c)?.label]})]})}):e.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center text-white",children:"Loading..."})}export{Ue as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.