1import{c as I,r as i,j as e}from"./vendor-tanstack-BVKRVeFx.js";import{g as t}from"./sonner-D6q-NjzM.js";import{B as d}from"./button-OUjdiLMl.js";import{C as y,b as N,c as w,d as v,a as C}from"./card-CQzhsazC.js";import{B as m}from"./badge-CUZHrh6o.js";import{P as B,f as S,g as R,b as T,c as _,a as z}from"./priceListExportService-01hOCZsT.js";import{ad as b,h as l,R as G,bm as H}from"./vendor-icons-BiH2Z9LN.js";import"./vendor-supabase-BXk0iSTs.js";import"./vendor-react-DvEUl2kV.js";import"./vendor-radix-BMzjRKVX.js";import"./label-CvIKZcJx.js";import"./input-CCR7bdK9.js";import"./textarea-C2E94Sl9.js";import"./select-Cs7Ne2a6.js";import"./client-VY4HUT_Q.js";import"./index-CUczFT_R.js";function te(){const E=I(),[x,h]=i.useState(!1),[u,p]=i.useState(!1),[o,g]=i.useState(!0),[r,k]=i.useState(null),f="price-list-header",[j,L]=i.useState(()=>{try{const s=localStorage.getItem(f);if(s)return JSON.parse(s)}catch{}return{companyName:'ÐÐÐ "ÐÐÐФРÐСТ.ÐÐ Ð"',cities:"г. ÐкаÑеÑинбÑÑг, г. ЧелÑбинÑк",contacts:"+79122415613 Ðавел",email:"[email protected]"}}),P=s=>{L(s),localStorage.setItem(f,JSON.stringify(s))},c=async()=>{g(!0);try{const s=await S(),n=s.filter(a=>!a.isLowStock),F=R(n);k({total:n.length,lowStockTotal:s.filter(a=>a.isLowStock).length,categories:F.map(a=>({name:a.name,count:a.items.length}))})}catch(s){console.error("Error loading preview:",s),t.error("ÐÑибка загÑÑзки даннÑÑ
: "+s.message)}finally{g(!1)}};i.useEffect(()=>{c()},[]);const A=async()=>{h(!0);try{const[s,n]=await Promise.all([S(),T()]);if(s.length===0){t.warning("ÐÐµÑ ÑоваÑов Ð´Ð»Ñ Ð¿ÑайÑ-лиÑÑа. ÐÑовеÑÑÑе оÑÑаÑки и наÑÑÑойки каÑегоÑий.");return}await _(j,s,n),t.success(`ÐÑайÑ-лиÑÑ ÑгенеÑиÑован: ${s.length} позиÑий`)}catch(s){console.error("Error generating price list:",s),t.error("ÐÑибка генеÑаÑии: "+s.message)}finally{h(!1)}},D=async()=>{p(!0);try{const s=await z();s.errors.length>0?(console.error("AutoFill errors:",s.errors),t.warning(`Ðбновлено ${s.updated} запиÑей. ÐÑибок: ${s.errors.length}`)):t.success(`ÐвÑозаполнение завеÑÑено: обновлено ${s.updated} запиÑей`),E.invalidateQueries({queryKey:["product_name_type_directories"]}),c()}catch(s){console.error("Error auto-filling:",s),t.error("ÐÑибка авÑозаполнениÑ: "+s.message)}finally{p(!1)}};return e.jsxs("div",{className:"container mx-auto py-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center gap-2",children:[e.jsx(b,{className:"h-8 w-8"}),"ÐÑайÑ-лиÑÑ"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"ÐенеÑаÑÐ¸Ñ Ð¿ÑайÑ-лиÑÑа Ñ Ð°ÐºÑÑалÑнÑми Ñенами и оÑÑаÑками"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(d,{variant:"outline",onClick:c,disabled:o,children:[o?e.jsx(l,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(G,{className:"h-4 w-4 mr-2"}),"ÐбновиÑÑ"]}),e.jsxs(d,{onClick:A,disabled:x||!r||r.total===0,children:[x?e.jsx(l,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(b,{className:"h-4 w-4 mr-2"}),"СгенеÑиÑоваÑÑ Ð¿ÑайÑ"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(y,{children:[e.jsxs(N,{children:[e.jsx(w,{children:"Шапка пÑайÑ-лиÑÑа"}),e.jsx(v,{children:"ÐаÑÑÑойÑе инÑоÑмаÑÐ¸Ñ Ð¾ компании Ð´Ð»Ñ Ð¿ÑайÑ-лиÑÑа"})]}),e.jsx(C,{children:e.jsx(B,{header:j,onChange:P})})]}),e.jsxs(y,{children:[e.jsx(N,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(w,{children:"ÐÑевÑÑ ÑоваÑов"}),e.jsx(v,{children:"ТоваÑÑ Ñ Ð¾ÑÑаÑками > 100 кг на ÑкладаÑ
ÐÐРи ЧелÑбинÑк"})]}),e.jsxs(d,{variant:"outline",size:"sm",onClick:D,disabled:u,children:[u?e.jsx(l,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(H,{className:"h-4 w-4 mr-2"}),"ÐвÑозаполнение каÑегоÑий"]})]})}),e.jsx(C,{children:o?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(l,{className:"h-6 w-6 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"ÐагÑÑзка даннÑÑ
..."})]}):r?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(m,{variant:"secondary",className:"text-base px-3 py-1",children:["РналиÑии: ",r.total]}),r.lowStockTotal>0&&e.jsxs(m,{variant:"outline",className:"text-base px-3 py-1 text-muted-foreground",children:["Ðало / Ð½ÐµÑ Ð² налиÑии: ",r.lowStockTotal]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:r.categories.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx(m,{variant:"outline",children:s.count})]},s.name))}),r.total===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"ÐÐµÑ ÑоваÑов Ñ Ð¾ÑÑаÑками > 100 кг на ÑкладаÑ
ÐкаÑеÑинбÑÑга и ЧелÑбинÑка. ÐÑовеÑÑÑе наÑÑÑойки каÑегоÑий в ÑпÑавоÑнике комбинаÑий."})]}):e.jsx("p",{className:"text-muted-foreground",children:"ÐаннÑе не загÑÑженÑ"})})]})]})]})}export{te 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.