PageSourceSearch

https://driftgolf-qa.netlify.app/assets/FoodbevCategoriesPage-9e289a38.js

js driftgolf-qa.netlify.app collected 2026-10-03 10:40:19 UTC 5,964 bytes, 46 lines download raw bytes

1import{r as f,d,a as b,j as e,B as _}from"./index-4ce00ee7.js";import{g as u}from"./index-7de85521.js";import{S as l}from"./sweetalert2.all-2c1f30c7.js";import{d as Q}from"./index-e629a575.js";import{t as C}from"./index-51f3a61d.js";import{t as U}from"./trash-03bc5dcd.js";import{r as k}from"./RouteHandler-f8cc45bb.js";import{n as q,P as G,c as v}from"./not-found-a10d56df.js";import{u as F}from"./GolfClubHooks-443ca383.js";import{t as y}from"./formatters-cb9ccf71.js";import{F as Y}from"./FoodbevCategoryForm-e9d58680.js";const H=u`
2  mutation DeleteFoodbevCategoryMutation($id: String!) {
3    deleteFoodbevCategory(id: $id) {
4      id
5    }
6  }
7`,L=u`
8  mutation CreateFoodbevCategoryMutation($input: CreateFoodbevCategoryInput!) {
9    createFoodbevCategory(input: $input) {
10      id
11    }
12  }
13`,V=u`
14  mutation UpdateFoodbevCategoryMutation(
15    $id: String!
16    $input: UpdateFoodbevCategoryInput!
17  ) {
18    updateFoodbevCategory(id: $id, input: $input) {
19      id
20      golfClubId
21      name
22      description
23      active
24      createdAt
25      updatedAt
26    }
27  }
28`,w=({foodbevCategories:t,count:a,isEmpty:o})=>{const m=F(),x=Q.useForm();let g=1,h=10;const[j,n]=f.useState(""),[p,i]=f.useState(""),[I]=d.useMutation(H,{onCompleted:()=>{l.fire({title:"Deleted!",text:"Category has been deleted successfully",icon:"success",timer:5e3})},onError:s=>{C.toast.error(s.message)},refetchQueries:[{query:c,variables:{golfClubId:m,itemsPerPage:h,page:g}}],awaitRefetchQueries:!0}),[E,{loading:N,error:$}]=d.useMutation(L,{onCompleted:()=>{l.fire({title:"Created!",text:"Category has been created successfully",icon:"success",timer:5e3}),n(""),x.reset()},onError:s=>{C.toast.error(s.message)},refetchQueries:[{query:c,variables:{golfClubId:m,itemsPerPage:h,page:g}}],awaitRefetchQueries:!0}),[S]=d.useMutation(V,{onCompleted:()=>{l.fire({title:"Updated!",text:"Category has been updated successfully",icon:"success",timer:5e3}),n(""),i("")},onError:s=>{C.toast.error(s.message)},refetchQueries:[{query:c,variables:{golfClubId:m,itemsPerPage:h,page:g}}],awaitRefetchQueries:!0}),D=s=>{E({variables:{input:s}})},O=(s,r)=>{S({variables:{id:r,input:s}})},T=({id:s,name:r})=>{l.fire({title:"Delete Category",html:"Do you want to delete <b>"+r+"</b>?",icon:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Yes",reverseButtons:!0}).then(R=>{R.isConfirmed&&I({variables:{id:s}})})},A=s=>{x.reset(),i(s),n(!0)},B=()=>{n(""),i("")},M=s=>A(s),P=[{label:"Home",path:"/"},{label:"Food & Beverage",path:b.routes.foodbevOrders()},{label:"Categories",active:!0}];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl sm:text-2xl lg:text-4xl font-bold",children:"Food & Beverage"}),e.jsx(_,{crumbs:P})]}),e.jsx("button",{onClick:()=>n(!j),className:"bg-primary-500 hover:bg-orange-600 text-white text-xs sm:text-base px-3 py-2 rounded-lg h-fit whitespace-nowrap",children:"Create New"})]}),e.jsx("div",{className:"custom-table",children:e.jsxs("table",{className:"rw-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{colSpan:3,children:"Description"})]})}),e.jsxs("tbody",{children:[t.map(s=>e.jsxs("tr",{onClick:()=>M(s),className:"cursor-pointer hovered-row",children:[e.jsx("td",{children:y(s.name)}),e.jsx("td",{children:y(s.description)}),e.jsx("td",{children:e.jsx("nav",{className:"rw-table-actions space-x-4 relative",children:e.jsx("button",{onClick:r=>{r.stopPropagation(),k(b.routes.foodbevItems({categoryId:s.id,categoryName:s.name}))},title:"Show Items",className:"text-xs border text-white rounded-lg px-4 py-1 bg-orange-400 text-orange-500 hover:text-white hover:bg-orange-700 transition-all duration-150",children:"Items"})})}),e.jsx("td",{children:e.jsx("nav",{className:"rw-table-actions space-x-4 relative",children:e.jsx("button",{className:"cursor-pointer",type:"button",onClick:r=>{r.stopPropagation(),T(s)},children:e.jsx("img",{src:U,alt:"delete icon"})})})})]},s.id)),o||(t==null?void 0:t.length)<1&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsx("img",{src:q,alt:"not found",width:500,className:"mx-auto"})})}),e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsx(G,{count:a,length:t==null?void 0:t.length,route:b.routes.foodbevCategories})})})]})]})}),e.jsx("div",{id:"modal",className:`${j!==""?"":"hidden"} fixed inset-0 bg-gray-900 bg-opacity-50 flex items-center justify-center z-[111] backdrop-blur-lg`,children:e.jsxs("div",{children:[e.jsxs("h2",{className:"text-center text-3xl font-bold mb-8",children:[p?"Edit":"Create"," Category"]}),e.jsx("div",{className:"bg-white p-12 rounded-lg w-[444px]",children:e.jsx(Y,{onSave:p?O:D,modalHandler:B,foodbevCategory:p,setCategoryData:i,formMethods:x,loading:N,error:$})})]})})]})},c=u`
29  query FindFoodbevCategories($golfClubId: String! $page: Int! $itemsPerPage: Int!) {
30    foodbevCategoriesPage(golfClubId: $golfClubId page: $page itemsPerPage: $itemsPerPage) {
31      foodbevCategories {
32        id
33        golfClubId
34        name
35        description
36        active
37        createdAt
38        updatedAt
39        GolfClub {
40          name
41        }
42      }
43      count
44    }
45  }
46`,z=({page:t,golfClubId:a,itemsPerPage:o})=>(t=t?parseInt(t,10):v.page,o=o?parseInt(o,10):v.itemsPerPage,{variables:{golfClubId:a,page:t,itemsPerPage:o}}),J=()=>e.jsx("div",{children:"Loading..."}),K=({foodbevCategoriesPage:t})=>e.jsx(w,{foodbevCategories:t.foodbevCategories}),W=({error:t})=>e.jsx("div",{className:"rw-cell-error",children:t==null?void 0:t.message}),X=({foodbevCategoriesPage:t})=>e.jsx(w,{foodbevCategories:t.foodbevCategories,count:t.count}
46),Z=d.createCell({QUERY:c,beforeQuery:z,Loading:J,Empty:K,Failure:W,Success:X,displayName:"FoodbevCategoriesCell"}),ue=({page:t=1,itemsPerPage:a=10})=>{const o=F();return e.jsx(Z,{golfClubId:o,page:t,itemsPerPage:a})};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.