1import{r as n,j as s}from"./vendor-query-Oyu1rd__.js";import{a as g}from"./use-admin-auth-CyR0uDGG.js";import{A as C}from"./admin-layout-CS2f6DvO.js";import{a6 as A,I as z,a8 as y,ah as L,s as E,X as D,C as T}from"./vendor-ui-epaFV1ME.js";import"./index-th7DM8Ut.js";import"./vendor-i18n-rNDOJrVQ.js";import"./vendor-motion-C_1A7OQ1.js";const _={nova:"Nová",v_jednani:"V jednánÃ",schvalena:"Schválená",zamitnuta:"ZamÃtnutá"},$={"do-500k":"Do 500 000 KÄ","500k-1m":"500 000 â 1 000 000 KÄ","1m-2m":"1 000 000 â 2 000 000 KÄ","2m-plus":"Nad 2 000 000 KÄ"},I={ihned:"Co nejdÅÃve","3-mesice":"Do 3 mÄsÃců","6-mesicu":"Do 6 mÄsÃců",rok:"Do 1 roku"},Z={vlastni:"Má vlastnà prostor",hledam:"Hledá prostor"};function H(){const[l,i]=n.useState([]),[N,h]=n.useState(!0),[r,f]=n.useState(""),[m,w]=n.useState(null),[d,b]=n.useState(null),[x,v]=n.useState({}),[S,j]=n.useState(null),u=()=>{h(!0);const e=r?`?status=${r}`:"";g(`/admin/franchise${e}`).then(a=>a.json()).then(a=>i(a.applications||[])).catch(()=>{}).finally(()=>h(!1))};n.useEffect(()=>{u()},[r]);const o=async(e,a)=>{b(e);try{(await g(`/admin/franchise/${e}`,{method:"PATCH",body:JSON.stringify({status:a})})).ok&&u()}catch{}finally{b(null)}},k=async e=>{j(e);try{(await g(`/admin/franchise/${e}`,{method:"PATCH",body:JSON.stringify({adminNotes:x[e]??""})})).ok&&u()}catch{}finally{j(null)}};return s.jsxs(C,{children:[s.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-6",children:"FranÅ¡Ãzy"}),s.jsx("div",{className:"flex gap-2 mb-4 flex-wrap",children:[{value:"",label:"VÅ¡echny"},{value:"nova",label:"Nové"},{value:"v_jednani",label:"V jednánÃ"},{value:"schvalena",label:"Schválené"},{value:"zamitnuta",label:"ZamÃtnuté"}].map(e=>s.jsx("button",{onClick:()=>f(e.value),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${r===e.value?"bg-emerald-600 text-white":"bg-white text-gray-600 border border-gray-300 hover:bg-gray-50"}`,children:e.label},e.value))}),s.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200",children:N?s.jsx("div",{className:"p-6 text-gray-500 text-center",children:"NaÄÃtánÃ..."}):l.length===0?s.jsx("div",{className:"p-6 text-gray-400 text-center",children:"Žádné žádosti"}):s.jsx("div",{className:"divide-y divide-gray-100",children:l.map(e=>s.jsxs("div",{children:[s.jsxs("div",{className:"px-4 py-3 flex items-center justify-between cursor-pointer hover:bg-gray-50",onClick:()=>{const a=m===e.id?null:e.id;w(a),a!==null&&x[e.id]===void 0&&v(c=>({...c,[e.id]:e.adminNotes||""}))},children:[s.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[s.jsx(B,{status:e.status}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("p",{className:"font-medium text-gray-900 truncate",children:[e.firstName," ",e.lastName]}),s.jsxs("p",{className:"text-xs text-gray-500",children:[e.city," | ",e.email]})]})]}),s.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[s.jsx("span",{className:"text-xs text-gray-400 hidden sm:inline",children:new Date(e.createdAt).toLocaleDateString("cs-CZ")}),m===e.id?s.jsx(A,{className:"w-4 h-4 text-gray-400"}):s.jsx(z,{className:"w-4 h-4 text-gray-400"})]})]}),m===e.id&&s.jsxs("div",{className:"px-4 py-3 bg-gray-50 border-t border-gray-100",children:[s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-sm mb-4",children:[s.jsx(t,{label:"Jméno",value:`${e.firstName} ${e.lastName}`}),s.jsx(t,{label:"E-mail",value:e.email}),s.jsx(t,{label:"Telefon",value:e.phone}),s.jsx(t,{label:"MÄsto/Region",value:e.city}),s.jsx(t,{label:"Firma",value:e.companyName}),s.jsx(t,{label:"IÄO",value:e.ico}),s.jsx(t,{label:"Typ prostoru",value:Z[e.spaceType]||e.spaceType}),s.jsx(t,{label:"Rozloha",value:e.spaceSize}),s.jsx(t,{label:"RozpoÄet",value:$[e.budget]||e.budget}),s.jsx(t,{label:"Preferovaný start",value:I[e.preferredStart]||e.preferredStart}),s.jsx(t,{label:"VytvoÅeno",value:new Date(e.createdAt).toLocaleString("cs-CZ")}),s.jsx(t,{label:"Aktualizováno",value:new Date(e.updatedAt).toLocaleString("cs-CZ")})]}),e.experience&&s.jsxs("div",{className:"mb-3",children:[s.jsx("p",{className:"text-xs text-gray-500 font-medium mb-1",children:"ZkuÅ¡enosti:"}),s.jsx("p",{className:"text-sm text-gray-900 bg-white p-2 rounded border border-gray-200",children:e.experience})]}),e.motivation&&s.jsxs("div",{className:"mb-3",children:[s.jsx("p",{className:"text-xs text-gray-500 font-medium mb-1",children:"Motivace:"}),s.jsx("p",{className:"text-sm text-gray-900 bg-white p-2 rounded border border-gray-200",children:e.motivation})]}),s.jsxs("div",{className:"mb-4",children:[s.jsxs("p",{className:"text-xs text-gray-500 font-medium mb-1 flex items-center gap-1",children:[s.jsx(y,{className:"w-3 h-3"}),"Internà poznámky:"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("textarea",{value:x[e.id]??e.adminNotes??"",onChange:a=>v(c=>({...c,[e.id]:a.target.value})),rows:2,className:"flex-1 text-sm p-2 rounded border border-gray-200 resize-none",placeholder:"PÅidejte poznámku..."}),s.jsxs("button",{onClick:()=>k(e.id),disabled:S===e.id,className:"flex items-center gap-1 px-3 py-1.5 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700 disabled:opacity-50 self-end",children:[s.jsx(L,{className:"w-4 h-4"}),"Uložit"]})]})]}),s.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.status!=="v_jednani"&&s.jsxs("button",{onClick:()=>o(e.id,"v_jednani"),disabled:d===e.id,className:"flex items-center gap-1 px-3 py-1.5 bg-blue-600 text-white rounded-lg text-sm hover:bg-blue-700 disabled:opacity-50",children:[s.jsx(y,{className:"w-4 h-4"}),"V jednánÃ"]}),e.status!=="schvalena"&&s.jsxs("button",{onClick:()=>o(e.id,"schvalena"),disabled:d===e.id,className:"flex items-center gap-1 px-3 py-1.5 bg-emerald-600 text-white rounded-lg text-sm hover:bg-emerald-700 disabled:opacity-50",children:[s.jsx(E,{className:"w-4 h-4"}),"Schválit"]}),e.status!=="zamitnuta"&&s.jsxs("button",{onClick:()=>o(e.id,"zamitnuta"),disabled:d===e.id,className:"flex items-center gap-1 px-3 py-1.5 bg-red-600 text-white rounded-lg text-sm hover:bg-red-700 disabled:opacity-50",children:[s.jsx(D,{className:"w-4 h-4"}),"ZamÃtnout"]}),e.status!=="nova"&&s.jsxs("button",{onClick:()=>o(e.id,"nova"),disabled:d===e.id,className:"flex items-center gap-1 px-3 py-1.5 bg-gray-200 text-gray-700 rounded-lg text-sm hover:bg-gray-300 disabled:opacity-50",children:[s.jsx(T,{className:"w-4 h-4"}),"Vrátit na novou"]})]})]})]},e.id))})})]})}function B({status:l}){const i={nova:"bg-yellow-100 text-yellow-800",v_jednani:"bg-blue-100 text-blue-800",schvalena:"bg-green-100 text-green-800",zamitnuta:"bg-red-100 text-red-800"};return s.jsx("span",{className:`inline-block px-2 py-0.5 rounded-full text-xs font-medium ${i[l]||"bg-gray-100 text-gray-800"}`,children:_[l]||l})}function t({label:l,value:i}){return i?s.jsxs("div",{children:[s.jsxs("span",{className:"text-gray-500",children:[l,":"]}
1)," ",s.jsx("span",{className:"text-gray-900",children:i})]}):null}export{H 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.