1 line
34 KiB
JavaScript
1 line
34 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,6655,e=>{"use strict";let a=e.i(47167).default.env.NEXT_PUBLIC_API_URL??"/admin/api/v1";e.s(["ADMIN_API_BASE",0,a])},45946,e=>{"use strict";var a=e.i(43476),s=e.i(71645),n=e.i(18566),t=e.i(22016),i=e.i(6655);let l={ACTIVE:"text-emerald-400",TRIALING:"text-sky-400",SUSPENDED:"text-red-400",PENDING:"text-orange-400",CANCELLED:"text-zinc-400",PAST_DUE:"text-orange-400"},r="mt-1 w-full rounded-xl border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-emerald-500",c="text-xs font-medium uppercase tracking-wide text-zinc-500";function o(e){return e?new Date(e).toISOString().slice(0,10):""}function d(e){return e.trim()||null}function u(e){var a;let s=!(a=e.address)||"object"!=typeof a||Array.isArray(a)?{}:a;return{company:{name:e.name??"",slug:e.slug??"",email:e.email??"",phone:e.phone??"",status:e.status??"TRIALING",subscriptionPaymentRef:e.subscriptionPaymentRef??""},companyProfile:{legalForm:s.legalForm??"",managerName:s.managerName??"",zipCode:s.zipCode??"",fax:s.fax??"",yearsActive:s.yearsActive??"",iceNumber:s.iceNumber??"",operatingLicenseNumber:s.operatingLicenseNumber??"",operatingLicenseIssuedAt:s.operatingLicenseIssuedAt??"",operatingLicenseIssuedBy:s.operatingLicenseIssuedBy??"",representativeName:s.representativeName??"",representativeTitle:s.representativeTitle??"",responsibleName:s.responsibleName??"",responsibleRole:s.responsibleRole??"",responsibleIdentityNumber:s.responsibleIdentityNumber??"",responsibleQualification:s.responsibleQualification??"",responsiblePhone:s.responsiblePhone??"",responsibleEmail:s.responsibleEmail??""},subscription:{plan:e.subscription?.plan??"STARTER",billingPeriod:e.subscription?.billingPeriod??"MONTHLY",status:e.subscription?.status??"TRIALING",currency:e.subscription?.currency??"MAD",trialStartAt:o(e.subscription?.trialStartAt),trialEndAt:o(e.subscription?.trialEndAt),currentPeriodStart:o(e.subscription?.currentPeriodStart),currentPeriodEnd:o(e.subscription?.currentPeriodEnd),cancelledAt:o(e.subscription?.cancelledAt),cancelAtPeriodEnd:e.subscription?.cancelAtPeriodEnd??!1},brand:{displayName:e.brand?.displayName??e.name??"",tagline:e.brand?.tagline??"",subdomain:e.brand?.subdomain??e.slug??"",customDomain:e.brand?.customDomain??"",publicEmail:e.brand?.publicEmail??"",publicPhone:e.brand?.publicPhone??"",publicAddress:e.brand?.publicAddress??"",publicCity:e.brand?.publicCity??"",publicCountry:e.brand?.publicCountry??"",websiteUrl:e.brand?.websiteUrl??"",whatsappNumber:e.brand?.whatsappNumber??"",defaultLocale:e.brand?.defaultLocale??"en",defaultCurrency:e.brand?.defaultCurrency??"MAD",isListedOnMarketplace:e.brand?.isListedOnMarketplace??!0},contractSettings:{legalName:e.contractSettings?.legalName??"",registrationNumber:e.contractSettings?.registrationNumber??"",taxId:e.contractSettings?.taxId??"",terms:e.contractSettings?.terms??"",fuelPolicyType:e.contractSettings?.fuelPolicyType??"FULL_TO_FULL",lateFeePerHour:e.contractSettings?.lateFeePerHour?.toString()??"",taxRate:e.contractSettings?.taxRate?.toString()??"",signatureRequired:e.contractSettings?.signatureRequired??!0,showTax:e.contractSettings?.showTax??!1},accountingSettings:{reportingPeriod:e.accountingSettings?.reportingPeriod??"MONTHLY",fiscalYearStart:e.accountingSettings?.fiscalYearStart?.toString()??"1",currency:e.accountingSettings?.currency??"MAD",accountantEmail:e.accountingSettings?.accountantEmail??"",accountantName:e.accountingSettings?.accountantName??"",autoSendReport:e.accountingSettings?.autoSendReport??!1,reportFormat:e.accountingSettings?.reportFormat??"PDF"}}}e.s(["default",0,function(){let{id:e}=(0,n.useParams)(),o=(0,n.useRouter)(),[p,m]=(0,s.useState)(null),[x,b]=(0,s.useState)(null),[g,h]=(0,s.useState)([]),[N,j]=(0,s.useState)([]),[y,v]=(0,s.useState)(null),[f,S]=(0,s.useState)(""),[P,C]=(0,s.useState)(!1),[A,E]=(0,s.useState)(!0),[L,R]=(0,s.useState)(null),[T,w]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[z,k]=(0,s.useState)(null),[U,_]=(0,s.useState)(!1);async function M(){try{let[a,s]=await Promise.all([fetch(`${i.ADMIN_API_BASE}/admin/companies/${e}`,{cache:"no-store",credentials:"include"}),fetch(`${i.ADMIN_API_BASE}/admin/audit-logs?entityId=${e}&pageSize=10`,{cache:"no-store",credentials:"include"})]),n=await a.json(),t=await s.json();if(!a.ok)throw Error(n?.message??"Not found");m(n.data),b(u(n.data)),h(t.data?.data??[]);let l=n.data?.subscription?.id;if(l){let e=await fetch(`${i.ADMIN_API_BASE}/admin/subscriptions/${l}/events`,{cache:"no-store",credentials:"include"}),a=await e.json();j(Array.isArray(a.data)?a.data:[])}R(null)}catch(e){R(e.message)}finally{E(!1)}}function F(e,a){b(s=>s?{...s,[e]:{...s[e],...a}}:s)}async function O(){if(x){I(!0),k(null),R(null);try{let a=await fetch(`${i.ADMIN_API_BASE}/admin/companies/${e}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({company:{name:x.company.name,slug:x.company.slug,email:x.company.email,phone:d(x.company.phone),subscriptionPaymentRef:d(x.company.subscriptionPaymentRef),address:{streetAddress:d(x.brand.publicAddress),city:d(x.brand.publicCity),country:d(x.brand.publicCountry),zipCode:d(x.companyProfile.zipCode),legalName:d(x.contractSettings.legalName),legalForm:d(x.companyProfile.legalForm),companyEmail:d(x.company.email),managerName:d(x.companyProfile.managerName),iceNumber:d(x.companyProfile.iceNumber),operatingLicenseNumber:d(x.companyProfile.operatingLicenseNumber),operatingLicenseIssuedAt:d(x.companyProfile.operatingLicenseIssuedAt),operatingLicenseIssuedBy:d(x.companyProfile.operatingLicenseIssuedBy),fax:d(x.companyProfile.fax),yearsActive:d(x.companyProfile.yearsActive),representativeName:d(x.companyProfile.representativeName),representativeTitle:d(x.companyProfile.representativeTitle),responsibleName:d(x.companyProfile.responsibleName),responsibleRole:d(x.companyProfile.responsibleRole),responsibleIdentityNumber:d(x.companyProfile.responsibleIdentityNumber),responsibleQualification:d(x.companyProfile.responsibleQualification),responsiblePhone:d(x.companyProfile.responsiblePhone),responsibleEmail:d(x.companyProfile.responsibleEmail)}},subscription:{plan:x.subscription.plan,billingPeriod:x.subscription.billingPeriod,status:x.subscription.status,currency:x.subscription.currency,trialStartAt:d(x.subscription.trialStartAt),trialEndAt:d(x.subscription.trialEndAt),currentPeriodStart:d(x.subscription.currentPeriodStart),currentPeriodEnd:d(x.subscription.currentPeriodEnd),cancelledAt:d(x.subscription.cancelledAt),cancelAtPeriodEnd:x.subscription.cancelAtPeriodEnd},brand:{displayName:x.brand.displayName,tagline:d(x.brand.tagline),subdomain:x.brand.subdomain,customDomain:d(x.brand.customDomain),publicEmail:d(x.brand.publicEmail),publicPhone:d(x.brand.publicPhone),publicAddress:d(x.brand.publicAddress),publicCity:d(x.brand.publicCity),publicCountry:d(x.brand.publicCountry),websiteUrl:d(x.brand.websiteUrl),whatsappNumber:d(x.brand.whatsappNumber),defaultLocale:x.brand.defaultLocale,defaultCurrency:x.brand.defaultCurrency,isListedOnMarketplace:x.brand.isListedOnMarketplace},contractSettings:{legalName:d(x.contractSettings.legalName),registrationNumber:d(x.contractSettings.registrationNumber),taxId:d(x.contractSettings.taxId),terms:x.contractSettings.terms,fuelPolicyType:x.contractSettings.fuelPolicyType,lateFeePerHour:x.contractSettings.lateFeePerHour?Number(x.contractSettings.lateFeePerHour):null,taxRate:x.contractSettings.taxRate?Number(x.contractSettings.taxRate):null,signatureRequired:x.contractSettings.signatureRequired,showTax:x.contractSettings.showTax},accountingSettings:{reportingPeriod:x.accountingSettings.reportingPeriod,fiscalYearStart:Number(x.accountingSettings.fiscalYearStart||1),currency:x.accountingSettings.currency,accountantEmail:d(x.accountingSettings.accountantEmail),accountantName:d(x.accountingSettings.accountantName),autoSendReport:x.accountingSettings.autoSendReport,reportFormat:x.accountingSettings.reportFormat}})}),s=await a.json();if(!a.ok)throw Error(s?.message??"Save failed");m(s.data),b(u(s.data)),k("Company settings updated."),await M()}catch(e){R(e.message)}finally{I(!1)}}}async function B(e){if(p?.subscription?.id){if(!f.trim())return void R("A reason is required for subscription overrides");v(e),R(null);try{let a=await fetch(`${i.ADMIN_API_BASE}/admin/subscriptions/${p.subscription.id}/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({reason:f})}),s=await a.json();if(!a.ok)throw Error(s?.message??"Action failed");S(""),C(!1),await M()}catch(e){R(e.message)}finally{v(null)}}}async function H(a){w(!0),R(null);try{let s=await fetch(`${i.ADMIN_API_BASE}/admin/companies/${e}/status`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({status:a})}),n=await s.json();if(!s.ok)throw Error(n?.message??"Action failed");await M()}catch(e){R(e.message)}finally{w(!1)}}async function Y(){w(!0);try{let a=await fetch(`${i.ADMIN_API_BASE}/admin/companies/${e}`,{method:"DELETE",credentials:"include"}),s=await a.json();if(!a.ok)throw Error(s?.message??"Delete failed");o.push("/dashboard/companies")}catch(e){R(e.message),w(!1)}}if((0,s.useEffect)(()=>{M()},[e]),A)return(0,a.jsx)("div",{className:"shell py-16 text-center text-zinc-500",children:"Loading…"});if(L&&!p)return(0,a.jsx)("div",{className:"shell py-16 text-center text-red-400",children:L});if(!p||!x)return null;let $={employees:p._count?.employees??p.employees?.length??0,vehicles:p._count?.vehicles??p.vehicles?.length??0,customers:p._count?.customers??p.customers?.length??0,reservations:p._count?.reservations??p.reservations?.length??0};return(0,a.jsxs)("div",{className:"shell space-y-6 py-8",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)(t.default,{href:"/dashboard/companies",className:"text-sm text-zinc-500 hover:text-zinc-300",children:"← Companies"}),(0,a.jsx)("button",{onClick:O,disabled:D,className:"rounded-xl bg-emerald-600 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-emerald-500 disabled:opacity-50",children:D?"Saving…":"Save changes"})]}),(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-3xl font-black",children:p.name}),(0,a.jsx)("p",{className:"mt-1 font-mono text-sm text-zinc-400",children:p.slug})]}),(0,a.jsx)("span",{className:`text-sm font-semibold ${l[p.status]??"text-zinc-400"}`,children:p.status})]}),L&&(0,a.jsx)("div",{className:"panel p-4 text-sm text-red-400",children:L}),z&&(0,a.jsx)("div",{className:"panel p-4 text-sm text-emerald-400",children:z}),(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[{label:"Employees",value:$.employees},{label:"Vehicles",value:$.vehicles},{label:"Customers",value:$.customers},{label:"Reservations",value:$.reservations}].map(e=>(0,a.jsxs)("div",{className:"panel p-5",children:[(0,a.jsx)("p",{className:"text-xs text-zinc-500",children:e.label}),(0,a.jsx)("p",{className:"mt-1 text-2xl font-black",children:e.value})]},e.label))}),(0,a.jsxs)("div",{className:"grid gap-6 xl:grid-cols-2",children:[(0,a.jsxs)("section",{className:"panel p-6",children:[(0,a.jsx)("h2",{className:"text-base font-semibold",children:"Company"}),(0,a.jsxs)("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Name"}),(0,a.jsx)("input",{className:r,value:x.company.name,onChange:e=>F("company",{name:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Slug"}),(0,a.jsx)("input",{className:r,value:x.company.slug,onChange:e=>F("company",{slug:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Email"}),(0,a.jsx)("input",{className:r,type:"email",value:x.company.email,onChange:e=>F("company",{email:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Phone"}),(0,a.jsx)("input",{className:r,value:x.company.phone,onChange:e=>F("company",{phone:e.target.value})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:c,children:"Company status"}),(0,a.jsx)("p",{className:`mt-1 text-sm font-semibold ${l[x.company.status]??"text-zinc-400"}`,children:x.company.status})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Subscription payment ref"}),(0,a.jsx)("input",{className:r,value:x.company.subscriptionPaymentRef,onChange:e=>F("company",{subscriptionPaymentRef:e.target.value})})]})]})]}),(0,a.jsxs)("section",{className:"panel p-6",children:[(0,a.jsx)("h2",{className:"text-base font-semibold",children:"Subscription"}),(0,a.jsxs)("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Plan"}),(0,a.jsxs)("select",{className:r,value:x.subscription.plan,onChange:e=>F("subscription",{plan:e.target.value}),children:[(0,a.jsx)("option",{value:"STARTER",children:"STARTER"}),(0,a.jsx)("option",{value:"GROWTH",children:"GROWTH"}),(0,a.jsx)("option",{value:"PRO",children:"PRO"})]})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Billing period"}),(0,a.jsxs)("select",{className:r,value:x.subscription.billingPeriod,onChange:e=>F("subscription",{billingPeriod:e.target.value}),children:[(0,a.jsx)("option",{value:"MONTHLY",children:"MONTHLY"}),(0,a.jsx)("option",{value:"ANNUAL",children:"ANNUAL"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:c,children:"Status"}),(0,a.jsx)("p",{className:`mt-1 text-sm font-semibold ${l[x.subscription.status]??"text-zinc-400"}`,children:x.subscription.status}),p.subscription?.paymentPendingSince&&(0,a.jsxs)("p",{className:"mt-0.5 text-xs text-zinc-500",children:["Pending since ",new Date(p.subscription.paymentPendingSince).toLocaleDateString()]}),p.subscription?.pastDueSince&&(0,a.jsxs)("p",{className:"mt-0.5 text-xs text-orange-500",children:["Past due since ",new Date(p.subscription.pastDueSince).toLocaleDateString()]}),p.subscription?.suspendedAt&&(0,a.jsxs)("p",{className:"mt-0.5 text-xs text-red-500",children:["Suspended ",new Date(p.subscription.suspendedAt).toLocaleDateString()]})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Currency"}),(0,a.jsxs)("select",{className:r,value:x.subscription.currency,onChange:e=>F("subscription",{currency:e.target.value}),children:[(0,a.jsx)("option",{value:"MAD",children:"MAD"}),(0,a.jsx)("option",{value:"USD",children:"USD"}),(0,a.jsx)("option",{value:"EUR",children:"EUR"})]})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Trial start"}),(0,a.jsx)("input",{className:r,type:"date",value:x.subscription.trialStartAt,onChange:e=>F("subscription",{trialStartAt:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Trial end"}),(0,a.jsx)("input",{className:r,type:"date",value:x.subscription.trialEndAt,onChange:e=>F("subscription",{trialEndAt:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Period start"}),(0,a.jsx)("input",{className:r,type:"date",value:x.subscription.currentPeriodStart,onChange:e=>F("subscription",{currentPeriodStart:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Period end"}),(0,a.jsx)("input",{className:r,type:"date",value:x.subscription.currentPeriodEnd,onChange:e=>F("subscription",{currentPeriodEnd:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Cancelled at"}),(0,a.jsx)("input",{className:r,type:"date",value:x.subscription.cancelledAt,onChange:e=>F("subscription",{cancelledAt:e.target.value})})]}),(0,a.jsxs)("label",{className:"flex items-center gap-3 pt-7 text-sm text-zinc-300",children:[(0,a.jsx)("input",{type:"checkbox",checked:x.subscription.cancelAtPeriodEnd,onChange:e=>F("subscription",{cancelAtPeriodEnd:e.target.checked})}),"Cancel at period end"]})]})]}),(0,a.jsxs)("section",{className:"panel p-6",children:[(0,a.jsx)("h2",{className:"text-base font-semibold",children:"Brand and public profile"}),(0,a.jsxs)("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Display name"}),(0,a.jsx)("input",{className:r,value:x.brand.displayName,onChange:e=>F("brand",{displayName:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Subdomain"}),(0,a.jsx)("input",{className:r,value:x.brand.subdomain,onChange:e=>F("brand",{subdomain:e.target.value})})]}),(0,a.jsxs)("label",{className:"md:col-span-2",children:[(0,a.jsx)("span",{className:c,children:"Tagline"}),(0,a.jsx)("input",{className:r,value:x.brand.tagline,onChange:e=>F("brand",{tagline:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Public email"}),(0,a.jsx)("input",{className:r,type:"email",value:x.brand.publicEmail,onChange:e=>F("brand",{publicEmail:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Public phone"}),(0,a.jsx)("input",{className:r,value:x.brand.publicPhone,onChange:e=>F("brand",{publicPhone:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Custom domain"}),(0,a.jsx)("input",{className:r,value:x.brand.customDomain,onChange:e=>F("brand",{customDomain:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Website URL"}),(0,a.jsx)("input",{className:r,type:"url",value:x.brand.websiteUrl,onChange:e=>F("brand",{websiteUrl:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"WhatsApp"}),(0,a.jsx)("input",{className:r,value:x.brand.whatsappNumber,onChange:e=>F("brand",{whatsappNumber:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Locale"}),(0,a.jsx)("input",{className:r,value:x.brand.defaultLocale,onChange:e=>F("brand",{defaultLocale:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Brand currency"}),(0,a.jsxs)("select",{className:r,value:x.brand.defaultCurrency,onChange:e=>F("brand",{defaultCurrency:e.target.value}),children:[(0,a.jsx)("option",{value:"MAD",children:"MAD"}),(0,a.jsx)("option",{value:"USD",children:"USD"}),(0,a.jsx)("option",{value:"EUR",children:"EUR"})]})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"City"}),(0,a.jsx)("input",{className:r,value:x.brand.publicCity,onChange:e=>F("brand",{publicCity:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Country"}),(0,a.jsx)("input",{className:r,value:x.brand.publicCountry,onChange:e=>F("brand",{publicCountry:e.target.value})})]}),(0,a.jsxs)("label",{className:"md:col-span-2",children:[(0,a.jsx)("span",{className:c,children:"Address"}),(0,a.jsx)("input",{className:r,value:x.brand.publicAddress,onChange:e=>F("brand",{publicAddress:e.target.value})})]}),(0,a.jsxs)("label",{className:"flex items-center gap-3 pt-7 text-sm text-zinc-300",children:[(0,a.jsx)("input",{type:"checkbox",checked:x.brand.isListedOnMarketplace,onChange:e=>F("brand",{isListedOnMarketplace:e.target.checked})}),"Listed on marketplace"]})]})]}),(0,a.jsxs)("section",{className:"panel p-6",children:[(0,a.jsx)("h2",{className:"text-base font-semibold",children:"Company legal profile"}),(0,a.jsxs)("div",{className:"mt-4 grid gap-6",children:[(0,a.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Legal form"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.legalForm,onChange:e=>F("companyProfile",{legalForm:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Manager / owner name"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.managerName,onChange:e=>F("companyProfile",{managerName:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"ZIP / postal code"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.zipCode,onChange:e=>F("companyProfile",{zipCode:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Fax"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.fax,onChange:e=>F("companyProfile",{fax:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Years active"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.yearsActive,onChange:e=>F("companyProfile",{yearsActive:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"ICE number"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.iceNumber,onChange:e=>F("companyProfile",{iceNumber:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Operating license number"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.operatingLicenseNumber,onChange:e=>F("companyProfile",{operatingLicenseNumber:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Operating license issue date"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.operatingLicenseIssuedAt,onChange:e=>F("companyProfile",{operatingLicenseIssuedAt:e.target.value})})]}),(0,a.jsxs)("label",{className:"md:col-span-2",children:[(0,a.jsx)("span",{className:c,children:"Issuing authority"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.operatingLicenseIssuedBy,onChange:e=>F("companyProfile",{operatingLicenseIssuedBy:e.target.value})})]})]}),(0,a.jsxs)("div",{className:"border-t border-zinc-800 pt-6",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-zinc-200",children:"Legal representative"}),(0,a.jsxs)("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Representative name"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.representativeName,onChange:e=>F("companyProfile",{representativeName:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Representative title"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.representativeTitle,onChange:e=>F("companyProfile",{representativeTitle:e.target.value})})]})]})]}),(0,a.jsxs)("div",{className:"border-t border-zinc-800 pt-6",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-zinc-200",children:"Responsible person"}),(0,a.jsxs)("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Responsible name"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.responsibleName,onChange:e=>F("companyProfile",{responsibleName:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Responsible role"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.responsibleRole,onChange:e=>F("companyProfile",{responsibleRole:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Identity document number"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.responsibleIdentityNumber,onChange:e=>F("companyProfile",{responsibleIdentityNumber:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Qualification / diploma / experience"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.responsibleQualification,onChange:e=>F("companyProfile",{responsibleQualification:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Responsible phone"}),(0,a.jsx)("input",{className:r,value:x.companyProfile.responsiblePhone,onChange:e=>F("companyProfile",{responsiblePhone:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Responsible email"}),(0,a.jsx)("input",{className:r,type:"email",value:x.companyProfile.responsibleEmail,onChange:e=>F("companyProfile",{responsibleEmail:e.target.value})})]})]})]})]})]}),(0,a.jsxs)("section",{className:"panel p-6",children:[(0,a.jsx)("h2",{className:"text-base font-semibold",children:"Operations and finance"}),(0,a.jsxs)("div",{className:"mt-4 grid gap-6",children:[(0,a.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Legal name"}),(0,a.jsx)("input",{className:r,value:x.contractSettings.legalName,onChange:e=>F("contractSettings",{legalName:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Registration number"}),(0,a.jsx)("input",{className:r,value:x.contractSettings.registrationNumber,onChange:e=>F("contractSettings",{registrationNumber:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Tax ID"}),(0,a.jsx)("input",{className:r,value:x.contractSettings.taxId,onChange:e=>F("contractSettings",{taxId:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Fuel policy type"}),(0,a.jsxs)("select",{className:r,value:x.contractSettings.fuelPolicyType,onChange:e=>F("contractSettings",{fuelPolicyType:e.target.value}),children:[(0,a.jsx)("option",{value:"FULL_TO_FULL",children:"FULL_TO_FULL"}),(0,a.jsx)("option",{value:"FULL_TO_EMPTY",children:"FULL_TO_EMPTY"}),(0,a.jsx)("option",{value:"SAME_TO_SAME",children:"SAME_TO_SAME"}),(0,a.jsx)("option",{value:"PREPAID",children:"PREPAID"}),(0,a.jsx)("option",{value:"FREE",children:"FREE"})]})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Late fee per hour"}),(0,a.jsx)("input",{className:r,type:"number",value:x.contractSettings.lateFeePerHour,onChange:e=>F("contractSettings",{lateFeePerHour:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Tax rate"}),(0,a.jsx)("input",{className:r,type:"number",step:"0.01",value:x.contractSettings.taxRate,onChange:e=>F("contractSettings",{taxRate:e.target.value})})]}),(0,a.jsxs)("label",{className:"flex items-center gap-3 pt-7 text-sm text-zinc-300",children:[(0,a.jsx)("input",{type:"checkbox",checked:x.contractSettings.signatureRequired,onChange:e=>F("contractSettings",{signatureRequired:e.target.checked})}),"Signature required"]}),(0,a.jsxs)("label",{className:"flex items-center gap-3 pt-7 text-sm text-zinc-300",children:[(0,a.jsx)("input",{type:"checkbox",checked:x.contractSettings.showTax,onChange:e=>F("contractSettings",{showTax:e.target.checked})}),"Show tax on documents"]}),(0,a.jsxs)("label",{className:"md:col-span-2",children:[(0,a.jsx)("span",{className:c,children:"Terms"}),(0,a.jsx)("textarea",{className:`${r} min-h-28`,value:x.contractSettings.terms,onChange:e=>F("contractSettings",{terms:e.target.value})})]})]}),(0,a.jsxs)("div",{className:"border-t border-zinc-800 pt-6",children:[(0,a.jsx)("h3",{className:"text-sm font-semibold text-zinc-200",children:"Accounting settings"}),(0,a.jsxs)("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Reporting period"}),(0,a.jsxs)("select",{className:r,value:x.accountingSettings.reportingPeriod,onChange:e=>F("accountingSettings",{reportingPeriod:e.target.value}),children:[(0,a.jsx)("option",{value:"WEEKLY",children:"WEEKLY"}),(0,a.jsx)("option",{value:"MONTHLY",children:"MONTHLY"}),(0,a.jsx)("option",{value:"QUARTERLY",children:"QUARTERLY"}),(0,a.jsx)("option",{value:"ANNUAL",children:"ANNUAL"})]})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Fiscal year start month"}),(0,a.jsx)("input",{className:r,type:"number",min:"1",max:"12",value:x.accountingSettings.fiscalYearStart,onChange:e=>F("accountingSettings",{fiscalYearStart:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Accounting currency"}),(0,a.jsxs)("select",{className:r,value:x.accountingSettings.currency,onChange:e=>F("accountingSettings",{currency:e.target.value}),children:[(0,a.jsx)("option",{value:"MAD",children:"MAD"}),(0,a.jsx)("option",{value:"USD",children:"USD"}),(0,a.jsx)("option",{value:"EUR",children:"EUR"})]})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Report format"}),(0,a.jsxs)("select",{className:r,value:x.accountingSettings.reportFormat,onChange:e=>F("accountingSettings",{reportFormat:e.target.value}),children:[(0,a.jsx)("option",{value:"PDF",children:"PDF"}),(0,a.jsx)("option",{value:"CSV",children:"CSV"}),(0,a.jsx)("option",{value:"BOTH",children:"BOTH"})]})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Accountant name"}),(0,a.jsx)("input",{className:r,value:x.accountingSettings.accountantName,onChange:e=>F("accountingSettings",{accountantName:e.target.value})})]}),(0,a.jsxs)("label",{children:[(0,a.jsx)("span",{className:c,children:"Accountant email"}),(0,a.jsx)("input",{className:r,type:"email",value:x.accountingSettings.accountantEmail,onChange:e=>F("accountingSettings",{accountantEmail:e.target.value})})]}),(0,a.jsxs)("label",{className:"flex items-center gap-3 pt-7 text-sm text-zinc-300",children:[(0,a.jsx)("input",{type:"checkbox",checked:x.accountingSettings.autoSendReport,onChange:e=>F("accountingSettings",{autoSendReport:e.target.checked})}),"Auto-send reports"]})]})]})]})]})]}),(0,a.jsxs)("div",{className:"grid gap-6 lg:grid-cols-2",children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"panel p-6 space-y-4",children:[(0,a.jsx)("h2",{className:"text-base font-semibold",children:"Company actions"}),(0,a.jsxs)("div",{className:"space-y-3",children:["SUSPENDED"===p.status?(0,a.jsx)("button",{onClick:()=>H("ACTIVE"),disabled:T,className:"w-full rounded-xl bg-emerald-900/40 py-2.5 text-sm font-semibold text-emerald-400 transition-colors hover:bg-emerald-900/60 disabled:opacity-50",children:"Reactivate company"}):(0,a.jsx)("button",{onClick:()=>H("SUSPENDED"),disabled:T,className:"w-full rounded-xl bg-red-950/40 py-2.5 text-sm font-semibold text-red-400 transition-colors hover:bg-red-950/60 disabled:opacity-50",children:"Suspend company"}),U?(0,a.jsxs)("div",{className:"space-y-3 rounded-xl border border-red-900/50 p-4",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-red-400",children:"This will permanently delete all company data. Are you sure?"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("button",{onClick:()=>_(!1),className:"flex-1 rounded-lg bg-zinc-800 py-2 text-sm text-zinc-300",children:"Cancel"}),(0,a.jsx)("button",{onClick:Y,disabled:T,className:"flex-1 rounded-lg bg-red-700 py-2 text-sm font-semibold text-white hover:bg-red-600 disabled:opacity-50",children:"Delete"})]})]}):(0,a.jsx)("button",{onClick:()=>_(!0),className:"w-full rounded-xl bg-zinc-800 py-2.5 text-sm font-semibold text-zinc-400 transition-colors hover:bg-zinc-700",children:"Delete company"})]})]}),p.subscription&&(0,a.jsxs)("div",{className:"panel p-6 space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h2",{className:"text-base font-semibold",children:"Subscription overrides"}),(0,a.jsx)("button",{onClick:()=>C(e=>!e),className:"text-xs text-zinc-400 hover:text-zinc-200",children:P?"Hide":"Show"})]}),P&&(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"text-xs font-medium uppercase tracking-wide text-zinc-500",children:"Reason (required)"}),(0,a.jsx)("input",{className:"mt-1 w-full rounded-xl border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-emerald-500",placeholder:"e.g. Customer requested extension…",value:f,onChange:e=>S(e.target.value)})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,a.jsx)("button",{onClick:()=>B("reactivate"),disabled:!!y,className:"rounded-lg bg-emerald-950/50 py-2 text-xs font-semibold text-emerald-400 hover:bg-emerald-900/50 disabled:opacity-50",children:"reactivate"===y?"…":"Reactivate"}),(0,a.jsx)("button",{onClick:()=>B("extend-grace-period"),disabled:!!y,className:"rounded-lg bg-sky-950/50 py-2 text-xs font-semibold text-sky-400 hover:bg-sky-900/50 disabled:opacity-50",children:"extend-grace-period"===y?"…":"+7d grace"}),(0,a.jsx)("button",{onClick:()=>B("suspend"),disabled:!!y,className:"rounded-lg bg-orange-950/50 py-2 text-xs font-semibold text-orange-400 hover:bg-orange-900/50 disabled:opacity-50",children:"suspend"===y?"…":"Suspend"}),(0,a.jsx)("button",{onClick:()=>B("cancel"),disabled:!!y,className:"rounded-lg bg-red-950/50 py-2 text-xs font-semibold text-red-400 hover:bg-red-900/50 disabled:opacity-50",children:"cancel"===y?"…":"Cancel"})]}),(0,a.jsxs)("p",{className:"text-xs text-zinc-600",children:["Retry count: ",p.subscription.retryCount??0," / 5"]})]})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[N.length>0&&(0,a.jsxs)("div",{className:"panel overflow-hidden",children:[(0,a.jsx)("div",{className:"border-b border-zinc-800 px-6 py-4",children:(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"Subscription timeline"})}),(0,a.jsx)("div",{className:"divide-y divide-zinc-800/60 max-h-72 overflow-y-auto",children:N.map(e=>(0,a.jsxs)("div",{className:"px-6 py-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-sky-400",children:e.eventType}),(0,a.jsx)("span",{className:"text-xs text-zinc-600",children:new Date(e.occurredAt).toLocaleString()})]}),(0,a.jsxs)("p",{className:"mt-0.5 text-xs text-zinc-500",children:["source: ",e.source]})]},e.id))})]}),g.length>0&&(0,a.jsxs)("div",{className:"panel overflow-hidden",children:[(0,a.jsx)("div",{className:"border-b border-zinc-800 px-6 py-4",children:(0,a.jsx)("h2",{className:"text-sm font-semibold",children:"Recent audit events"})}),(0,a.jsx)("div",{className:"divide-y divide-zinc-800/60",children:g.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between px-6 py-3 text-sm",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-medium text-zinc-200",children:e.action}),(0,a.jsx)("span",{className:"ml-2 text-zinc-500",children:e.resource}),e.adminUser?.email?(0,a.jsx)("span",{className:"ml-2 text-zinc-600",children:e.adminUser.email}):null]}),(0,a.jsx)("span",{className:"text-xs text-zinc-600",children:new Date(e.createdAt).toLocaleString()})]},e.id))})]})]})]})]})}])}]); |