PageSourceSearch

https://www.chargeops.net/assets/vehicle-brands-W_0Cqf2S.js

js chargeops.net collected 2026-10-02 02:04:11 UTC 13,964 bytes, 1 lines download raw bytes

1import{r as g,j as e}from"./vendor-react-QE7wLE3r.js";import{a as Ne,m as ve,y as ye,n as we,o as u,p,aX as z,J as b,I as m,E as o,G as H,O as U,b as n,bk as Y,X as L,aM as R,cD as O,T as Q,aN as W,aO as X,aP as q,aQ as G,aR as J,aS as Z,aT as $,r as ee,s as ae,t as te,v as se,w as S,h as ke,x as j}from"./index-C5UqyXey.js";import{u as f}from"./use-pending-mutation-DBZ9oGbA.js";import{e as re,T as le,a as D,d as h,b as ne,c as x}from"./table-DLWj1IjW.js";import{P as ie}from"./panel-head-D5BGwFto.js";import{P as ce}from"./pen-cFOdRlSF.js";import"./vendor-radix-C7HJG0re.js";import"./vendor-motion-DpnOviVe.js";function _e(){const{language:de}=Ne(),a=(t,r)=>ke(de,t,r),{toast:i}=ve(),{isPlatformAdmin:w}=ye(),N=we(u.vehicleConfig.queries.getBrandsWithModels)??[],[v,P]=g.useState(""),[l,y]=g.useState({name:"",brandId:"",year:new Date().getFullYear().toString(),batteryCapacityKwh:""}),[T,k]=g.useState(null),[F,E]=g.useState(""),[C,I]=g.useState(null),[c,V]=g.useState({name:"",year:"",batteryCapacityKwh:""}),[K,oe]=g.useState("all"),me=p(u.vehicleConfig.mutations.createBrand),he=p(u.vehicleConfig.mutations.updateBrand),xe=p(u.vehicleConfig.mutations.deleteBrand),ge=p(u.vehicleConfig.mutations.createModel),ue=p(u.vehicleConfig.mutations.updateModel),pe=p(u.vehicleConfig.mutations.deleteModel),M=f(async t=>{try{await me({name:t}),P(""),i({title:a("cfgVehicleBrandCreated"),description:a("cfgVehicleBrandCreatedDesc")})}catch(r){i({variant:"destructive",title:a("error"),description:j(r,"Failed to create vehicle brand.")})}}),A=f(async({id:t,name:r})=>{try{await he({id:t,name:r}),k(null),i({title:a("cfgVehicleBrandUpdated"),description:a("cfgVehicleBrandUpdatedDesc")})}catch(s){i({variant:"destructive",title:a("error"),description:j(s,"Failed to update vehicle brand.")})}}),be=f(async t=>{try{await xe({id:t}),i({title:a("cfgVehicleBrandDeleted"),description:a("cfgVehicleBrandDeletedDesc")})}catch(r){i({variant:"destructive",title:a("error"),description:j(r,"Failed to delete vehicle brand.")})}}),_=f(async t=>{try{await ge({...t,brandId:t.brandId}),y({name:"",brandId:"",year:new Date().getFullYear().toString(),batteryCapacityKwh:""}),i({title:a("cfgVehicleModelCreated"),description:a("cfgVehicleModelCreatedDesc")})}catch(r){i({variant:"destructive",title:a("error"),description:j(r,"Failed to create vehicle model.")})}}),je=f(async({id:t,name:r,year:s,batteryCapacityKwh:d})=>{try{await ue({id:t,name:r,year:s,batteryCapacityKwh:d}),I(null),i({title:a("cfgVehicleModelUpdated"),description:a("cfgVehicleModelUpdatedDesc")})}catch(B){i({variant:"destructive",title:a("error"),description:j(B,"Failed to update vehicle model.")})}}),fe=f(async t=>{try{await pe({id:t}),i({title:a("cfgVehicleModelDeleted"),description:a("cfgVehicleModelDeletedDesc")})}catch(r){i({variant:"destructive",title:a("error"),description:j(r,"Failed to delete vehicle model.")})}});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:n("p-6","co-card"),children:[e.jsx(ie,{icon:z,title:a("vehicleBrands")}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mb-6",children:a("cfgManageVehicleBrands")}),w&&e.jsxs("div",{className:"flex gap-4 mb-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(b,{htmlFor:"new-vehicle-brand-name",className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:a("cfgBrandName")}),e.jsx(m,{id:"new-vehicle-brand-name",value:v,onChange:t=>P(t.target.value),placeholder:a("cfgBrandNamePlaceholder"),className:"mt-1 rounded-lg border-slate-200 dark:border-slate-700",onKeyDown:t=>{t.key==="Enter"&&v.trim()&&M.mutate(v.trim())}})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs(o,{type:"button",onClick:()=>M.mutate(v.trim()),disabled:!v.trim()||M.isPending,className:n("settings-cta"),children:[M.isPending?e.jsx(H,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(U,{className:"h-4 w-4 mr-2"}),a("add")]})})]}),e.jsx("div",{className:n("overflow-hidden","co-card"),children:N.length===0?e.jsx("div",{className:"p-8 text-center text-slate-500 dark:text-slate-400",children:a("cfgNoVehicleBrands")}):e.jsxs(re,{children:[e.jsx(le,{children:e.jsxs(D,{className:"border-b-2 border-brand-100 dark:border-brand-900/40",children:[e.jsx(h,{className:n("font-semibold text-[11px] uppercase tracking-[0.14em] select-none","text-brand-700 dark:text-brand-300 bg-gradient-to-b from-brand-50/80 to-slate-50/60 dark:from-brand-950/40 dark:to-slate-900/40"),children:a("cfgBrandName")}),e.jsx(h,{className:n("font-semibold text-[11px] uppercase tracking-[0.14em] select-none text-center","text-brand-700 dark:text-brand-300 bg-gradient-to-b from-brand-50/80 to-slate-50/60 dark:from-brand-950/40 dark:to-slate-900/40"),children:a("cfgModelCount")}),e.jsx(h,{className:n("w-28 font-semibold text-[11px] uppercase tracking-[0.14em] select-none text-right","text-brand-700 dark:text-brand-300 bg-gradient-to-b from-brand-50/80 to-slate-50/60 dark:from-brand-950/40 dark:to-slate-900/40"),children:a("common.actions")})]})}),e.jsx(ne,{children:N.map(t=>e.jsxs(D,{className:n("co-row"),children:[e.jsx(x,{children:T===t._id?e.jsx(m,{value:F,onChange:r=>E(r.target.value),className:"h-8",onKeyDown:r=>{r.key==="Enter"?A.mutate({id:t._id,name:F}):r.key==="Escape"&&k(null)}}):e.jsx("span",{className:"font-medium",children:t.name})}),e.jsx(x,{className:"text-center",children:e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-brand-100 text-brand-800 dark:bg-brand-900 dark:text-brand-200",children:t.models?.length??0})}),e.jsx(x,{className:"text-right",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:w&&(T===t._id?e.jsxs(e.Fragment,{children:[e.jsx(o,{size:"sm",variant:"ghost",onClick:()=>A.mutate({id:t._id,name:F}),className:"text-green-500 hover:text-green-600 [@media(pointer:coarse)]:min-w-11",children:e.jsx(Y,{className:"h-4 w-4"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"[@media(pointer:coarse)]:min-w-11",onClick:()=>k(null),children:e.jsx(L,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(o,{size:"sm",variant:"ghost",className:"[@media(pointer:coarse)]:min-w-11",onClick:()=>{k(t._id),E(t.name)},"aria-label":a("configuration.ariaEditNamed",{name:t.name}),children:e.jsx(ce,{className:"h-4 w-4"})}),e.jsxs(R,{children:[e.jsx(O,{asChild:!0,children:e.jsx(o,{size:"sm",variant:"ghost",className:"text-red-500 hover:text-red-600 [@media(pointer:coarse)]:min-w-11","aria-label":a("configuration.ariaDeleteNamed",{name:t.name}),children:e.jsx(Q,{className:"h-4 w-4"})})}),e.jsxs(W,{children:[e.jsxs(X,{children:[e.jsx(q,{children:a("cfgDeleteVehicleBrand")}),e.jsx(G,{children:a("cfgDeleteConfirm",{name:t.name})})]}),e.jsxs(J,{children:[e.jsx(Z,{children:a("common.cancel")}),e.jsx($,{onClick:()=>be.mutate(t._id),variant:"destructive",children:a("common.delete")})]})]})]})]}))})})]},t._id))})]})})]}
1),e.jsxs("div",{className:n("p-6","co-card"),children:[e.jsx(ie,{icon:z,title:a("vehicleModels")}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mb-6",children:a("cfgManageVehicleModels")}),w&&e.jsxs("div",{className:"flex flex-col gap-4 mb-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(b,{htmlFor:"new-vehicle-model-brand",className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:a("cfgBrand")}),e.jsxs(ee,{value:l.brandId,onValueChange:t=>y({...l,brandId:t}),children:[e.jsx(ae,{className:"mt-1",children:e.jsx(te,{placeholder:a("cfgSelectBrand")})}),e.jsx(se,{children:N.map(t=>e.jsx(S,{value:t._id,children:t.name},t._id))})]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(b,{htmlFor:"new-vehicle-model-name",className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:a("cfgModelName")}),e.jsx(m,{id:"new-vehicle-model-name",value:l.name,onChange:t=>y({...l,name:t.target.value}),placeholder:a("cfgModelNamePlaceholder"),className:"mt-1 rounded-lg border-slate-200 dark:border-slate-700"})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(b,{htmlFor:"new-vehicle-model-year",className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:a("cfgYear")}),e.jsx(m,{id:"new-vehicle-model-year",type:"number",value:l.year,onChange:t=>y({...l,year:t.target.value}),placeholder:"2024",className:"mt-1 rounded-lg border-slate-200 dark:border-slate-700"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(b,{htmlFor:"new-vehicle-model-battery",className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:a("cfgBatteryCapacity")}),e.jsx(m,{id:"new-vehicle-model-battery",type:"number",value:l.batteryCapacityKwh,onChange:t=>y({...l,batteryCapacityKwh:t.target.value}),placeholder:"75",className:"mt-1 rounded-lg border-slate-200 dark:border-slate-700"})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs(o,{type:"button",onClick:()=>{!l.name.trim()||!l.brandId||!l.year||!l.batteryCapacityKwh||_.mutate({name:l.name.trim(),brandId:l.brandId,year:parseInt(l.year),batteryCapacityKwh:parseFloat(l.batteryCapacityKwh)})},disabled:!l.name.trim()||!l.brandId||!l.year||!l.batteryCapacityKwh||_.isPending,className:n("settings-cta"),children:[_.isPending?e.jsx(H,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(U,{className:"h-4 w-4 mr-2"}),a("add")]})})]})]}),e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(b,{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:a("cfgFilterByBrand")}),e.jsxs(ee,{value:K,onValueChange:oe,children:[e.jsx(ae,{className:"w-52",children:e.jsx(te,{})}),e.jsxs(se,{children:[e.jsx(S,{value:"all",children:a("cfgAllBrands")}),N.map(t=>e.jsx(S,{value:t._id,children:t.name},t._id))]})]})]}),e.jsx("div",{className:n("overflow-hidden","co-card"),children:(()=>{const t=N.flatMap(s=>(s.models||[]).map(d=>({...d,brandName:s.name,brandId:s._id}))),r=K==="all"?t:t.filter(s=>s.brandId===K);return r.length===0?e.jsx("div",{className:"p-8 text-center text-slate-500 dark:text-slate-400",children:a("cfgNoVehicleModels")}):e.jsxs(re,{children:[e.jsx(le,{children:e.jsxs(D,{className:"border-b-2 border-brand-100 dark:border-brand-900/40",children:[e.jsx(h,{className:n("font-semibold text-[11px] uppercase tracking-[0.14em] select-none","text-brand-700 dark:text-brand-300 bg-gradient-to-b from-brand-50/80 to-slate-50/60 dark:from-brand-950/40 dark:to-slate-900/40"),children:a("cfgBrand")}),e.jsx(h,{className:n("font-semibold text-[11px] uppercase tracking-[0.14em] select-none","text-brand-700 dark:text-brand-300 bg-gradient-to-b from-brand-50/80 to-slate-50/60 dark:from-brand-950/40 dark:to-slate-900/40"),children:a("cfgModelName")}),e.jsx(h,{className:n("font-semibold text-[11px] uppercase tracking-[0.14em] select-none text-center","text-brand-700 dark:text-brand-300 bg-gradient-to-b from-brand-50/80 to-slate-50/60 dark:from-brand-950/40 dark:to-slate-900/40"),children:a("cfgYear")}),e.jsx(h,{className:n("font-semibold text-[11px] uppercase tracking-[0.14em] select-none text-center","text-brand-700 dark:text-brand-300 bg-gradient-to-b from-brand-50/80 to-slate-50/60 dark:from-brand-950/40 dark:to-slate-900/40"),children:a("cfgBatteryKwh")}),e.jsx(h,{className:n("w-28 font-semibold text-[11px] uppercase tracking-[0.14em] select-none text-right","text-brand-700 dark:text-brand-300 bg-gradient-to-b from-brand-50/80 to-slate-50/60 dark:from-brand-950/40 dark:to-slate-900/40"),children:a("common.actions")})]})}),e.jsx(ne,{children:r.map(s=>e.jsxs(D,{className:n("co-row"),children:[e.jsx(x,{children:e.jsx("span",{className:"text-slate-600 dar
1k:text-slate-400",children:s.brandName})}),e.jsx(x,{children:C===s._id?e.jsx(m,{value:c.name,onChange:d=>V({...c,name:d.target.value}),className:"h-8"}):e.jsx("span",{className:"font-medium",children:s.name})}),e.jsx(x,{className:"text-center",children:C===s._id?e.jsx(m,{type:"number",value:c.year,onChange:d=>V({...c,year:d.target.value}),className:"h-8 w-20 mx-auto"}):e.jsx("span",{children:s.year})}),e.jsx(x,{className:"text-center",children:C===s._id?e.jsx(m,{type:"number",value:c.batteryCapacityKwh,onChange:d=>V({...c,batteryCapacityKwh:d.target.value}),className:"h-8 w-20 mx-auto"}):e.jsx("span",{children:s.batteryCapacityKwh})}),e.jsx(x,{className:"text-right",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:w&&(C===s._id?e.jsxs(e.Fragment,{children:[e.jsx(o,{size:"sm",variant:"ghost",onClick:()=>{const d=parseInt(c.year),B=parseFloat(c.batteryCapacityKwh);Number.isNaN(d)||Number.isNaN(B)||je.mutate({id:s._id,name:c.name,year:d,batteryCapacityKwh:B})},disabled:!c.name||!c.year||!c.batteryCapacityKwh,className:"text-green-500 hover:text-green-600 [@media(pointer:coarse)]:min-w-11",children:e.jsx(Y,{className:"h-4 w-4"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"[@media(pointer:coarse)]:min-w-11",onClick:()=>I(null),children:e.jsx(L,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(o,{size:"sm",variant:"ghost",className:"[@media(pointer:coarse)]:min-w-11",onClick:()=>{I(s._id),V({name:s.name,year:String(s.year),batteryCapacityKwh:String(s.batteryCapacityKwh)})},"aria-label":a("configuration.ariaEditNamed",{name:s.name}),children:e.jsx(ce,{className:"h-4 w-4"})}),e.jsxs(R,{children:[e.jsx(O,{asChild:!0,children:e.jsx(o,{size:"sm",variant:"ghost",className:"text-red-500 hover:text-red-600 [@media(pointer:coarse)]:min-w-11","aria-label":a("configuration.ariaDeleteNamed",{name:s.name}),children:e.jsx(Q,{className:"h-4 w-4"})})}),e.jsxs(W,{children:[e.jsxs(X,{children:[e.jsx(q,{children:a("cfgDeleteVehicleModel")}),e.jsx(G,{children:a("cfgDeleteConfirm",{name:s.name})})]}),e.jsxs(J,{children:[e.jsx(Z,{children:a("common.cancel")}),e.jsx($,{onClick:()=>fe.mutate(s._id),variant:"destructive",children:a("common.delete")})]})]})]})]}))})})]},s._id))})]})})()})]})]})}export{_e as VehicleBrandsSection};

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.