PageSourceSearch

https://remenu-staging.fly.dev/assets/DeleteEntityModal-CGP7yGbe.js

js remenu-staging.fly.dev collected 2026-10-03 08:27:57 UTC 5,489 bytes, 1 lines download raw bytes

1import{j as t}from"./jsx-runtime-D8ipelNA.js";import{z as s}from"./index-DXqQCM1T.js";import{u as j}from"./useModal-CJOBTagi.js";import{t as y}from"./trpc.clientsetup-DtHqWGLU.js";import{G as N,P as f}from"./index-B_LZ9kqH.js";import{z as v}from"./index-CuMLbxmh.js";import{L as P,F as E}from"./components-DSvduGxv.js";import{u as w}from"./useInvalidateDashboard-D6VgzVGH.js";import{u as M,e as I}from"./EntityType-CeFvHLJa.js";import{C as p}from"./custom-toaster-mxQcZiZJ.js";import{H as g}from"./HiddenInput-CPBdodrp.js";import{a as D,u as A}from"./index-DexNTU48.js";function R(e){return N({tag:"svg",attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"},child:[]}]})(e)}function q(e){return N({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M290.7 57.4L57.4 290.7c-25 25-25 65.5 0 90.5l80 80c12 12 28.3 18.7 45.3 18.7H288h9.4H512c17.7 0 32-14.3 32-32s-14.3-32-32-32H387.9L518.6 285.3c25-25 25-65.5 0-90.5L381.3 57.4c-25-25-65.5-25-90.5 0zM297.4 416H288l-105.4 0-80-80L227.3 211.3 364.7 348.7 297.4 416z"},child:[]}]})(e)}const C=e=>v(e).with("RESTAURANT_SLOT",()=>{throw new Error("RESTAURANT_SLOT does not have a valid route")}).with("RESTAURANT",()=>"restaurants").with("MENU",()=>"menus").with("SECTION",()=>"sections").with("SECTION_GROUP",()=>"section-groups").with("ITEM",()=>"items").exhaustive(),L=({item:e})=>{const{section:n}=e,{sectionGroup:l}=n,{menu:o}=l,{restaurant:d}=o,i=[d,o,l,n,e];return t.jsx("div",{className:"photo-item-path-display",children:i.map((r,a)=>t.jsxs(t.Fragment,{children:[t.jsx(P,{to:`/dashboard/${C(r.entityType)}/${r.id}`,className:"photo-item-path-display-link",children:r.name},r.id),a<i.length-1&&t.jsx(R,{size:6})]}))})},F=()=>{const e=w();return y.deletePhoto.useMutation({onSuccess:()=>{e()}})},J=s.object({modalType:s.literal("deletePhoto"),itemPhotoId:s.string()}),K=({itemPhotoId:e})=>{var r;const{closeModal:n}=j(),l=F(),{data:o,isLoading:d}=y.getPhotoRelatedEntities.useQuery({itemPhotoId:e}),i=((o==null?void 0:o.items.length)??0)>0;return t.jsxs(E,{action:"/api/delete-entity",method:"delete",className:"modal-form delete-photo-modal",onSubmit:async a=>{a.preventDefault(),l.mutateAsync({itemPhotoId:e}).then(()=>{n()})},children:[t.jsx("h1",{className:"modal-title",style:{textAlign:i?"center":"left"},children:"Delete this photo?"}),i&&t.jsxs("div",{className:"delete-photo-warning-box",children:[t.jsxs("div",{className:"delete-photo-warning-box-title",children:[t.jsx(f,{color:"red"}),"WARNING",t.jsx(f,{color:"red"})]}),t.jsx("p",{children:"Some entities depend on this photo, if you delete it, we will remove the photo from those entities. Note, this may affect your menu styling."}),t.jsx("h5",{children:"You are using this photo in the following items"}),(r=o==null?void 0:o.items)==null?void 0:r.map(a=>t.jsx(L,{item:a},a.id))]}),t.jsx("p",{style:{textAlign:i?"center":"left"},children:"If you delete this, you can't recover it."}),t.jsxs("div",{className:"modal-btn-wrap",style:{justifyContent:i?"center":"flex-start"},children:[t.jsx("div",{children:t.jsx("button",{type:"submit",className:"modal-btn delete-modal-btn",autoFocus:!0,disabled:l.isPending,children:"Delete"})}),t.jsx("div",{className:"modal-bottom",children:t.jsx("button",{onClick:a=>{a.preventDefault(),n()},className:"modal-btn cancel-modal-btn cta",disabled:d,children:"Cancel"})})]})]})},T=(e,n)=>{try{return e.parse(n)}catch{return!1}},O=()=>y.deleteEntity.useMutation({}),U=({entityId:e,entityName:n,entityType:l})=>{const{closeModal:o}=j(),d=O(),i=D(),r=M(),a=A(),S=w();return t.jsxs(E,{action:"/api/delete-entity",method:"delete",className:"modal-form",onSubmit:async m=>{m.preventDefault();const x=new FormData(m.currentTarget),h=T(s.string(),x.get("entityId")),b=T(I,x.get("entityType"));if(!h){p.error("Must Provide Entity Id");return}if(!b){p.error("Must Provide Entity Type");return}d.mutateAsync({entityId:h,entityType:b},{onSettled:()=>{S()},onSuccess:()=>
1{if(o(),i.pathname.includes(h)){const u=v(r.data).with({entityType:"ITEM"},c=>`/dashboard/sections/${c.item.sectionId}`).with({entityType:"SECTION"},c=>`/dashboard/section-groups/${c.section.sectionGroupId}`).with({entityType:"SECTION_GROUP"},c=>`/dashboard/menus/${c.sectionGroup.menuId}`).with({entityType:"RESTAURANT"},()=>"/dashboard").with({entityType:"RESTAURANT_SLOT"},()=>"/dashboard").otherwise(()=>"/dashboard");a(u)}}}).catch(u=>{p.error("Something went Wrong"),console.error(u.message)})},children:[t.jsxs("h1",{className:"modal-title",children:["Delete ",n,"?"]}),t.jsxs("p",{children:["If you delete this ",l.toLowerCase(),", you can't recover it."]}),t.jsx(g,{name:"entityType",defaultValue:l}),t.jsx(g,{name:"entityId",defaultValue:e}),t.jsxs("div",{className:"modal-btn-wrap",children:[t.jsx("div",{children:t.jsx("button",{type:"submit",className:"modal-btn delete-modal-btn",autoFocus:!0,disabled:d.isPending,children:"Delete"})}),t.jsx("div",{className:"modal-bottom",children:t.jsx("button",{onClick:m=>{m.preventDefault(),o()},className:"modal-btn cancel-modal-btn cta",children:"Cancel"})})]})]})},X=s.object({modalType:s.literal("deleteEntity"),entityId:s.string(),parentEntityId:s.string().optional(),entityName:s.string(),entityType:I}),tt=s.object({modalType:s.literal("uploadImage")}),et=e=>t.jsx(U,{...e});export{et as D,q as F,X as a,K as b,T as c,J as d,tt as u};

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.