PageSourceSearch

https://www.tillsync.ai/assets/FoodPricingPage-BAyHIjS0.js

js tillsync.ai collected 2026-10-05 15:25:52 UTC 16,894 bytes, 1 lines download raw bytes

1import{b as A,u as x,a as F,j as e}from"./data-vendor-C91Wc5Q_.js";import{r as P}from"./react-vendor-PqhhQyRC.js";import{c as I,b as d,a as c,u as M,P as T}from"./AdminPage-DEF3s-lo.js";import{S as D,M as K}from"./MobileNav-C-rq-7OF.js";import{u as Q,f as R}from"./index-Bxjb1Xws.js";import{D as H,m as C,R as z,y as h,a0 as $,a1 as p,l as y,a2 as E,H as L,a3 as u}from"./ui-vendor-C5EKwEwO.js";import"./charts-echarts-uyc5TIk9.js";import"./supabase-vendor-CVfkMyKi.js";const l=s=>{if(!s)return"";const r=Object.entries(s).filter(([,i])=>i!==void 0);return r.length===0?"":"?"+new URLSearchParams(r.map(([i,n])=>[i,String(n)])).toString()},o={getDashboard:async()=>d("/food-pricing/dashboard"),getSuppliers:async()=>d("/food-pricing/suppliers"),createSupplier:async s=>c("/food-pricing/suppliers",s),getIngredients:async s=>{const r=l({category:s});return d(`/food-pricing/ingredients${r}`)},createIngredient:async s=>c("/food-pricing/ingredients",s),getIngredientPriceHistory:async(s,r=365)=>{const i=l({days:r});return d(`/food-pricing/ingredients/${s}/price-history${i}`)},getPurchases:async s=>{const r=l(s);return d(`/food-pricing/purchases${r}`)},createPurchase:async s=>c("/food-pricing/purchases",s),bulkImportPurchases:async s=>c("/food-pricing/purchases/bulk",s),getMenuItems:async s=>{const r=l({category:s});return d(`/food-pricing/menu-items${r}`)},createMenuItem:async s=>c("/food-pricing/menu-items",s),addMenuIngredient:async(s,r)=>c(`/food-pricing/menu-items/${s}/ingredients`,r),getMenuItemCost:async s=>d(`/food-pricing/menu-items/${s}/cost`),getPredictions:async(s,r=90)=>{const i=l({days:r});return d(`/food-pricing/predictions/${s}${i}`)},generatePredictions:async s=>c(`/food-pricing/predictions/generate/${s}`),getAlerts:async(s="open")=>{const r=l({status:s});return d(`/food-pricing/alerts${r}`)},acknowledgeAlert:async s=>I(`/food-pricing/alerts/${s}/acknowledge`),resolveAlert:async s=>I(`/food-pricing/alerts/${s}/resolve`)};function Y(){const s=A(),r=M(),{sidebarMarginClass:i}=Q(),[n,q]=P.useState("overview"),{data:a,isLoading:j}=x({queryKey:["food-pricing-dashboard"],queryFn:()=>o.getDashboard(),staleTime:6e4}),{data:N,isLoading:b}=x({queryKey:["food-pricing-ingredients"],queryFn:()=>o.getIngredients(),staleTime:6e4}),{data:f,isLoading:v}=x({queryKey:["food-pricing-menu-items"],queryFn:()=>o.getMenuItems(),staleTime:6e4}),{data:k,isLoading:S}=x({queryKey:["food-pricing-alerts"],queryFn:()=>o.getAlerts("open"),staleTime:3e4}),w=F({mutationFn:t=>o.acknowledgeAlert(t),onSuccess:()=>{s.invalidateQueries({queryKey:["food-pricing-alerts"]}),s.invalidateQueries({queryKey:["food-pricing-dashboard"]})}}),g=P.useMemo(()=>a?.ingredient_count_by_category?Object.entries(a.ingredient_count_by_category).map(([t,m])=>({category:t,count:m})):[],[a?.ingredient_count_by_category]),_=j||b||v;return e.jsxs("div",{className:"flex h-screen bg-gray-50 dark:bg-gray-900 overflow-hidden",children:[e.jsx(D,{onLogout:r}),e.jsxs(T,{className:`flex-1 flex flex-col ${i} pb-20 md:pb-0 overflow-x-hidden transition-all duration-300`,children:[e.jsx("header",{className:"bg-white dark:bg-gray-800 border-b border-slate-200 dark:border-gray-700 z-10 shadow-sm",children:e.jsx("div",{className:"px-4 sm:px-6 lg:px-8 py-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-3",children:[e.jsx(H,{className:"w-7 h-7 text-green-600 dark:text-green-400"}),e.jsx("span",{children:"Food Pricing & Costing"})]}),e.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:"Track ingredient costs, predict prices, and optimize menu pricing (Target: 25-28% food cost)"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(C.button,{onClick:()=>{s.invalidateQueries({queryKey:["food-pricing-dashboard"]}),s.invalidateQueries({queryKey:["food-pricing-ingredients"]}),s.invalidateQueries({queryKey:["food-pricing-menu-items"]})},disabled:_,whileHover:{scale:1.05},whileTap:{scale:.95},className:"flex items-center gap-2 px-4 py-2 bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-700 dark:text-white rounded-lg transition-colors",children:[e.jsx(z,{className:`w-4 h-4 ${_?"animate-spin":""}`}),e.jsx("span",{className:"text-sm font-medium hidden md:inline",children:"Refresh"})]})})]})})}),e.jsx("main",{className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"px-4 sm:px-6 lg:px-8 py-8 space-y-6",children:[e.jsxs(C.div,{variants:R,initial:"hidden",animate:"visible",className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Total Ingredients"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white mt-1",children:a?.total_ingredients||0})]}),e.jsx(h,{className:"w-10 h-10 text-indigo-600 dark:text-indigo-400"})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Menu Items"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 dark:text-white mt-1",children:a?.total_menu_items||0})]}
1),e.jsx($,{className:"w-10 h-10 text-purple-600 dark:text-purple-400"})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"30-Day Purchases"}),e.jsxs("p",{className:"text-2xl font-bold text-green-600 dark:text-green-400 mt-1",children:["$",(a?.total_purchases_30d||0).toLocaleString()]})]}),e.jsx(p,{className:"w-10 h-10 text-green-600 dark:text-green-400"})]})}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow p-6 border border-orange-200 dark:border-orange-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Price Alerts"}),e.jsx("p",{className:"text-2xl font-bold text-orange-600 dark:text-orange-400 mt-1",children:a?.open_alerts||0})]}),e.jsx(y,{className:"w-10 h-10 text-orange-600 dark:text-orange-400"})]})})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:e.jsx("nav",{className:"flex space-x-1 p-2 overflow-x-auto",children:[{id:"overview",label:"Overview",icon:E},{id:"ingredients",label:"Ingredients",icon:h},{id:"menu",label:"Menu Costing",icon:$},{id:"purchases",label:"Purchases",icon:p},{id:"alerts",label:"Alerts",icon:L}].map(t=>e.jsxs("button",{onClick:()=>q(t.id),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg transition-colors whitespace-nowrap ${n===t.id?"bg-green-100 dark:bg-green-900 text-green-700 dark:text-green-300":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`,children:[e.jsx(t.icon,{className:"w-4 h-4"}),t.label]},t.id))})}),e.jsxs("div",{className:"p-6",children:[n==="overview"&&e.jsxs("div",{className:"space-y-6",children:[a?.items_needing_price_adjustment&&a.items_needing_price_adjustment.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4 flex items-center gap-2",children:[e.jsx(y,{className:"w-5 h-5 text-orange-500"}),"Menu Items Needing Price Adjustment"]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:[e.jsx("th",{className:"px-4 py-3",children:"Item"}),e.jsx("th",{className:"px-4 py-3",children:"Plate Cost"}),e.jsx("th",{className:"px-4 py-3",children:"Current Price"}),e.jsx("th",{className:"px-4 py-3",children:"Food Cost %"}),e.jsx("th",{className:"px-4 py-3",children:"Target %"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:a.items_needing_price_adjustment.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-gray-900 dark:text-white",children:t.name}),e.jsxs("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:["$",t.plate_cost.toFixed(2)]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:["$",t.current_price.toFixed(2)]}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:"text-red-600 dark:text-red-400 font-semibold",children:[t.food_cost_percent.toFixed(1),"%"]})}),e.jsxs("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:[t.target_percent,"%"]})]},t.id))})]})})]}),g.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Ingredients by Category"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-4",children:g.map(({category:t,count:m})=>e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 capitalize",children:t.replace("_"," ")}),e.jsx("p",{className:"text-xl font-bold text-gray-900 dark:text-white",children:m})]},t))})]}),!j&&!a?.items_needing_price_adjustment?.length&&g.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(h,{className:"w-16 h-16 text-gray-300 dark:text-gray-600 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Get Started with Food Pricing"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:"Add suppliers, ingredients, and menu items to start tracking your food costs."})]})]}),n==="ingredients"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Ingredient List"}),e.jsxs("button",{className:"flex items-center gap-2 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium",children:[e.jsx(u,{className:"w-4 h-4"}),"Add Ingredient"]})]}),b?e.jsx("div",{className:"text-center py-8 text-gray-500",children:"Loading ingredients..."}):N?.ingredients?.length?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:[e.jsx("th",{className:"px-4 py-3",children:"Name"}),e.jsx("th",{className:"px-4 py-3",children:"Category"}),e.jsx("th",{className:"px-4 py-3",children:"Unit"}),e.jsx("th",{className:"px-4 py-3",children:"Par Level"}),e.jsx("th",{className:"px-4 py-3",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:N.ingredients.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-gray-900 dark:text-white",children:t.name}),e.jsx("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300 capitalize",children:t.category.replace("_"," ")}),e.jsx("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:t.unit}),e.jsx("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:t.par_level||"-"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{className:"text-indigo-600 hover:text-indigo-800 dark:text-indigo-400 text-sm",children:"View History"})})]},t.id))})]})}):e.jsx("div",{className:"text-center py-8 text-gray-500",children:"No ingredients added yet"})]}),n==="menu"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Menu Items & Costing"}),e.jsxs("button",{className:"flex items-center gap-2 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium",children:[e.jsx(u,{className:"w-4 h-4"}),"Add Menu Item"]})]}),v?e.jsx("div",{className:"text-center py-8 text-gray-500",children:"Loading menu items..."}):f?.menu_items?.length?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:[e.jsx("th",{className:"px-4 py-3",children:"Item"}),e.jsx("th",{className:"px-4 py-3",children:"Category"}),e.jsx("th",{className:"px-4 py-3",children:"Plate Cost"}),e.jsx("th",{className:"px-4 py-3",children:"Menu Price"}),e.jsx("th",{className:"px-4 py-3",children:"Food Cost %"}),e.jsx("th",{className:"px-4 py-3",children:"Target %"}),e.jsx("th",{className:"px-4 py-3",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:f.menu_items.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-gray-900 dark:text-white",children:t.name}),e.jsx("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:t.category||"-"}),e.jsxs("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:["$",(t.plate_cost||0).toFixed(2)]}),e.jsxs("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:["$",(t.current_price||0).toFixed(2)]}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`font-semibold ${(t.food_cost_percent||0)>t.target_food_cost_percent?"text-red-600 dark:text-red-400":"text-green-600 dark:text-green-400"}`,children:[(t.food_cost_percent||0).toFixed(1),"%"]})}),e.jsxs("td",{className:"px-4 py-3 text-gray-600 dark:text-gray-300",children:[t.target_food_cost_percent,"%"]}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{className:"text-indigo-600 hover:text-indigo-800 dark:text-indigo-400 text-sm",children:"Edit Recipe"})})]},t.id))})]})}):e.jsx("div",{className:"text-center py-8 text-gray-500",children:"No menu items added yet"})]}),n==="purchases"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Purchase History"}),e.jsxs("button",{className:"flex items-center gap-2 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium",children:[e.jsx(u,{className:"w-4 h-4"}),"Add Purchase"]})]}),e.jsxs("div",{className:"text-center py-8 text-gray-500",children:[e.jsx(p,{className:"w-12 h-12 mx-auto mb-4 text-gray-300"}),e.jsx("p",{children:"Import your purchase history from Sysco, US Foods, or Restaurant Depot"}),e.jsx("button",{className:"mt-4 px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-sm font-medium",children:"Import CSV"})]})]}),n==="alerts"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Price Alerts"}),S?e.jsx("div",{className:"text-center py-8 text-gray-500",children:"Loading alerts..."}):k?.alerts?.length?e.jsx("div",{className:"space-y-3",children:k.alerts.map(t=>e.jsxs("div",{className:"flex items-start justify-between p-4 bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-700 rounded-lg",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(y,{className:"w-5 h-5 text-orange-500 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:t.message}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:[new Date(t.created_at).toLocaleDateString()," -"," ",t.alert_type]})]})]}),e.jsx("button",{onClick:()=>w.mutate(t.id),disabled:w.isPending,className:"px-3 py-1 bg-orange-600 hover:bg-orange-700 text-white rounded text-sm",children:"Acknowledge"})]},t.id))}):e.jsxs("div",{className:"text-center py-8 text-gray-500",children:[e.jsx(L,{className:"w-12 h-12 mx-auto mb-4 text-gray-300"}),e.jsx("p",{children:"No open alerts. Price spikes will appear here."})]})]})]})]})]})})]}),e.jsx(K,{})]})}
1export{Y as FoodPricingPage,Y 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.