1import{r as y,c as M,j as e,H as W,d as _}from"./app-D7bY3VIr.js";import z from"./AdminLayout-CaNKtVdR.js";import G from"./DangerButton-DxKHxMNW.js";import o from"./InputError-JpchlQzo.js";import c from"./InputLabel-dvjxXfr8.js";import w from"./Modal-C2SBH01o.js";import k from"./PrimaryButton-BEsfaPUo.js";import C from"./SecondaryButton-B2kfP-pM.js";import x from"./TextInput-BIQ_0JaE.js";import{TranslationProvider as q,useTranslationLocale as A}from"./TranslationTabs-D64pUcwU.js";import"./ApplicationLogo-CByfrvp1.js";import"./Dropdown-CCJeegzQ.js";import"./transition-DG5evRMa.js";import"./useTranslation-tvhqZ2qh.js";import"./index-SlqGhRfq.js";function ce({plans:t,categories:l,selectedCategoryId:h}){const[j,p]=y.useState(!1),[g,u]=y.useState(null),[r,a]=y.useState(null),i=M({plan_id:"",category_id:h||(l.length>0?l[0].id:""),name:{fr:"",en:""},description:{fr:"",en:""},base_price:0,popular:!1,total_months:12,features:[{icon:"",text:{fr:"",en:""}}],active:!0,order:0}),n=M({plan_id:"",category_id:"",name:{fr:"",en:""},description:{fr:"",en:""},base_price:0,popular:!1,total_months:12,features:[{icon:"",text:{fr:"",en:""}}],active:!0,order:0}),E=()=>{p(!0),i.reset(),i.setData("category_id",h||(l.length>0?l[0].id:"")),i.setData("features",[{icon:"",text:{fr:"",en:""}}])},D=()=>{p(!1),i.reset(),i.clearErrors()},I=s=>{u(s),n.setData({plan_id:s.plan_id,category_id:s.category_id,name:s.name||{fr:"",en:""},description:s.description||{fr:"",en:""},base_price:s.base_price,popular:s.popular,total_months:s.total_months,features:s.features&&s.features.length>0?s.features.map(d=>({icon:d.icon||"",text:typeof d.text=="string"?{fr:d.text,en:d.text}:d.text||{fr:"",en:""}})):[{icon:"",text:{fr:"",en:""}}],active:s.active,order:s.order||0})},F=()=>{u(null),n.reset(),n.clearErrors()},S=(s,d)=>{const m=s.data.features||[];d("features",[...m,{icon:"",text:{fr:"",en:""}}])},P=(s,d,m)=>{const v=s.data.features||[];d("features",v.filter((N,b)=>b!==m))},L=(s,d,m,v,N,b=null)=>{const f=[...s.data.features||[]];v==="text"&&b?f[m]={...f[m],text:{...f[m].text||{fr:"",en:""},[b]:N}}:f[m]={...f[m],[v]:N},d("features",f)},B=s=>{s.preventDefault(),i.post(route("admin.pricing.store"),{preserveScroll:!0,onSuccess:()=>D()})},H=s=>{s.preventDefault(),n.put(route("admin.pricing.update",g.id),{preserveScroll:!0,onSuccess:()=>F()})},$=s=>{_.delete(route("admin.pricing.destroy",s.id),{preserveScroll:!0,onSuccess:()=>a(null)})},T=s=>{_.get(route("admin.pricing.index"),{category_id:s},{preserveScroll:!0,preserveState:!0})};return e.jsxs(z,{children:[e.jsx(W,{title:"Gestion des tarifs"}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Gestion des tarifs"}),e.jsx("p",{className:"mt-2 text-sm text-gray-600",children:"Gérez les plans et tarifs de votre application"})]}),e.jsxs(k,{onClick:E,children:[e.jsx("svg",{className:"mr-2 h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Nouveau plan"]})]}),l.length>0&&e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Filtrer par catégorie :"}),e.jsxs("select",{className:"rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",value:h||"",onChange:s=>T(s.target.value||null),children:[e.jsx("option",{value:"",children:"Toutes les catégories"}),l.map(s=>e.jsx("option",{value:s.id,children:s.name?.fr||s.name},s.id))]})]}),e.jsxs("div",{className:"overflow-hidden rounded-lg bg-white shadow-sm ring-1 ring-gray-200",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500",children:"Plan ID"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500",children:"Nom"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500",children:"Catégorie"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500",children:"Prix"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500",children:"Statut"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium uppercase tracking-wider text-gray-500",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 bg-white",children:t.data.map(s=>e.jsxs("tr",{className:"hover:bg-gray-50 transition-colors",children:[e.jsx("td",{className:"whitespace-nowrap px-6 py-4 text-sm font-medium text-gray-900",children:s.plan_id}),e.jsx("td",{className:"whitespace-nowrap px-6 py-4 text-sm text-gray-500",children:s.name?.fr||s.name}),e.jsx("td",{className:"whitespace-nowrap px-6 py-4 text-sm text-gray-500",children:s.category?.name?.fr||s.category?.name||"-"}),e.jsx("td",{className:"whitespace-nowrap px-6 py-4 text-sm text-gray-500",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-bold text-indigo-600",children:[parseFloat(s.base_price).toFixed(2)," â¬"]}),e.jsx("span",{className:"text-xs",children:"/mois"})]})}),e.jsx("td",{className:"whitespace-nowrap px-6 py-4 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold ${s.active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:s.active?"Actif":"Inactif"}),s.popular&&e.jsx("span",{className:"inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold bg-indigo-100 text-indigo-800",children:"Populaire"})]})}),e.jsx("td",{className:"whitespace-nowrap px-6 py-4 text-right text-sm font-medium",children:e.jsxs("div",{className:"flex items-center justify-end space-x-3",children:[e.jsxs("button",{onClick:()=>I(s),className:"inline-flex items-center rounded-md px-3 py-1.5 text-sm font-medium text-indigo-600 hover:bg-indigo-50 transition-colors",children:[e.jsx("svg",{className:"mr-1.5 h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),"Modifier"]}),e.jsxs("button",{onClick:()=>a(s),className:"inline-flex items-center rounded-md px-3 py-1.5 text-sm font-medium text-red-600 hover:bg-red-50 transition-colors",children:[e.jsx("svg",{className:"mr-1.5 h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),"Supprimer"]})]})})]},s.id))})]})}),t.links&&t.links.length>3&&e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-200 bg-white px-6 py-4",children:[e.jsxs("div",{className:"text-sm text-gray-700",children:["Affichage de ",e.jsx("span",{className:"font-medium",children:t.from})," à "," ",e.jsx("span",{className:"font-medium",children:t.to})," sur"," ",e.jsx("span",{className:"font-medium",children:t.total})," résultats"]}),e.jsx("div",{className:"flex space-x-2",children:t.links.map((s,d)=>e.jsx("button",{onClick:()=>{s.url&&_.get(s.url)},disabled:!s.url,className:`relative inline-flex items-center rounded-md border px-4 py-2 text-sm font-medium ${s.active?"z-10 border-indigo-500 bg-indigo-50 text-indigo-600":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"} ${s.url?"cursor-pointer":"cursor-not-allowed opacity-50"}`,dangerouslySetInnerHTML:{__html:s.label}},d))})]})]})]}),e.jsx(O,{show:j,onClose:D,form:i,onSubmit:B,categories:l,addFeature:()=>S(i,i.setData),removeFeature:s=>P(i,i.setData,s),updateFeature:(s,d,m,v)=>L(i,i.setData,s,d,m,v)}),e.jsx(V,{show:g!==null,onClose:F,form:n,onSubmit:H,categories:l,addFeature:()=>S(n,n.setData),removeFeature:s=>P(n,n.setData,s),updateFeature:(s,d,m,v)=>L(n,n.setData,s,d,m,v)}),e.jsxs(w,{show:r!==null,onClose:()=>a(null),children:[e.jsxs("div",{className:"p-6",children:[e.jsx("h2",{className:"text-lg font-medium text-gray-900",children:"Supprimer le plan"}),e.jsxs("p",{className:"mt-1 text-sm text-gray-600",children:["Ãtes-vous sûr de vouloir supprimer le plan"," ",e.jsx("strong",{children:r?.name?.fr||r?.name})," ? Cette action est irréversible."]})]}),e.jsxs("div",{className:"flex items-center justify-end bg-gray-50 px-6 py-4",children:[e.jsx(C,{onClick:()=>a(null),children:"Annuler"}),e.jsx(G,{className:"ml-3",onClick:()=>$(r),children:"Supprimer"})]})]})]})}function O({show:t,onClose:l,form:h,onSubmit:j,categories:p,addFeature:g,removeFeature:u,updateFeature:r}){return e.jsx(w,{show:t,onClose:l,children:e.jsx(q,{children:e.jsx(R,{form:h,onSubmit:j,onClose:l,categories:p,addFeature:g,removeFeature:u,updateFeature:r})})})}function R({form:t,onSubmit:l,onClose:h,categories:j,addFeature:p,removeFeature:g,updateFeature:u}){const{activeLocale:r}=A();return e.jsxs("form",{onSubmit:l,children:[e.jsxs("div",{className:"p-6 max-h-[80vh] overflow-y-auto",children:[e.jsx("h2",{className:"text-lg font-medium text-gray-900 mb-4",children:"Créer un nouveau plan"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{htmlFor:"plan_id",value:"Plan ID (identifiant unique)"}),e.jsx(x,{id:"plan_id",type:"text",className:"mt-1 block w-full",value:t.data.plan_id,onChange:a=>t.setData("plan_id",a.target.value),required:!0,autoFocus:!0,placeholder:"premium, business, etc."}),e.jsx(o,{message:t.errors.plan_id,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"category_id",value:"Catégorie"}),e.jsxs("select",{id:"category_id",className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",value:t.data.category_id,onChange:a=>t.setData("category_id",a.target.value),required:!0,children:[e.jsx("option",{value:"",children:"Sélectionner une catégorie"}),j.map(a=>e.jsx("option",{value:a.id,children:a.name?.fr||a.name},a.id))]}),e.jsx(o,{message:t.errors.category_id,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"name",value:"Nom"}),e.jsx(x,{id:"name",type:"text",className:"mt-1 block w-full",value:t.data.name?.[r]||"",onChange:a=>t.setData("name",{...t.data.name,[r]:a.target.value}),required:!0}),e.jsx(o,{message:t.errors[`name.${r}`]||t.errors.name,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"description",value:"Description"}),e.jsx("textarea",{id:"description",className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",rows:"3",value:t.data.description?.[r]||"",onChange:a=>t.setData("description",{...t.data.description,[r]:a.target.value})}),e.jsx(o,{message:t.errors[`description.${r}`]||t.errors.description,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"base_price",value:"Prix de base (â¬)"}),e.jsx(x,{id:"base_price",type:"number",step:"0.01",className:"mt-1 block w-full",value:t.data.base_price,onChange:a=>t.setData("base_price",parseFloat(a.target.value)||0),required:!0}),e.jsx(o,{message:t.errors.base_price,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"total_months",value:"Durée (mois)"}),e.jsx(x,{id:"total_months",type:"number",min:"1",className:"mt-1 block w-full",value:t.data.total_months,onChange:a=>t.setData("total_months",parseInt(a.target.value)||1),required:!0}),e.jsx(o,{message:t.errors.total_months,className:"mt-2"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{children:[e.jsx(c,{htmlFor:"order",value:"Ordre d'affichage"}),e.jsx(x,{id:"order",type:"number",min:"0",className:"mt-1 block w-full",value:t.data.order,onChange:a=>t.setData("order",parseInt(a.target.value)||0)}),e.jsx(o,{message:t.errors.order,className:"mt-2"})]})}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",checked:t.data.popular,onChange:a=>t.setData("popular",a.target.checked)}),e.jsx("span",{className:"ml-2 text-sm text-gray-600",children:"Populaire"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",checked:t.data.active,onChange:a=>t.setData("active",a.target.checked)}),e.jsx("span",{className:"ml-2 text-sm text-gray-600",children:"Actif"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(c,{value:"Caractéristiques"}),e.jsx("button",{type:"button",onClick:p,className:"text-sm text-indigo-600 hover:text-indigo-800",children:"+ Ajouter"})]}),t.data.features&&t.data.features.map((a,i)=>e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx(x,{type:"text",placeholder:"Icône (emoji)",className:"w-20",value:a.icon||"",onChange:n=>
1u(i,"icon",n.target.value)}),e.jsx(x,{type:"text",placeholder:"Description",className:"flex-1",value:a.text?.[r]||"",onChange:n=>u(i,"text",n.target.value,r)}),t.data.features.length>1&&e.jsx("button",{type:"button",onClick:()=>g(i),className:"text-red-600 hover:text-red-800",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},i)),e.jsx(o,{message:t.errors.features,className:"mt-2"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end bg-gray-50 px-6 py-4",children:[e.jsx(C,{onClick:h,children:"Annuler"}),e.jsx(k,{className:"ml-3",disabled:t.processing,children:"Créer"})]})]})}function V({show:t,onClose:l,form:h,onSubmit:j,categories:p,addFeature:g,removeFeature:u,updateFeature:r}){return e.jsx(w,{show:t,onClose:l,children:e.jsx(q,{children:e.jsx(J,{form:h,onSubmit:j,onClose:l,categories:p,addFeature:g,removeFeature:u,updateFeature:r})})})}function J({form:t,onSubmit:l,onClose:h,categories:j,addFeature:p,removeFeature:g,updateFeature:u}){const{activeLocale:r}=A();return e.jsxs("form",{onSubmit:l,children:[e.jsxs("div",{className:"p-6 max-h-[80vh] overflow-y-auto",children:[e.jsx("h2",{className:"text-lg font-medium text-gray-900 mb-4",children:"Modifier le plan"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{htmlFor:"edit_plan_id",value:"Plan ID (identifiant unique)"}),e.jsx(x,{id:"edit_plan_id",type:"text",className:"mt-1 block w-full",value:t.data.plan_id,onChange:a=>t.setData("plan_id",a.target.value),required:!0,autoFocus:!0}),e.jsx(o,{message:t.errors.plan_id,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"edit_category_id",value:"Catégorie"}),e.jsxs("select",{id:"edit_category_id",className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",value:t.data.category_id,onChange:a=>t.setData("category_id",a.target.value),required:!0,children:[e.jsx("option",{value:"",children:"Sélectionner une catégorie"}),j.map(a=>e.jsx("option",{value:a.id,children:a.name?.fr||a.name},a.id))]}),e.jsx(o,{message:t.errors.category_id,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"edit_name",value:"Nom"}),e.jsx(x,{id:"edit_name",type:"text",className:"mt-1 block w-full",value:t.data.name?.[r]||"",onChange:a=>t.setData("name",{...t.data.name,[r]:a.target.value}),required:!0}),e.jsx(o,{message:t.errors[`name.${r}`]||t.errors.name,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"edit_description",value:"Description"}),e.jsx("textarea",{id:"edit_description",className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",rows:"3",value:t.data.description?.[r]||"",onChange:a=>t.setData("description",{...t.data.description,[r]:a.target.value})}),e.jsx(o,{message:t.errors[`description.${r}`]||t.errors.description,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"edit_base_price",value:"Prix de base (â¬)"}),e.jsx(x,{id:"edit_base_price",type:"number",step:"0.01",className:"mt-1 block w-full",value:t.data.base_price,onChange:a=>t.setData("base_price",parseFloat(a.target.value)||0),required:!0}),e.jsx(o,{message:t.errors.base_price,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(c,{htmlFor:"edit_total_months",value:"Durée (mois)"}),e.jsx(x,{id:"edit_total_months",type:"number",min:"1",className:"mt-1 block w-full",value:t.data.total_months,onChange:a=>t.setData("total_months",parseInt(a.target.value)||1),required:!0}),e.jsx(o,{message:t.errors.total_months,className:"mt-2"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{children:[e.jsx(c,{htmlFor:"edit_order",value:"Ordre d'affichage"}),e.jsx(x,{id:"edit_order",type:"number",min:"0",className:"mt-1 block w-full",value:t.data.order,onChange:a=>t.setData("order",parseInt(a.target.value)||0)}),e.jsx(o,{message:t.errors.order,className:"mt-2"})]})}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",checked:t.data.popular,onChange:a=>t.setData("popular",a.target.checked)}),e.jsx("span",{className:"ml-2 text-sm text-gray-600",children:"Populaire"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-500 focus:ring-indigo-500",checked:t.data.active,onChange:a=>t.setData("active",a.target.checked)}),e.jsx("span",{className:"ml-2 text-sm text-gray-600",children:"Actif"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(c,{value:"Caractéristiques"}),e.jsx("button",{type:"button",onClick:p,className:"text-sm text-indigo-600 hover:text-indigo-800",children:"+ Ajouter"})]}),t.data.features&&t.data.features.map((a,i)=>e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx(x,{type:"text",placeholder:"Icône (emoji)",className:"w-20",value:a.icon||"",onChange:n=>
1u(i,"icon",n.target.value)}),e.jsx(x,{type:"text",placeholder:"Description",className:"flex-1",value:a.text?.[r]||"",onChange:n=>u(i,"text",n.target.value,r)}),t.data.features.length>1&&e.jsx("button",{type:"button",onClick:()=>g(i),className:"text-red-600 hover:text-red-800",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},i)),e.jsx(o,{message:t.errors.features,className:"mt-2"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end bg-gray-50 px-6 py-4",children:[e.jsx(C,{onClick:h,children:"Annuler"}),e.jsx(k,{className:"ml-3",disabled:t.processing,children:"Enregistrer"})]})]})}export{ce 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.