PageSourceSearch

https://ontariocanna.ca/assets/ManageDispensaries-BoQ3dZKp.js

js ontariocanna.ca collected 2026-10-08 06:16:31 UTC 15,150 bytes, 13 lines download raw bytes

1import{c as A,B as D,r as f,j as e,X as E,f as b,k as q,L as P}from"./index-BseVR5nP.js";import{u as C}from"./useMutation-CyzVcz6f.js";import{T as F}from"./ThinContentWarning-DZikdwzs.js";import{P as T}from"./plus-CcJC24g_.js";import{E as M}from"./eye-Cqg7y7ZG.js";import{E as z}from"./eye-off-CkT--aNt.js";import{E as B}from"./external-link-BjSbGs-1.js";import{P as L}from"./pencil-DaSVN1o3.js";import{T as I}from"./trash-2-CzHXz3av.js";import"./triangle-alert-C74HHf0X.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Q=[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],S=A("SquareCheckBig",Q);/**
7 * @license lucide-react v0.475.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const K=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],_=A("Square",K),R=["Indica","Sativa","Hybrid","Edibles","Concentrates","CBD","Topicals","Accessories"];function U({dispensary:r,onClose:i}){const u=D(),l=!r?.id,[s,m]=f.useState({name:r?.name||"",slug:r?.slug||"",city:r?.city||"",province:r?.province||"Ontario",address:r?.address||"",phone:r?.phone||"",website:r?.website||"",hours:r?.hours||"",description:r?.description||"",photos:r?.photos?.join(`
12`)||"",menu_categories:r?.menu_categories||[],featured:r?.featured||!1,status:r?.status||"draft",index_page:r?.index_page!==!1,meta_title:r?.meta_title||"",meta_description:r?.meta_description||""}),d=C({mutationFn:t=>l?b.entities.Dispensary.create(t):b.entities.Dispensary.update(r.id,t),onSuccess:()=>{u.invalidateQueries({queryKey:["dispensaries"]}),i()}}),c=t=>{t.preventDefault(),d.mutate({...s,photos:s.photos.split(`
13`).map(o=>o.trim()).filter(Boolean)})},n=(t,o)=>m(j=>({...j,[t]:o})),y=t=>n("menu_categories",s.menu_categories.includes(t)?s.menu_categories.filter(o=>o!==t):[...s.menu_categories,t]);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70",children:e.jsxs("div",{className:"bg-card border border-border rounded-2xl w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"sticky top-0 bg-card border-b border-border px-6 py-4 flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-black text-foreground",children:l?"Add Dispensary":"Edit Dispensary"}),e.jsx("button",{onClick:i,className:"text-muted-foreground hover:text-foreground",children:e.jsx(E,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:c,className:"p-6 space-y-5",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(h,{label:"Name *",value:s.name,onChange:t=>{n("name",t),l&&n("slug",t.toLowerCase().replace(/[^a-z0-9]+/g,"-"))}}),e.jsx(h,{label:"URL Slug *",value:s.slug,onChange:t=>n("slug",t)}),e.jsx(h,{label:"City *",value:s.city,onChange:t=>n("city",t)}),e.jsx(h,{label:"Phone",value:s.phone,onChange:t=>n("phone",t)}),e.jsx(h,{label:"Address",value:s.address,onChange:t=>n("address",t),className:"sm:col-span-2"}),e.jsx(h,{label:"Website",value:s.website,onChange:t=>n("website",t),className:"sm:col-span-2"}),e.jsx(w,{label:"Hours",value:s.hours,onChange:t=>n("hours",t),rows:2}),e.jsx(w,{label:"Description",value:s.description,onChange:t=>n("description",t),rows:3,className:"sm:col-span-2"}),e.jsx(w,{label:"Photo URLs (one per line)",value:s.photos,onChange:t=>n("photos",t),rows:3,className:"sm:col-span-2"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground mb-2 block",children:"Menu Categories"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:R.map(t=>e.jsx("button",{type:"button",onClick:()=>y(t),className:`text-xs px-3 py-1.5 rounded-full border transition-colors ${s.menu_categories.includes(t)?"bg-primary/10 border-primary/40 text-primary":"border-border text-muted-foreground hover:border-primary/30"}`,children:t},t))})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4 border-t border-border pt-4",children:[e.jsx("h3",{className:"text-xs font-bold text-muted-foreground uppercase tracking-wider sm:col-span-2",children:"SEO + Publishing"}),e.jsx(h,{label:"Meta Title",value:s.meta_title,onChange:t=>n("meta_title",t)}),e.jsx(h,{label:"Meta Description",value:s.meta_description,onChange:t=>n("meta_description",t)}),e.jsxs("div",{className:"flex items-center gap-4 sm:col-span-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.index_page,onChange:t=>n("index_page",t.target.checked),className:"rounded"}),e.jsx("span",{className:"text-foreground",children:"Index in search engines"})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.featured,onChange:t=>n("featured",t.target.checked),className:"rounded"}),e.jsx("span",{className:"text-foreground",children:"Featured listing"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground mb-1.5 block",children:"Status"}),e.jsxs("select",{value:s.status,onChange:t=>n("status",t.target.value),className:"w-full bg-background border border-border rounded-lg px-3 py-2 text-sm text-foreground focus:outline-none focus:border-primary/60",children:[e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"published",children:"Published"})]})]})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"submit",disabled:d.isPending,className:"flex-1 bg-primary text-primary-foreground font-bold py-2.5 rounded-lg hover:opacity-90 disabled:opacity-50 transition-opacity text-sm",children:d.isPending?"Saving...":l?"Create Dispensary":"Save Changes"}),e.jsx("button",{type:"button",onClick:i,className:"px-4 py-2.5 border border-border rounded-lg text-sm text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"})]})]})]})})}function h({label:r,value:i,onChange:u,className:l=""}){return e.jsxs("div",{className:l,children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground mb-1.5 block",children:r}),e.jsx("input",{type:"text",value:i,onChange:s=>u(s.target.value),className:"w-full bg-background border border-border rounded-lg px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-primary/60 transition-all"})]})}function w({label:r,value:i,onChange:u,rows:l=3,className:s=""}){return e.jsxs("div",{className:s,children:[e.jsx("label",{className:"text-xs font-semibold text-muted-foreground mb-1.5 block",children:r}),e.jsx("textarea",{value:i,onChange:m=>u(m.target.value),rows:l,className:"w-full bg-background border border-border rounded-lg px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-primary/60 transition-all resize-none"})]})}const V=["Indica","Sativa","Hybrid","CBD","Edibles","Vapes","Concentrates","Pre-Rolls","Topicals","Accessories"];function $(r){const i=[];return r.description||i.push("no description"),r.photos?.length||i.push("no photos"),r.address||i.push("no address"),i}function H({selected:r,onClear:i,dispensaries:u,onBulkUpdate:l}){const[s,m]=f.useState(""),[d,c]=f.useState(""),[n,y]=f.useState(""),t=()=>{const o={};s&&(o.status=s),!(d&&n&&([...r].forEach(v=>{const N=u.find(a=>a.id===v);if(!N)return;let p=N.menu_categories||[];d==="add"&&!p.includes(n)&&(p=[...p,n]),d==="remove"&&(p=p.filter(a=>a!==n)),l(v,{...o,menu_categories:p})}),!s))&&s&&[...r].forEach(j=>l(j,o))};return e.jsxs("div",{className:"mb-4 bg-primary/8 border border-primary/25 rounded-xl px-4 py-3 flex flex-wrap items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-semibold text-primary",children:[r.size," selected"]}),e.jsx("div",{className:"h-4 w-px bg-border"}),e.jsxs("select",{value:s,onChange:o=>m(o.target.value),className:"bg-card border border-border rounded-lg px-3 py-1.5 text-xs text-foreground focus:outline-none focus:border-primary/60",children:[e.jsx("option",{value:"",children:"Set status…"}),e.jsx("option",{value:"active",children:"Set Active"}),e.jsx("option",{value:"inactive",children:"Set Inactive"})]}),e.jsxs("select",{value:d,onChange:o=>c(o.target.value),className:"bg-card border border-border rounded-lg px-3 py-1.5 text-xs text-foreground focus:outline-none focus:border-primary/60",children:[e.jsx("option",{value:"",children:"Category tag…"}),e.jsx("option",{value:"add",children:"Add tag"}),e.jsx("option",{value:"remove",children:"Remove tag"})]}),d&&e.jsxs("select",{value:n,onChange:o=>y(o.target.value),className:"bg-card border border-border rounded-lg px-3 py-1.5 text-xs text-foreground focus:outline-none focus:border-primary/60",children:[e.jsx("option",{value:"",children:"Pick category…"}),V.map(o=>e.jsx("option",{value:o,children:o},o))]}),e.jsx("button",{onClick:t,disabled:!s&&!(d&&n),className:"bg-primary text-white text-xs font-semibold px-4 py-1.5 rounded-lg hover:bg-primary/90 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"Apply"}),e.jsx("button",{onClick:i,className:"ml-auto text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(E,{className:"w-4 h-4"})})]})}function re(){const r=D(),[i,u]=f.useState(null),[l,s]=f.useState(new Set),[m,d]=f.useState(!1),{data:c=[],isLoading:n}=q({queryKey:["dispensaries","all"],queryFn:()=>b.entities.Dispensary.list("-created_date",200)}),y=C({mutationFn:a=>b.entities.Dispensary.delete(a),onSuccess:()=>
13r.invalidateQueries({queryKey:["dispensaries"]})}),t=C({mutationFn:({id:a,status:x})=>b.entities.Dispensary.update(a,{status:x}),onSuccess:()=>r.invalidateQueries({queryKey:["dispensaries"]})}),o=C({mutationFn:({id:a,data:x})=>b.entities.Dispensary.update(a,x),onSuccess:()=>r.invalidateQueries({queryKey:["dispensaries"]})}),j=(a,x)=>o.mutate({id:a,data:x}),v=a=>{s(x=>{const g=new Set(x);return g.has(a)?g.delete(a):g.add(a),g})},N=()=>{l.size===c.length?s(new Set):s(new Set(c.map(a=>a.id)))},p=c.length>0&&l.size===c.length;return e.jsxs("div",{className:"p-6 max-w-6xl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-black text-foreground",children:"Dispensaries"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[c.length," total"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:async()=>{d(!0);try{await b.functions.invoke("fixThinContent",{type:"dispensaries"}),r.invalidateQueries({queryKey:["dispensaries"]})}finally{d(!1)}},disabled:m,className:"text-xs bg-yellow-500/20 text-yellow-600 px-3 py-1.5 rounded hover:bg-yellow-500/30 disabled:opacity-50 transition-colors",children:m?"Fixing...":"🔧 Fix Thin Content"}),e.jsxs("button",{onClick:()=>u({}),className:"flex items-center gap-2 bg-primary text-primary-foreground font-bold px-4 py-2.5 rounded-lg hover:opacity-90 transition-opacity text-sm",children:[e.jsx(T,{className:"w-4 h-4"})," Add Dispensary"]})]})]}),l.size>0&&e.jsx(H,{selected:l,onClear:()=>s(new Set),dispensaries:c,onBulkUpdate:j}),n&&e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"w-8 h-8 border-4 border-muted border-t-primary rounded-full animate-spin"})}),e.jsxs("div",{className:"bg-card border border-border rounded-xl overflow-hidden",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border",children:[e.jsx("th",{className:"px-4 py-3 w-8",children:e.jsx("button",{onClick:N,className:"text-muted-foreground hover:text-primary transition-colors",children:p?e.jsx(S,{className:"w-4 h-4 text-primary"}):e.jsx(_,{className:"w-4 h-4"})})}),e.jsx("th",{className:"text-left px-4 py-3 text-muted-foreground font-medium",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-3 text-muted-foreground font-medium hidden sm:table-cell",children:"City"}),e.jsx("th",{className:"text-left px-4 py-3 text-muted-foreground font-medium hidden md:table-cell",children:"Categories"}),e.jsx("th",{className:"text-left px-4 py-3 text-muted-foreground font-medium",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 text-muted-foreground font-medium hidden md:table-cell",children:"Index"}),e.jsx("th",{className:"text-right px-4 py-3 text-muted-foreground font-medium",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:c.map(a=>{const x=$(a),g=l.has(a.id);return e.jsxs("tr",{className:`hover:bg-muted/20 transition-colors ${g?"bg-primary/5":""}`,children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>v(a.id),className:"text-muted-foreground hover:text-primary transition-colors",children:g?e.jsx(S,{className:"w-4 h-4 text-primary"}):e.jsx(_,{className:"w-4 h-4"})})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-medium text-foreground",children:a.name}),x.length>0&&e.jsx(F,{issues:x})]}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground hidden sm:table-cell",children:a.city}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(a.menu_categories||[]).slice(0,3).map(k=>e.jsx("span",{className:"text-[10px] bg-secondary text-muted-foreground px-1.5 py-0.5 rounded",children:k},k)),(a.menu_categories?.length||0)>3&&e.jsxs("span",{className:"text-[10px] text-muted-foreground/60",children:["+",a.menu_categories.length-3]})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{onClick:()=>t.mutate({id:a.id,status:a.status==="active"?"inactive":"active"}),className:`text-xs px-2.5 py-1 rounded-full font-medium transition-colors ${a.status==="active"?"bg-green-500/10 text-green-400 hover:bg-green-500/20":"bg-muted text-muted-foreground hover:bg-muted/80"}`,children:a.status})}),e.jsx("td",{className:"px-4 py-3 hidden md:table-cell",children:a.index_page?e.jsx(M,{className:"w-4 h-4 text-primary"}):e.jsx(z,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(P,{to:`/admin/dispensaries/${a.id}`,className:"p-1.5 text-muted-foreground hover:text-primary hover:bg-muted rounded-md transition-colors",children:e.jsx(B,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>u(a),className:"p-1.5 text-muted-foreground hover:text-primary hover:bg-muted rounded-md transition-colors",children:e.jsx(L,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>y.mutate(a.id),className:"p-1.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-md transition-colors",children:e.jsx(I,{className:"w-3.5 h-3.5"})})]})})]},a.id)})})]}),!n&&c.length===0&&e.jsx("div",{className:"text-center py-16 text-muted-foreground",children:"No dispensaries yet. Add your first listing."})]}),i!==null&&e.jsx(U,{dispensary:i,onClose:()=>u(null)})]})}export{re 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.