PageSourceSearch

https://rubpage.com/assets/AdminNeighborhoodsPage-bY7K8968.js

js rubpage.com collected 2026-09-25 06:31:29 UTC 7,602 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-query-nkyHp8gL.js";import{r as m}from"./vendor-react-BNT0nzvx.js";import{D as b}from"./DashboardLayout-BQArLa03.js";import{C as j}from"./use-admin-BO9a-9QR.js";import{d as v,e as f,f as N}from"./use-neighborhoods-DjVtXLg0.js";import{i as y,B as i,Y as C,n as d}from"./index-BG1hbjB_.js";import{D as w,b as _,c as A,d as D}from"./dialog-B5Y3GFNH.js";import{A as k,h as S,a as P,b as T,c as L,d as z,e as E,f as F,g as I}from"./alert-dialog-B5uVNgde.js";import{P as B}from"./pencil-Oe0dv2QU.js";import{T as H}from"./trash-2-D8mh_ZKl.js";import{S as M}from"./save-CkVTcoKu.js";import"./input-otp-BmijqesX.js";import"./shield-check-BjMYzFta.js";import"./shield-D2cqmhBs.js";import"./chevron-right-Bjkf53ML.js";import"./eye-CbHUV7pU.js";import"./mail-check-D7o3uZkb.js";import"./users-qXgsJLD-.js";import"./newspaper-CxHmHB1y.js";import"./crown-CsNa2Jyx.js";import"./target-DCR3Hpgj.js";import"./list-CCtzf_Gh.js";import"./flag-BAn4BLiN.js";import"./vendor-ui-DPPUfW-O.js";import"./vendor-charts-B_MCcq71.js";import"./vendor-supabase-BRDBMtg7.js";const q={name:"",slug:"",priority:0,is_active:!0,description:"",center_lat:null,center_lng:null,meta_title:"",meta_description:"",seo_text:""},ue=()=>{const{data:x,isLoading:u}=j(),[a,g]=m.useState(""),{data:n,isLoading:c}=v(a||void 0),o=f(),h=N(),{toast:l}=y(),[t,r]=m.useState(null),p=async()=>{if(!t?.name||!t?.slug||!a){l({title:"Name, slug and city required",variant:"destructive"});return}try{await o.mutateAsync({...t,city_id:a}),l({title:t.id?"Neighborhood updated":"Neighborhood created"}),r(null)}catch(s){l({title:"Error",description:s.message,variant:"destructive"})}};return e.jsxs(b,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h1",{className:"text-xl font-medium text-foreground",children:"Neighborhoods"}),e.jsxs(i,{size:"sm",onClick:()=>r({...q}),disabled:!a,children:[e.jsx(C,{className:"w-4 h-4 mr-1"})," Add"]})]}),e.jsxs("div",{className:"mb-4 max-w-xs",children:[e.jsx("label",{className:"text-xs font-medium text-foreground block mb-1",children:"Select City"}),u?e.jsx(d,{className:"w-4 h-4 animate-spin"}):e.jsxs("select",{value:a,onChange:s=>g(s.target.value),className:"w-full px-3 py-2 rounded-lg border border-border bg-background text-sm",children:[e.jsx("option",{value:"",children:"— Choose city —"}),(x??[]).map(s=>e.jsxs("option",{value:s.id,children:[s.name,", ",s.state??s.country]},s.id))]})]}),a&&c&&e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(d,{className:"w-5 h-5 animate-spin text-muted-foreground"})}),a&&!c&&e.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-[1fr_80px_60px_60px_80px] gap-3 px-4 py-2.5 bg-secondary/30 border-b border-border text-xs font-medium text-muted-foreground",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Slug"}),e.jsx("span",{children:"Priority"}),e.jsx("span",{children:"Active"}),e.jsx("span",{children:"Actions"})]}),e.jsxs("div",{className:"divide-y divide-border max-h-[500px] overflow-y-auto",children:[(n??[]).length===0&&e.jsx("div",{className:"px-4 py-6 text-sm text-muted-foreground text-center",children:"No neighborhoods yet. Add one above."}),(n??[]).map(s=>e.jsxs("div",{className:"grid grid-cols-[1fr_80px_60px_60px_80px] gap-3 px-4 py-2.5 text-sm items-center",children:[e.jsx("span",{className:"text-foreground truncate",children:s.name}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",children:s.slug}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.priority}),e.jsx("span",{className:"text-xs",children:s.is_active?"✓":"✗"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>r({...s}),children:e.jsx(B,{className:"w-3.5 h-3.5"})}),e.jsxs(k,{children:[e.jsx(S,{asChild:!0,children:e.jsx(i,{variant:"ghost",size:"sm",children:e.jsx(H,{className:"w-3.5 h-3.5 text-destructive"})})}),e.jsxs(P,{children:[e.jsxs(T,{children:[e.jsxs(L,{children:["Delete ",s.name,"?"]}),e.jsx(z,{children:"This will remove the neighborhood."})]}),e.jsxs(E,{children:[e.jsx(F,{children:"Cancel"}),e.jsx(I,{onClick:()=>h.mutateAsync(s.id),children:"Delete"})]})]})]})]})]},s.id))]})]}),e.jsx(w,{open:!!t,onOpenChange:()=>r(null),children:e.jsxs(_,{className:"max-w-md",children:[e.jsx(A,{children:e.jsx(D,{children:t?.id?"
1Edit Neighborhood":"Add Neighborhood"})}),t&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Name *"}),e.jsx("input",{value:t.name,onChange:s=>r({...t,name:s.target.value}),className:"w-full px-3 py-2 rounded-lg border border-border bg-background text-sm mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Slug *"}),e.jsx("input",{value:t.slug,onChange:s=>r({...t,slug:s.target.value}),className:"w-full px-3 py-2 rounded-lg border border-border bg-background text-sm mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Priority"}),e.jsx("input",{type:"number",value:t.priority??0,onChange:s=>r({...t,priority:parseInt(s.target.value)||0}),className:"w-full px-3 py-2 rounded-lg border border-border bg-background text-sm mt-1"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Center Lat"}),e.jsx("input",{type:"number",step:"any",value:t.center_lat??"",onChange:s=>r({...t,center_lat:s.target.value?parseFloat(s.target.value):null}),className:"w-full px-3 py-2 rounded-lg border border-border bg-background text-sm mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Center Lng"}),e.jsx("input",{type:"number",step:"any",value:t.center_lng??"",onChange:s=>r({...t,center_lng:s.target.value?parseFloat(s.target.value):null}),className:"w-full px-3 py-2 rounded-lg border border-border bg-background text-sm mt-1"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.is_active??!0,onChange:s=>r({...t,is_active:s.target.checked}),id:"nb-active"}),e.jsx("label",{htmlFor:"nb-active",className:"text-xs font-medium text-foreground",children:"Active"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Description"}),e.jsx("textarea",{value:t.description??"",onChange:s=>r({...t,description:s.target.value}),rows:2,className:"w-full px-3 py-2 rounded-lg border border-border bg-background text-sm mt-1 resize-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Meta Title"}),e.jsx("input",{value:t.meta_title??"",onChange:s=>r({...t,meta_title:s.target.value}),className:"w-full px-3 py-2 rounded-lg border border-border bg-background text-sm mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-foreground",children:"Meta Description"}),e.jsx("textarea",{value:t.meta_description??"",onChange:s=>r({...t,meta_description:s.target.value}),rows:2,className:"w-full px-3 py-2 rounded-lg border border-border bg-background text-sm mt-1 resize-none"})]}),e.jsxs(i,{onClick:p,disabled:o.isPending,className:"w-full",children:[o.isPending?e.jsx(d,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(M,{className:"w-4 h-4 mr-2"})," Save"]})]})]})})]})};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.