PageSourceSearch

https://joinsafqa.com/assets/cartarm.lazy-CyKYVMLq.js

js joinsafqa.com collected 2026-10-02 00:07:25 UTC 6,213 bytes, 1 lines download raw bytes

1import{j as s,aB as U,t as G,aU as p,v as i,N as j,b8 as H,w as J,x as Q,r as u,ba as c,F as W,S as y,ap as F,c as X}from"./index-cX9jsT0G.js";import{c as Y,u as Z,F as ee,A as S,a as se,b as re,O as oe}from"./FormValidationErrors-eSoEOhON.js";import{A as te}from"./admin-page-meta-CH_SoSC8.js";import{p as ae}from"./admin-duplicate-CR-NzMlg.js";import{u as ne}from"./useFilters-PGxC6fuF.js";import{D as le}from"./OmniTable-CtlDWuCb.js";import{R as ie,C as pe}from"./RelationshipMultiSelectField-B_Fatnl5.js";import{d as ce}from"./relationship-entities-CzHD2Spe.js";import{T as me}from"./fuse-B6-COWXi.js";import"./AdminPageHeader-B8WdE8FZ.js";import"./loader-circle-59JFk-e4.js";import"./omnitable-query-DH7U7xhT.js";import"./sdk-error-BQUOss77.js";import"./AdminEmptyState-CGN1MuTg.js";import"./table-CN1-DWJZ.js";import"./copy-CSkVImnd.js";import"./popover-DGnuMGhC.js";import"./index.module-CJMJGQSL.js";import"./rotate-ccw-Cft5xEsU.js";import"./chevron-down-CZjdfAd0.js";import"./check-Ygepfp4U.js";const de=(o,l)=>[{header:"key",accessorKey:"key",enableFiltering:!0,mobileLabel:"Rule key"},{header:"shops",accessorKey:"shops",minBreakpoint:"md",mobileLabel:"Associated shops",cell:({row:r})=>{const a=r?.original?.shops;return s.jsx("div",{className:"flex max-w-md flex-wrap gap-1",children:a?.map(e=>s.jsx(U,{variant:"secondary",children:e.name_en},e.id))})}},{id:"actions",cell:({row:r})=>s.jsx(le,{row:r,onEdit:o,onDelete:l}),size:50}],ue=({form:o,isLoading:l})=>s.jsx(ie,{form:o,name:"shopIDs",label:"Shops",placeholder:"Select shops",config:ce,disabled:l,maxCount:1}),g=G({key:i(),shopIDs:p(i()),input:p(i()),apply:p(i()),remove:p(i()),toggle:p(i()),spinner:p(i()),error:p(i()),success:p(i()),applied:p(i())}),A={key:"",shopIDs:[],input:[],apply:[],remove:[],toggle:[],spinner:[],error:[],success:[],applied:[]},m=({title:o,fields:l,name:r,form:a,append:e,remove:d})=>s.jsxs("div",{className:`space-y-3 rounded-md border border-border p-4 ${Y}`,children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h4",{className:"text-sm font-medium",children:o}),s.jsxs(j,{type:"button",variant:"outline",size:"sm",onClick:()=>e(""),children:[s.jsx(pe,{className:"mr-2 h-4 w-4"}),"Add selector"]})]}),s.jsxs("div",{className:"space-y-2",children:[l.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No selectors added yet."}):null,l.map((t,n)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"w-6 shrink-0 text-right text-xs text-muted-foreground tabular-nums",children:[n+1,"."]}),s.jsx(H,{name:`${r}.${n}`,control:a.control,render:({field:f})=>s.jsx("input",{className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",placeholder:`Enter ${o.toLowerCase()}`,"aria-label":`${o} ${n+1}`,...f})}),s.jsx(j,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(n),"aria-label":`Remove ${o} ${n+1}`,children:s.jsx(me,{className:"h-4 w-4"})})]},t.id))]}),a.formState.errors[r]&&typeof a.formState.errors[r]=="object"&&a.formState.errors[r]!==null&&"root"in a.formState.errors[r]?s.jsx("p",{className:"text-sm text-destructive",children:a.formState.errors[r].root?.message}):null]});function fe({initialData:o,onSubmit:l,duplicateItem:r,onFormStateChange:a}){const e=J({resolver:Q(g),defaultValues:o||A});Z(e,a),u.useEffect(()=>(e.reset(o),()=>{e.reset()}),[o,e]),u.useEffect(()=>{if(r){const O=Object.keys(g.shape).reduce((b,x)=>(x in r&&x in g.shape&&(b[x]=r[x]),b),{});e.reset(O),requestAnimationFrame(()=>e.setFocus("key"))}},[r,e]);const{fields:d,append:t,remove:n}=c({control:e.control,name:"input"}),{fields:f,append:h,remove:C}=c({control:e.control,name:"apply"}),{fields:k,append:N,remove:R}=c({control:e.control,name:"remove"}),{fields:D,append:w,remove:E}=c({control:e.control,name:"toggle"}),{fields:L,append:T,remove:_}=c({control:e.control,name:"spinner"}),{fields:I,append:$,remove:M}=c({control:e.control,name:"error"}),{fields:K,append:P,remove:V}=c({control:e.control,name:"success"}),{fields:q,append:z,remove:B}=c({control:e.control,name:"applied"});return s.jsx(W,{...e,children:s.jsxs("form",{id:"omni-admin-form",onSubmit:re(e,l),className:"space-y-6",children:[s.jsx(ee,{form:e}),s.jsxs(S,{title:"Identity",description:"Rule key and shops where this CartArm configuration applies.",children:[s.jsx(se,{form:e,schema:g,isLoading:!1,label:"Key",name:"key",required:!0,message:"Unique identifier for this rule set."}),s.jsx(ue,{form:e,isLoading:!1})]}),s.jsxs(S,{title:"Selector groups",description:"CSS selectors used at each stage of the coupon application flow.",children:[s.jsx(m,{title:"Input selectors",fields:d,name:"input",form:e,append:t,remove:n}),s.jsx(m,{title:"Apply selectors",fields:f,name:"apply",form:e,append:h,remove:C}),s.jsx(m,{title:"Remove selectors",fields:k,name:"remove",form:e,append:N,remove:R}),s.jsx(m,{title:"Toggle selectors",fields:D,name:"toggle",form:e,append:w,remove:E}),s.jsx(m,{title:"Spinner selectors",fields:L,name:"spinner",form:e,append:T,remove:_}),s.jsx(m,{title:"Error selectors",fields:I,name:"error",form:e,append:$,remove:M}),s.jsx(m,{title:"Success selectors",fields:K,name:"success",form:e,append:P,remove:V}),s.jsx(m,{title:"Applied selectors",fields:q,name:"applied",form:e,append:z,remove:B})]})]})})}const v=te.cartarm,xe=()=>{const o=async t=>{const n=await y.cartarm.softDelete(t.id);if(!n.success){const h=n.error?.response?.data;return F.error(h?.message??"Failed to delete rule"),!1}return F.success(`CartArm rule "${t.key}" deleted`),!0},l=u.useCallback(t=>de(t.onEdit,t.onDelete),[]),r=u.useCallback(t=>ae(t,["key"]),[]),{filters:a,setFilters:e}=ne("/_admin_protected/admin/cartarm"),d=u.useCallback((t,n)=>Promise.resolve(e(t,n)),[e]);return s.jsx(oe,{buildColumns:l,filters:a,onDelete:o,setFilters:d,module:y.cartarm,FormComponent:fe,defaultValues:A,onPrepareDuplicate:r,entityLabel:v.entityLabel,pageTitle:v.title,pageDescription:v.description,tableKey:"cartarm"})},Me=X("/_admin_protected/admin/cartarm")({component:xe});export{Me as Route};

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.