@nextblock-cms/ecom 0.12.16 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/CustomerProfileForm.cjs.js +1 -1
- package/lib/components/CustomerProfileForm.d.ts +5 -1
- package/lib/components/CustomerProfileForm.es.js +112 -108
- package/lib/pages/cms/products/server-actions.cjs.js +1 -1
- package/lib/pages/cms/products/server-actions.d.ts +10 -0
- package/lib/pages/cms/products/server-actions.es.js +65 -49
- package/package.json +4 -4
- package/server.cjs.js +1 -1
- package/server.d.ts +1 -1
- package/server.es.js +59 -58
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("react"),V=require("react-hook-form"),X=require("./AccountNavigationMenu.cjs.js"),w=require("@nextblock-cms/ui/avatar"),z=require("@nextblock-cms/ui/button"),d=require("@nextblock-cms/ui/card"),W=require("@nextblock-cms/ui/checkbox"),t=require("@nextblock-cms/ui/input"),n=require("@nextblock-cms/ui/label"),o=require("@nextblock-cms/ui/select"),H=require("@nextblock-cms/ui/separator"),M=require("../server-actions/customer-actions.cjs.js"),f=require("../customer.cjs.js"),O=require("@nextblock-cms/db"),N=require("lucide-react"),R=require("@nextblock-cms/utils"),q=require("../countries.cjs.js");function G(s){return s?s.startsWith("http")?s:process.env.NEXT_PUBLIC_R2_BASE_URL?`${process.env.NEXT_PUBLIC_R2_BASE_URL}/${s}`:process.env.NEXT_PUBLIC_SUPABASE_URL?`${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${s}`:s:null}function C(s){return{company_name:s?.company_name||"",recipient_name:s?.recipient_name||"",line1:s?.line1||"",line2:s?.line2||"",city:s?.city||"",state:s?.state||"",postal_code:s?.postal_code||"",country_code:q.normalizeCountryCode(s?.country_code)||"CA"}}function U({prefix:s,title:h,register:c}){const{t:a}=R.useTranslations(),v=a("company_name")==="company_name"?"Company name":a("company_name");return e.jsxs("div",{className:"space-y-4 rounded-xl border p-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:h}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("profile_address_defaults_help")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-company_name`,children:v}),e.jsx(t.Input,{id:`${s}-company_name`,...c(`${s}.company_name`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-recipient_name`,children:a("full_name")}),e.jsx(t.Input,{id:`${s}-recipient_name`,...c(`${s}.recipient_name`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-country_code`,children:a("country")}),e.jsx("select",{id:`${s}-country_code`,className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",...c(`${s}.country_code`),children:q.countries.map(m=>e.jsx("option",{value:m.code,children:m.name},m.code))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-line1`,children:a("address_line_1")}),e.jsx(t.Input,{id:`${s}-line1`,...c(`${s}.line1`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-line2`,children:a("address_line_2")}),e.jsx(t.Input,{id:`${s}-line2`,...c(`${s}.line2`)})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-city`,children:a("city")}),e.jsx(t.Input,{id:`${s}-city`,...c(`${s}.city`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-state`,children:a("state_province")}),e.jsx(t.Input,{id:`${s}-state`,...c(`${s}.state`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-postal_code`,children:a("postal_zip_code")}),e.jsx(t.Input,{id:`${s}-postal_code`,...c(`${s}.postal_code`)})]})]})]})}function J({initialData:s,MediaPickerComponent:h,isAdmin:c,email:a,accountLinks:v,onAction:m,initialSuccessMessage:_}){const{t:l}=R.useTranslations(),[L,S]=b.useState(!1),[$,y]=b.useState(_?{type:"success",text:_}:null),T=s?.use_billing_for_shipping??(!s?.shipping_address||f.addressesMatch(s?.billing_address,s?.shipping_address)),{register:u,handleSubmit:B,setValue:x,getValues:F,watch:g,reset:I}=V.useForm({defaultValues:{full_name:s?.full_name||"",avatar_url:s?.avatar_url||"",website:s?.website||"",phone:s?.phone||"",role:s?.role,use_billing_for_shipping:T,billing_address:C(s?.billing_address),shipping_address:C(s?.shipping_address)}});b.useEffect(()=>{s&&I({full_name:s.full_name||"",avatar_url:s.avatar_url||"",website:s.website||"",phone:s.phone||"",role:s.role,use_billing_for_shipping:s.use_billing_for_shipping??(!s.shipping_address||f.addressesMatch(s.billing_address,s.shipping_address)),billing_address:C(s.billing_address),shipping_address:C(s.shipping_address)})},[s,I]),b.useEffect(()=>{_&&y({type:"success",text:_})},[_]),b.useEffect(()=>{const r=O.createClient();(async()=>{const{data:{user:j}}=await r.auth.getUser();j&&!F("full_name")&&j.user_metadata?.full_name&&x("full_name",j.user_metadata.full_name)})()},[F,x]);const k=r=>{const p=G(r?.object_key??r?.file_path);p&&x("avatar_url",p)},P=async r=>{S(!0),y(null);const p=f.normalizeCustomerAddress(r.billing_address)??f.emptyCustomerAddress(),j=r.use_billing_for_shipping?p:f.normalizeCustomerAddress(r.shipping_address);try{const i={...r,billing_address:p,shipping_address:j};if(m){const E=await m(i);if(E?.error)throw new Error(E.error)}else await M.updateProfile(i);y({type:"success",text:l("profile_updated_success")})}catch(i){if(i.message==="NEXT_REDIRECT"||i.message?.includes("NEXT_REDIRECT"))return;console.error(i),y({type:"error",text:i.message||l("profile_update_failed")})}finally{S(!1)}},A=g("use_billing_for_shipping");return e.jsxs("div",{className:"grid gap-6 md:grid-cols-12 max-w-5xl mx-auto",children:[e.jsxs(d.Card,{className:"md:col-span-4 h-fit",children:[e.jsx(d.CardHeader,{children:e.jsx(d.CardTitle,{className:"text-xl",children:l("public_profile")})}),e.jsxs(d.CardContent,{className:"flex flex-col items-center text-center space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs(w.Avatar,{className:"h-32 w-32 border-4 border-muted",children:[e.jsx(w.AvatarImage,{src:g("avatar_url")||void 0,className:"object-cover"}),e.jsx(w.AvatarFallback,{className:"text-4xl bg-secondary",children:g("full_name")?.charAt(0)?.toUpperCase()||e.jsx(N.User,{className:"h-12 w-12"})})]}),h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/40 rounded-full cursor-pointer",children:e.jsx(h,{triggerLabel:e.jsx(N.Upload,{className:"h-6 w-6 text-white"}),triggerVariant:"ghost",title:l("customer_profile"),onSelect:k,accept:r=>r.file_type.startsWith("image/"),hideTrigger:!1})})]}),!h&&e.jsxs("div",{className:"w-full",children:[e.jsx(n.Label,{htmlFor:"avatar_url",className:"sr-only",children:l("avatar_url")}),e.jsx(t.Input,{id:"avatar_url",...u("avatar_url"),placeholder:"https://...",className:"mt-2"})]}),e.jsxs("div",{className:"w-full space-y-1 text-left mt-4",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:l("identity")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-semibold text-lg",children:g("full_name")||l("full_name")})})]}),v?.length?e.jsx(X.AccountNavigationMenu,{links:v,className:"mt-2 text-left"}):null]})]}),e.jsx(d.Card,{className:"md:col-span-8",children:e.jsxs("form",{onSubmit:B(P),children:[e.jsx(d.CardHeader,{children:e.jsx(d.CardTitle,{children:l("details")})}),e.jsxs(d.CardContent,{className:"space-y-6",children:[a&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(n.Label,{htmlFor:"email",children:[l("email")||"Email"," (Read-only)"]}),e.jsx(t.Input,{id:"email",value:a,readOnly:!0,disabled:!0,className:"bg-muted/50"})]}),e.jsx("div",{className:"rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground",children:l("profile_basic_info_help")}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(n.Label,{htmlFor:"full_name",className:"flex items-center gap-2",children:[e.jsx(N.User,{className:"h-4 w-4"})," ",l("full_name")]}),e.jsx(t.Input,{id:"full_name",...u("full_name")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(n.Label,{htmlFor:"phone",className:"flex items-center gap-2",children:[e.jsx(N.Phone,{className:"h-4 w-4"})," ",l("phone_number")]}),e.jsx(t.Input,{id:"phone",...u("phone")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(n.Label,{htmlFor:"website",className:"flex items-center gap-2",children:[e.jsx(N.Globe,{className:"h-4 w-4"})," ",l("website")]}),e.jsx(t.Input,{id:"website",...u("website"),placeholder:"https://example.com"})]}),e.jsx(H.Separator,{className:"my-2"}),e.jsx(U,{prefix:"billing_address",title:l("billing_address"),register:u}),e.jsxs("div",{className:"flex items-center space-x-3 rounded-lg border p-4",children:[e.jsx(W.Checkbox,{id:"use_billing_for_shipping",checked:!!A,onCheckedChange:r=>x("use_billing_for_shipping",!!r,{shouldDirty:!0})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(n.Label,{htmlFor:"use_billing_for_shipping",className:"cursor-pointer",children:l("use_billing_for_shipping")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("profile_use_billing_for_shipping_help")})]})]}),!A&&e.jsx(U,{prefix:"shipping_address",title:l("shipping_address"),register:u}),$&&e.jsx("div",{className:`mt-4 rounded-xl border p-4 text-sm ${$.type==="success"?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-red-200 bg-red-50 text-red-700"}`,children:$.text}),c&&e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Admin Settings"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(n.Label,{htmlFor:"role",children:"Role"}),e.jsxs(o.Select,{value:g("role")||"USER",onValueChange:r=>x("role",r),children:[e.jsx(o.SelectTrigger,{children:e.jsx(o.SelectValue,{placeholder:"Select role"})}),e.jsxs(o.SelectContent,{children:[e.jsx(o.SelectItem,{value:"USER",children:"User"}),e.jsx(o.SelectItem,{value:"WRITER",children:"Writer"}),e.jsx(o.SelectItem,{value:"ADMIN",children:"Admin"})]})]})]})]})]}),e.jsx(d.CardFooter,{className:"flex justify-end",children:e.jsx(z.Button,{type:"submit",disabled:L,size:"lg",children:l(L?"saving":"save_changes")})})]})})]})}exports.CustomerProfileForm=J;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("react"),z=require("react-hook-form"),W=require("./AccountNavigationMenu.cjs.js"),w=require("@nextblock-cms/ui/avatar"),H=require("@nextblock-cms/ui/button"),d=require("@nextblock-cms/ui/card"),M=require("@nextblock-cms/ui/checkbox"),a=require("@nextblock-cms/ui/input"),n=require("@nextblock-cms/ui/label"),o=require("@nextblock-cms/ui/select"),O=require("@nextblock-cms/ui/separator"),G=require("../server-actions/customer-actions.cjs.js"),f=require("../customer.cjs.js"),J=require("@nextblock-cms/db"),N=require("lucide-react"),R=require("@nextblock-cms/utils"),T=require("../countries.cjs.js");function K(s){return s?s.startsWith("http")?s:process.env.NEXT_PUBLIC_R2_BASE_URL?`${process.env.NEXT_PUBLIC_R2_BASE_URL}/${s}`:process.env.NEXT_PUBLIC_SUPABASE_URL?`${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${s}`:s:null}function C(s){return{company_name:s?.company_name||"",recipient_name:s?.recipient_name||"",line1:s?.line1||"",line2:s?.line2||"",city:s?.city||"",state:s?.state||"",postal_code:s?.postal_code||"",country_code:T.normalizeCountryCode(s?.country_code)||"CA"}}function q({prefix:s,title:p,register:c}){const{t}=R.useTranslations(),y=t("company_name")==="company_name"?"Company name":t("company_name");return e.jsxs("div",{className:"space-y-4 rounded-xl border p-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:p}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("profile_address_defaults_help")})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-company_name`,children:y}),e.jsx(a.Input,{id:`${s}-company_name`,...c(`${s}.company_name`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-recipient_name`,children:t("full_name")}),e.jsx(a.Input,{id:`${s}-recipient_name`,...c(`${s}.recipient_name`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-country_code`,children:t("country")}),e.jsx("select",{id:`${s}-country_code`,className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",...c(`${s}.country_code`),children:T.countries.map(m=>e.jsx("option",{value:m.code,children:m.name},m.code))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-line1`,children:t("address_line_1")}),e.jsx(a.Input,{id:`${s}-line1`,...c(`${s}.line1`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-line2`,children:t("address_line_2")}),e.jsx(a.Input,{id:`${s}-line2`,...c(`${s}.line2`)})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-city`,children:t("city")}),e.jsx(a.Input,{id:`${s}-city`,...c(`${s}.city`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-state`,children:t("state_province")}),e.jsx(a.Input,{id:`${s}-state`,...c(`${s}.state`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(n.Label,{htmlFor:`${s}-postal_code`,children:t("postal_zip_code")}),e.jsx(a.Input,{id:`${s}-postal_code`,...c(`${s}.postal_code`)})]})]})]})}function Q({initialData:s,MediaPickerComponent:p,isAdmin:c,email:t,accountLinks:y,onAction:m,initialSuccessMessage:_,lockRole:A,lockRoleReason:B}){const{t:l}=R.useTranslations(),[L,S]=b.useState(!1),[$,v]=b.useState(_?{type:"success",text:_}:null),P=s?.use_billing_for_shipping??(!s?.shipping_address||f.addressesMatch(s?.billing_address,s?.shipping_address)),{register:u,handleSubmit:k,setValue:x,getValues:F,watch:g,reset:I}=z.useForm({defaultValues:{full_name:s?.full_name||"",avatar_url:s?.avatar_url||"",website:s?.website||"",phone:s?.phone||"",role:s?.role,use_billing_for_shipping:P,billing_address:C(s?.billing_address),shipping_address:C(s?.shipping_address)}});b.useEffect(()=>{s&&I({full_name:s.full_name||"",avatar_url:s.avatar_url||"",website:s.website||"",phone:s.phone||"",role:s.role,use_billing_for_shipping:s.use_billing_for_shipping??(!s.shipping_address||f.addressesMatch(s.billing_address,s.shipping_address)),billing_address:C(s.billing_address),shipping_address:C(s.shipping_address)})},[s,I]),b.useEffect(()=>{_&&v({type:"success",text:_})},[_]),b.useEffect(()=>{const r=J.createClient();(async()=>{const{data:{user:j}}=await r.auth.getUser();j&&!F("full_name")&&j.user_metadata?.full_name&&x("full_name",j.user_metadata.full_name)})()},[F,x]);const V=r=>{const h=K(r?.object_key??r?.file_path);h&&x("avatar_url",h)},X=async r=>{S(!0),v(null);const h=f.normalizeCustomerAddress(r.billing_address)??f.emptyCustomerAddress(),j=r.use_billing_for_shipping?h:f.normalizeCustomerAddress(r.shipping_address);try{const i={...r,billing_address:h,shipping_address:j};if(m){const U=await m(i);if(U?.error)throw new Error(U.error)}else await G.updateProfile(i);v({type:"success",text:l("profile_updated_success")})}catch(i){if(i.message==="NEXT_REDIRECT"||i.message?.includes("NEXT_REDIRECT"))return;console.error(i),v({type:"error",text:i.message||l("profile_update_failed")})}finally{S(!1)}},E=g("use_billing_for_shipping");return e.jsxs("div",{className:"grid gap-6 md:grid-cols-12 max-w-5xl mx-auto",children:[e.jsxs(d.Card,{className:"md:col-span-4 h-fit",children:[e.jsx(d.CardHeader,{children:e.jsx(d.CardTitle,{className:"text-xl",children:l("public_profile")})}),e.jsxs(d.CardContent,{className:"flex flex-col items-center text-center space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs(w.Avatar,{className:"h-32 w-32 border-4 border-muted",children:[e.jsx(w.AvatarImage,{src:g("avatar_url")||void 0,className:"object-cover"}),e.jsx(w.AvatarFallback,{className:"text-4xl bg-secondary",children:g("full_name")?.charAt(0)?.toUpperCase()||e.jsx(N.User,{className:"h-12 w-12"})})]}),p&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/40 rounded-full cursor-pointer",children:e.jsx(p,{triggerLabel:e.jsx(N.Upload,{className:"h-6 w-6 text-white"}),triggerVariant:"ghost",title:l("customer_profile"),onSelect:V,accept:r=>r.file_type.startsWith("image/"),hideTrigger:!1})})]}),!p&&e.jsxs("div",{className:"w-full",children:[e.jsx(n.Label,{htmlFor:"avatar_url",className:"sr-only",children:l("avatar_url")}),e.jsx(a.Input,{id:"avatar_url",...u("avatar_url"),placeholder:"https://...",className:"mt-2"})]}),e.jsxs("div",{className:"w-full space-y-1 text-left mt-4",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:l("identity")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"font-semibold text-lg",children:g("full_name")||l("full_name")})})]}),y?.length?e.jsx(W.AccountNavigationMenu,{links:y,className:"mt-2 text-left"}):null]})]}),e.jsx(d.Card,{className:"md:col-span-8",children:e.jsxs("form",{onSubmit:k(X),children:[e.jsx(d.CardHeader,{children:e.jsx(d.CardTitle,{children:l("details")})}),e.jsxs(d.CardContent,{className:"space-y-6",children:[t&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(n.Label,{htmlFor:"email",children:[l("email")||"Email"," (Read-only)"]}),e.jsx(a.Input,{id:"email",value:t,readOnly:!0,disabled:!0,className:"bg-muted/50"})]}),e.jsx("div",{className:"rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground",children:l("profile_basic_info_help")}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(n.Label,{htmlFor:"full_name",className:"flex items-center gap-2",children:[e.jsx(N.User,{className:"h-4 w-4"})," ",l("full_name")]}),e.jsx(a.Input,{id:"full_name",...u("full_name")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(n.Label,{htmlFor:"phone",className:"flex items-center gap-2",children:[e.jsx(N.Phone,{className:"h-4 w-4"})," ",l("phone_number")]}),e.jsx(a.Input,{id:"phone",...u("phone")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(n.Label,{htmlFor:"website",className:"flex items-center gap-2",children:[e.jsx(N.Globe,{className:"h-4 w-4"})," ",l("website")]}),e.jsx(a.Input,{id:"website",...u("website"),placeholder:"https://example.com"})]}),e.jsx(O.Separator,{className:"my-2"}),e.jsx(q,{prefix:"billing_address",title:l("billing_address"),register:u}),e.jsxs("div",{className:"flex items-center space-x-3 rounded-lg border p-4",children:[e.jsx(M.Checkbox,{id:"use_billing_for_shipping",checked:!!E,onCheckedChange:r=>x("use_billing_for_shipping",!!r,{shouldDirty:!0})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(n.Label,{htmlFor:"use_billing_for_shipping",className:"cursor-pointer",children:l("use_billing_for_shipping")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:l("profile_use_billing_for_shipping_help")})]})]}),!E&&e.jsx(q,{prefix:"shipping_address",title:l("shipping_address"),register:u}),$&&e.jsx("div",{className:`mt-4 rounded-xl border p-4 text-sm ${$.type==="success"?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-red-200 bg-red-50 text-red-700"}`,children:$.text}),c&&e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Admin Settings"}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(n.Label,{htmlFor:"role",children:"Role"}),e.jsxs(o.Select,{value:g("role")||"USER",onValueChange:r=>x("role",r),disabled:A,children:[e.jsx(o.SelectTrigger,{children:e.jsx(o.SelectValue,{placeholder:"Select role"})}),e.jsxs(o.SelectContent,{children:[e.jsx(o.SelectItem,{value:"USER",children:"User"}),e.jsx(o.SelectItem,{value:"WRITER",children:"Writer"}),e.jsx(o.SelectItem,{value:"ADMIN",children:"Admin"})]})]}),A&&e.jsx("p",{className:"text-xs text-muted-foreground",children:B||"This is the only Admin account, so its role can't be changed. Promote another user to Admin first."})]})]})]}),e.jsx(d.CardFooter,{className:"flex justify-end",children:e.jsx(H.Button,{type:"submit",disabled:L,size:"lg",children:l(L?"saving":"save_changes")})})]})})]})}exports.CustomerProfileForm=Q;
|
|
@@ -16,6 +16,10 @@ interface CustomerProfileFormProps {
|
|
|
16
16
|
error?: string;
|
|
17
17
|
} | void>;
|
|
18
18
|
initialSuccessMessage?: string | null;
|
|
19
|
+
/** Disable the admin Role selector (e.g. this is the only Admin, so its role can't be changed). */
|
|
20
|
+
lockRole?: boolean;
|
|
21
|
+
/** Explanation shown under the disabled Role selector. */
|
|
22
|
+
lockRoleReason?: string;
|
|
19
23
|
}
|
|
20
|
-
export declare function CustomerProfileForm({ initialData, MediaPickerComponent, isAdmin, email, accountLinks, onAction, initialSuccessMessage, }: CustomerProfileFormProps): React.JSX.Element;
|
|
24
|
+
export declare function CustomerProfileForm({ initialData, MediaPickerComponent, isAdmin, email, accountLinks, onAction, initialSuccessMessage, lockRole, lockRoleReason, }: CustomerProfileFormProps): React.JSX.Element;
|
|
21
25
|
export {};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs as s, jsx as l } from "react/jsx-runtime";
|
|
3
|
-
import x, { useState as
|
|
4
|
-
import { useForm as
|
|
5
|
-
import { AccountNavigationMenu as
|
|
6
|
-
import { Avatar as
|
|
7
|
-
import { Button as
|
|
8
|
-
import { Card as
|
|
9
|
-
import { Checkbox as
|
|
10
|
-
import { Input as
|
|
11
|
-
import { Label as
|
|
12
|
-
import { Select as
|
|
13
|
-
import { Separator as
|
|
14
|
-
import { updateProfile as
|
|
15
|
-
import { addressesMatch as
|
|
16
|
-
import { createClient as
|
|
17
|
-
import { User as
|
|
18
|
-
import { useTranslations as
|
|
19
|
-
import { normalizeCountryCode as
|
|
20
|
-
function
|
|
3
|
+
import x, { useState as R } from "react";
|
|
4
|
+
import { useForm as q } from "react-hook-form";
|
|
5
|
+
import { AccountNavigationMenu as J } from "./AccountNavigationMenu.es.js";
|
|
6
|
+
import { Avatar as K, AvatarImage as M, AvatarFallback as Q } from "@nextblock-cms/ui/avatar";
|
|
7
|
+
import { Button as Y } from "@nextblock-cms/ui/button";
|
|
8
|
+
import { Card as T, CardHeader as B, CardTitle as I, CardContent as L, CardFooter as Z } from "@nextblock-cms/ui/card";
|
|
9
|
+
import { Checkbox as D } from "@nextblock-cms/ui/checkbox";
|
|
10
|
+
import { Input as t } from "@nextblock-cms/ui/input";
|
|
11
|
+
import { Label as a } from "@nextblock-cms/ui/label";
|
|
12
|
+
import { Select as ee, SelectTrigger as le, SelectValue as se, SelectContent as re, SelectItem as $ } from "@nextblock-cms/ui/select";
|
|
13
|
+
import { Separator as ne } from "@nextblock-cms/ui/separator";
|
|
14
|
+
import { updateProfile as ae } from "../server-actions/customer-actions.es.js";
|
|
15
|
+
import { addressesMatch as P, normalizeCustomerAddress as j, emptyCustomerAddress as de } from "../customer.es.js";
|
|
16
|
+
import { createClient as te } from "@nextblock-cms/db";
|
|
17
|
+
import { User as k, Upload as ce, Phone as ie, Globe as oe } from "lucide-react";
|
|
18
|
+
import { useTranslations as X } from "@nextblock-cms/utils";
|
|
19
|
+
import { normalizeCountryCode as me, countries as pe } from "../countries.es.js";
|
|
20
|
+
function he(e) {
|
|
21
21
|
return e ? e.startsWith("http") ? e : process.env.NEXT_PUBLIC_R2_BASE_URL ? `${process.env.NEXT_PUBLIC_R2_BASE_URL}/${e}` : process.env.NEXT_PUBLIC_SUPABASE_URL ? `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${e}` : e : null;
|
|
22
22
|
}
|
|
23
23
|
function y(e) {
|
|
@@ -29,92 +29,94 @@ function y(e) {
|
|
|
29
29
|
city: e?.city || "",
|
|
30
30
|
state: e?.state || "",
|
|
31
31
|
postal_code: e?.postal_code || "",
|
|
32
|
-
country_code:
|
|
32
|
+
country_code: me(e?.country_code) || "CA"
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function V({
|
|
36
36
|
prefix: e,
|
|
37
37
|
title: h,
|
|
38
|
-
register:
|
|
38
|
+
register: c
|
|
39
39
|
}) {
|
|
40
|
-
const { t:
|
|
40
|
+
const { t: d } = X(), b = d("company_name") === "company_name" ? "Company name" : d("company_name");
|
|
41
41
|
return /* @__PURE__ */ s("div", { className: "space-y-4 rounded-xl border p-4", children: [
|
|
42
42
|
/* @__PURE__ */ s("div", { children: [
|
|
43
43
|
/* @__PURE__ */ l("h3", { className: "text-lg font-medium", children: h }),
|
|
44
|
-
/* @__PURE__ */ l("p", { className: "text-sm text-muted-foreground", children:
|
|
44
|
+
/* @__PURE__ */ l("p", { className: "text-sm text-muted-foreground", children: d("profile_address_defaults_help") })
|
|
45
45
|
] }),
|
|
46
46
|
/* @__PURE__ */ s("div", { className: "grid gap-4 md:grid-cols-3", children: [
|
|
47
47
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
48
|
-
/* @__PURE__ */ l(
|
|
49
|
-
/* @__PURE__ */ l(
|
|
48
|
+
/* @__PURE__ */ l(a, { htmlFor: `${e}-company_name`, children: b }),
|
|
49
|
+
/* @__PURE__ */ l(t, { id: `${e}-company_name`, ...c(`${e}.company_name`) })
|
|
50
50
|
] }),
|
|
51
51
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
52
|
-
/* @__PURE__ */ l(
|
|
53
|
-
/* @__PURE__ */ l(
|
|
52
|
+
/* @__PURE__ */ l(a, { htmlFor: `${e}-recipient_name`, children: d("full_name") }),
|
|
53
|
+
/* @__PURE__ */ l(t, { id: `${e}-recipient_name`, ...c(`${e}.recipient_name`) })
|
|
54
54
|
] }),
|
|
55
55
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
56
|
-
/* @__PURE__ */ l(
|
|
56
|
+
/* @__PURE__ */ l(a, { htmlFor: `${e}-country_code`, children: d("country") }),
|
|
57
57
|
/* @__PURE__ */ l(
|
|
58
58
|
"select",
|
|
59
59
|
{
|
|
60
60
|
id: `${e}-country_code`,
|
|
61
61
|
className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
|
|
62
|
-
...
|
|
63
|
-
children:
|
|
62
|
+
...c(`${e}.country_code`),
|
|
63
|
+
children: pe.map((o) => /* @__PURE__ */ l("option", { value: o.code, children: o.name }, o.code))
|
|
64
64
|
}
|
|
65
65
|
)
|
|
66
66
|
] })
|
|
67
67
|
] }),
|
|
68
68
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
69
|
-
/* @__PURE__ */ l(
|
|
70
|
-
/* @__PURE__ */ l(
|
|
69
|
+
/* @__PURE__ */ l(a, { htmlFor: `${e}-line1`, children: d("address_line_1") }),
|
|
70
|
+
/* @__PURE__ */ l(t, { id: `${e}-line1`, ...c(`${e}.line1`) })
|
|
71
71
|
] }),
|
|
72
72
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
73
|
-
/* @__PURE__ */ l(
|
|
74
|
-
/* @__PURE__ */ l(
|
|
73
|
+
/* @__PURE__ */ l(a, { htmlFor: `${e}-line2`, children: d("address_line_2") }),
|
|
74
|
+
/* @__PURE__ */ l(t, { id: `${e}-line2`, ...c(`${e}.line2`) })
|
|
75
75
|
] }),
|
|
76
76
|
/* @__PURE__ */ s("div", { className: "grid gap-4 md:grid-cols-3", children: [
|
|
77
77
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
78
|
-
/* @__PURE__ */ l(
|
|
79
|
-
/* @__PURE__ */ l(
|
|
78
|
+
/* @__PURE__ */ l(a, { htmlFor: `${e}-city`, children: d("city") }),
|
|
79
|
+
/* @__PURE__ */ l(t, { id: `${e}-city`, ...c(`${e}.city`) })
|
|
80
80
|
] }),
|
|
81
81
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
82
|
-
/* @__PURE__ */ l(
|
|
83
|
-
/* @__PURE__ */ l(
|
|
82
|
+
/* @__PURE__ */ l(a, { htmlFor: `${e}-state`, children: d("state_province") }),
|
|
83
|
+
/* @__PURE__ */ l(t, { id: `${e}-state`, ...c(`${e}.state`) })
|
|
84
84
|
] }),
|
|
85
85
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
86
|
-
/* @__PURE__ */ l(
|
|
87
|
-
/* @__PURE__ */ l(
|
|
86
|
+
/* @__PURE__ */ l(a, { htmlFor: `${e}-postal_code`, children: d("postal_zip_code") }),
|
|
87
|
+
/* @__PURE__ */ l(t, { id: `${e}-postal_code`, ...c(`${e}.postal_code`) })
|
|
88
88
|
] })
|
|
89
89
|
] })
|
|
90
90
|
] });
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function Te({
|
|
93
93
|
initialData: e,
|
|
94
94
|
MediaPickerComponent: h,
|
|
95
|
-
isAdmin:
|
|
96
|
-
email:
|
|
95
|
+
isAdmin: c,
|
|
96
|
+
email: d,
|
|
97
97
|
accountLinks: b,
|
|
98
98
|
onAction: o,
|
|
99
|
-
initialSuccessMessage: u
|
|
99
|
+
initialSuccessMessage: u,
|
|
100
|
+
lockRole: w,
|
|
101
|
+
lockRoleReason: z
|
|
100
102
|
}) {
|
|
101
|
-
const { t: r } =
|
|
103
|
+
const { t: r } = X(), [C, A] = R(!1), [v, N] = R(
|
|
102
104
|
u ? { type: "success", text: u } : null
|
|
103
|
-
),
|
|
105
|
+
), W = e?.use_billing_for_shipping ?? (!e?.shipping_address || P(e?.billing_address, e?.shipping_address)), {
|
|
104
106
|
register: m,
|
|
105
|
-
handleSubmit:
|
|
107
|
+
handleSubmit: G,
|
|
106
108
|
setValue: _,
|
|
107
109
|
getValues: E,
|
|
108
110
|
watch: g,
|
|
109
111
|
reset: F
|
|
110
|
-
} =
|
|
112
|
+
} = q({
|
|
111
113
|
defaultValues: {
|
|
112
114
|
full_name: e?.full_name || "",
|
|
113
115
|
avatar_url: e?.avatar_url || "",
|
|
114
116
|
website: e?.website || "",
|
|
115
117
|
phone: e?.phone || "",
|
|
116
118
|
role: e?.role,
|
|
117
|
-
use_billing_for_shipping:
|
|
119
|
+
use_billing_for_shipping: W,
|
|
118
120
|
billing_address: y(e?.billing_address),
|
|
119
121
|
shipping_address: y(e?.shipping_address)
|
|
120
122
|
}
|
|
@@ -126,56 +128,56 @@ function Se({
|
|
|
126
128
|
website: e.website || "",
|
|
127
129
|
phone: e.phone || "",
|
|
128
130
|
role: e.role,
|
|
129
|
-
use_billing_for_shipping: e.use_billing_for_shipping ?? (!e.shipping_address ||
|
|
131
|
+
use_billing_for_shipping: e.use_billing_for_shipping ?? (!e.shipping_address || P(e.billing_address, e.shipping_address)),
|
|
130
132
|
billing_address: y(e.billing_address),
|
|
131
133
|
shipping_address: y(e.shipping_address)
|
|
132
134
|
});
|
|
133
135
|
}, [e, F]), x.useEffect(() => {
|
|
134
136
|
u && N({ type: "success", text: u });
|
|
135
137
|
}, [u]), x.useEffect(() => {
|
|
136
|
-
const
|
|
138
|
+
const n = te();
|
|
137
139
|
(async () => {
|
|
138
140
|
const {
|
|
139
141
|
data: { user: f }
|
|
140
|
-
} = await
|
|
142
|
+
} = await n.auth.getUser();
|
|
141
143
|
f && !E("full_name") && f.user_metadata?.full_name && _("full_name", f.user_metadata.full_name);
|
|
142
144
|
})();
|
|
143
145
|
}, [E, _]);
|
|
144
|
-
const
|
|
145
|
-
const p =
|
|
146
|
+
const H = (n) => {
|
|
147
|
+
const p = he(n?.object_key ?? n?.file_path);
|
|
146
148
|
p && _("avatar_url", p);
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
const p =
|
|
149
|
+
}, O = async (n) => {
|
|
150
|
+
A(!0), N(null);
|
|
151
|
+
const p = j(n.billing_address) ?? de(), f = n.use_billing_for_shipping ? p : j(n.shipping_address);
|
|
150
152
|
try {
|
|
151
|
-
const
|
|
152
|
-
...
|
|
153
|
+
const i = {
|
|
154
|
+
...n,
|
|
153
155
|
billing_address: p,
|
|
154
156
|
shipping_address: f
|
|
155
157
|
};
|
|
156
158
|
if (o) {
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
throw new Error(
|
|
159
|
+
const S = await o(i);
|
|
160
|
+
if (S?.error)
|
|
161
|
+
throw new Error(S.error);
|
|
160
162
|
} else
|
|
161
|
-
await
|
|
163
|
+
await ae(i);
|
|
162
164
|
N({ type: "success", text: r("profile_updated_success") });
|
|
163
|
-
} catch (
|
|
164
|
-
if (
|
|
165
|
+
} catch (i) {
|
|
166
|
+
if (i.message === "NEXT_REDIRECT" || i.message?.includes("NEXT_REDIRECT"))
|
|
165
167
|
return;
|
|
166
|
-
console.error(
|
|
168
|
+
console.error(i), N({ type: "error", text: i.message || r("profile_update_failed") });
|
|
167
169
|
} finally {
|
|
168
|
-
|
|
170
|
+
A(!1);
|
|
169
171
|
}
|
|
170
172
|
}, U = g("use_billing_for_shipping");
|
|
171
173
|
return /* @__PURE__ */ s("div", { className: "grid gap-6 md:grid-cols-12 max-w-5xl mx-auto", children: [
|
|
172
|
-
/* @__PURE__ */ s(
|
|
173
|
-
/* @__PURE__ */ l(
|
|
174
|
-
/* @__PURE__ */ s(
|
|
174
|
+
/* @__PURE__ */ s(T, { className: "md:col-span-4 h-fit", children: [
|
|
175
|
+
/* @__PURE__ */ l(B, { children: /* @__PURE__ */ l(I, { className: "text-xl", children: r("public_profile") }) }),
|
|
176
|
+
/* @__PURE__ */ s(L, { className: "flex flex-col items-center text-center space-y-4", children: [
|
|
175
177
|
/* @__PURE__ */ s("div", { className: "relative group", children: [
|
|
176
|
-
/* @__PURE__ */ s(
|
|
177
|
-
/* @__PURE__ */ l(
|
|
178
|
-
/* @__PURE__ */ l(
|
|
178
|
+
/* @__PURE__ */ s(K, { className: "h-32 w-32 border-4 border-muted", children: [
|
|
179
|
+
/* @__PURE__ */ l(M, { src: g("avatar_url") || void 0, className: "object-cover" }),
|
|
180
|
+
/* @__PURE__ */ l(Q, { className: "text-4xl bg-secondary", children: g("full_name")?.charAt(0)?.toUpperCase() || /* @__PURE__ */ l(k, { className: "h-12 w-12" }) })
|
|
179
181
|
] }),
|
|
180
182
|
h && /* @__PURE__ */ l("div", { className: "absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/40 rounded-full cursor-pointer", children: /* @__PURE__ */ l(
|
|
181
183
|
h,
|
|
@@ -183,22 +185,22 @@ function Se({
|
|
|
183
185
|
triggerLabel: /* @__PURE__ */ l(ce, { className: "h-6 w-6 text-white" }),
|
|
184
186
|
triggerVariant: "ghost",
|
|
185
187
|
title: r("customer_profile"),
|
|
186
|
-
onSelect:
|
|
187
|
-
accept: (
|
|
188
|
+
onSelect: H,
|
|
189
|
+
accept: (n) => n.file_type.startsWith("image/"),
|
|
188
190
|
hideTrigger: !1
|
|
189
191
|
}
|
|
190
192
|
) })
|
|
191
193
|
] }),
|
|
192
194
|
!h && /* @__PURE__ */ s("div", { className: "w-full", children: [
|
|
193
|
-
/* @__PURE__ */ l(
|
|
194
|
-
/* @__PURE__ */ l(
|
|
195
|
+
/* @__PURE__ */ l(a, { htmlFor: "avatar_url", className: "sr-only", children: r("avatar_url") }),
|
|
196
|
+
/* @__PURE__ */ l(t, { id: "avatar_url", ...m("avatar_url"), placeholder: "https://...", className: "mt-2" })
|
|
195
197
|
] }),
|
|
196
198
|
/* @__PURE__ */ s("div", { className: "w-full space-y-1 text-left mt-4", children: [
|
|
197
199
|
/* @__PURE__ */ l("div", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wider", children: r("identity") }),
|
|
198
200
|
/* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ l("span", { className: "font-semibold text-lg", children: g("full_name") || r("full_name") }) })
|
|
199
201
|
] }),
|
|
200
202
|
b?.length ? /* @__PURE__ */ l(
|
|
201
|
-
|
|
203
|
+
J,
|
|
202
204
|
{
|
|
203
205
|
links: b,
|
|
204
206
|
className: "mt-2 text-left"
|
|
@@ -206,61 +208,61 @@ function Se({
|
|
|
206
208
|
) : null
|
|
207
209
|
] })
|
|
208
210
|
] }),
|
|
209
|
-
/* @__PURE__ */ l(
|
|
210
|
-
/* @__PURE__ */ l(
|
|
211
|
-
/* @__PURE__ */ s(
|
|
212
|
-
|
|
213
|
-
/* @__PURE__ */ s(
|
|
211
|
+
/* @__PURE__ */ l(T, { className: "md:col-span-8", children: /* @__PURE__ */ s("form", { onSubmit: G(O), children: [
|
|
212
|
+
/* @__PURE__ */ l(B, { children: /* @__PURE__ */ l(I, { children: r("details") }) }),
|
|
213
|
+
/* @__PURE__ */ s(L, { className: "space-y-6", children: [
|
|
214
|
+
d && /* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
215
|
+
/* @__PURE__ */ s(a, { htmlFor: "email", children: [
|
|
214
216
|
r("email") || "Email",
|
|
215
217
|
" (Read-only)"
|
|
216
218
|
] }),
|
|
217
|
-
/* @__PURE__ */ l(
|
|
219
|
+
/* @__PURE__ */ l(t, { id: "email", value: d, readOnly: !0, disabled: !0, className: "bg-muted/50" })
|
|
218
220
|
] }),
|
|
219
221
|
/* @__PURE__ */ l("div", { className: "rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground", children: r("profile_basic_info_help") }),
|
|
220
222
|
/* @__PURE__ */ s("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
221
223
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
222
|
-
/* @__PURE__ */ s(
|
|
223
|
-
/* @__PURE__ */ l(
|
|
224
|
+
/* @__PURE__ */ s(a, { htmlFor: "full_name", className: "flex items-center gap-2", children: [
|
|
225
|
+
/* @__PURE__ */ l(k, { className: "h-4 w-4" }),
|
|
224
226
|
" ",
|
|
225
227
|
r("full_name")
|
|
226
228
|
] }),
|
|
227
|
-
/* @__PURE__ */ l(
|
|
229
|
+
/* @__PURE__ */ l(t, { id: "full_name", ...m("full_name") })
|
|
228
230
|
] }),
|
|
229
231
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
230
|
-
/* @__PURE__ */ s(
|
|
231
|
-
/* @__PURE__ */ l(
|
|
232
|
+
/* @__PURE__ */ s(a, { htmlFor: "phone", className: "flex items-center gap-2", children: [
|
|
233
|
+
/* @__PURE__ */ l(ie, { className: "h-4 w-4" }),
|
|
232
234
|
" ",
|
|
233
235
|
r("phone_number")
|
|
234
236
|
] }),
|
|
235
|
-
/* @__PURE__ */ l(
|
|
237
|
+
/* @__PURE__ */ l(t, { id: "phone", ...m("phone") })
|
|
236
238
|
] })
|
|
237
239
|
] }),
|
|
238
240
|
/* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
239
|
-
/* @__PURE__ */ s(
|
|
240
|
-
/* @__PURE__ */ l(
|
|
241
|
+
/* @__PURE__ */ s(a, { htmlFor: "website", className: "flex items-center gap-2", children: [
|
|
242
|
+
/* @__PURE__ */ l(oe, { className: "h-4 w-4" }),
|
|
241
243
|
" ",
|
|
242
244
|
r("website")
|
|
243
245
|
] }),
|
|
244
|
-
/* @__PURE__ */ l(
|
|
246
|
+
/* @__PURE__ */ l(t, { id: "website", ...m("website"), placeholder: "https://example.com" })
|
|
245
247
|
] }),
|
|
246
|
-
/* @__PURE__ */ l(
|
|
247
|
-
/* @__PURE__ */ l(
|
|
248
|
+
/* @__PURE__ */ l(ne, { className: "my-2" }),
|
|
249
|
+
/* @__PURE__ */ l(V, { prefix: "billing_address", title: r("billing_address"), register: m }),
|
|
248
250
|
/* @__PURE__ */ s("div", { className: "flex items-center space-x-3 rounded-lg border p-4", children: [
|
|
249
251
|
/* @__PURE__ */ l(
|
|
250
|
-
|
|
252
|
+
D,
|
|
251
253
|
{
|
|
252
254
|
id: "use_billing_for_shipping",
|
|
253
255
|
checked: !!U,
|
|
254
|
-
onCheckedChange: (
|
|
256
|
+
onCheckedChange: (n) => _("use_billing_for_shipping", !!n, { shouldDirty: !0 })
|
|
255
257
|
}
|
|
256
258
|
),
|
|
257
259
|
/* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
258
|
-
/* @__PURE__ */ l(
|
|
260
|
+
/* @__PURE__ */ l(a, { htmlFor: "use_billing_for_shipping", className: "cursor-pointer", children: r("use_billing_for_shipping") }),
|
|
259
261
|
/* @__PURE__ */ l("p", { className: "text-sm text-muted-foreground", children: r("profile_use_billing_for_shipping_help") })
|
|
260
262
|
] })
|
|
261
263
|
] }),
|
|
262
264
|
!U && /* @__PURE__ */ l(
|
|
263
|
-
|
|
265
|
+
V,
|
|
264
266
|
{
|
|
265
267
|
prefix: "shipping_address",
|
|
266
268
|
title: r("shipping_address"),
|
|
@@ -274,32 +276,34 @@ function Se({
|
|
|
274
276
|
children: v.text
|
|
275
277
|
}
|
|
276
278
|
),
|
|
277
|
-
|
|
279
|
+
c && /* @__PURE__ */ s("div", { className: "border-t pt-4 mt-4", children: [
|
|
278
280
|
/* @__PURE__ */ l("h3", { className: "text-sm font-medium mb-3", children: "Admin Settings" }),
|
|
279
281
|
/* @__PURE__ */ s("div", { className: "grid gap-2", children: [
|
|
280
|
-
/* @__PURE__ */ l(
|
|
282
|
+
/* @__PURE__ */ l(a, { htmlFor: "role", children: "Role" }),
|
|
281
283
|
/* @__PURE__ */ s(
|
|
282
|
-
|
|
284
|
+
ee,
|
|
283
285
|
{
|
|
284
286
|
value: g("role") || "USER",
|
|
285
|
-
onValueChange: (
|
|
287
|
+
onValueChange: (n) => _("role", n),
|
|
288
|
+
disabled: w,
|
|
286
289
|
children: [
|
|
287
|
-
/* @__PURE__ */ l(
|
|
288
|
-
/* @__PURE__ */ s(
|
|
290
|
+
/* @__PURE__ */ l(le, { children: /* @__PURE__ */ l(se, { placeholder: "Select role" }) }),
|
|
291
|
+
/* @__PURE__ */ s(re, { children: [
|
|
289
292
|
/* @__PURE__ */ l($, { value: "USER", children: "User" }),
|
|
290
293
|
/* @__PURE__ */ l($, { value: "WRITER", children: "Writer" }),
|
|
291
294
|
/* @__PURE__ */ l($, { value: "ADMIN", children: "Admin" })
|
|
292
295
|
] })
|
|
293
296
|
]
|
|
294
297
|
}
|
|
295
|
-
)
|
|
298
|
+
),
|
|
299
|
+
w && /* @__PURE__ */ l("p", { className: "text-xs text-muted-foreground", children: z || "This is the only Admin account, so its role can't be changed. Promote another user to Admin first." })
|
|
296
300
|
] })
|
|
297
301
|
] })
|
|
298
302
|
] }),
|
|
299
|
-
/* @__PURE__ */ l(
|
|
303
|
+
/* @__PURE__ */ l(Z, { className: "flex justify-end", children: /* @__PURE__ */ l(Y, { type: "submit", disabled: C, size: "lg", children: r(C ? "saving" : "save_changes") }) })
|
|
300
304
|
] }) })
|
|
301
305
|
] });
|
|
302
306
|
}
|
|
303
307
|
export {
|
|
304
|
-
|
|
308
|
+
Te as CustomerProfileForm
|
|
305
309
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@nextblock-cms/db/server"),d=require("../../../product-actions.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@nextblock-cms/db/server"),d=require("../../../product-actions.cjs.js"),f=require("../../../freemius-coupons.cjs.js"),l=require("../../../currency.cjs.js"),m=require("./product-price-sync.cjs.js"),a=require("next/cache"),b=require("next/navigation");function u(e){return e.toLowerCase().trim().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function _(e){const t=o.createClient(),{data:r}=await t.from("currencies").select("code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount").eq("is_active",!0).order("code",{ascending:!0}),s=m.sanitizeProductFormValuesForStoreManagedCurrencies(e,(r||[]).map(i=>l.normalizeCurrencyRecord(i))),c=await d.createProduct(t,s);if(s.payment_provider==="freemius"&&c?.id)try{await f.syncProductSaleCouponToFreemius({productId:c.id,client:o.getServiceRoleSupabaseClient()})}catch(i){console.error("Failed to sync Freemius sale coupon on create:",i)}a.revalidatePath("/cms/products"),b.redirect("/cms/products")}async function P(e,t){const r=o.createClient(),{data:{user:s}}=await r.auth.getUser();if(!s)throw new Error("User not authenticated.");const{data:c}=await r.from("currencies").select("code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount").eq("is_active",!0).order("code",{ascending:!0}),i=m.sanitizeProductFormValuesForStoreManagedCurrencies(t,(c||[]).map(g=>l.normalizeCurrencyRecord(g))),{error:n}=await r.from("product_drafts").upsert({product_id:e,author_id:s.id,meta:i,updated_at:new Date().toISOString()},{onConflict:"product_id"});if(n)throw new Error(`Failed to save product draft: ${n.message}`);return{success:!0}}async function h(e){const t=o.createClient();await d.deleteProduct(t,e),a.revalidatePath("/cms/products")}function p(e){return Array.from(new Set(e.map(t=>t.trim()).filter(Boolean)))}async function v(e){const t=p(e);if(t.length===0)return{success:!1,error:"Select at least one product."};const r=o.createClient(),{error:s}=await r.from("products").delete().in("id",t);return s?{success:!1,error:s.message}:(a.revalidatePath("/cms/products"),{success:!0,count:t.length})}async function A(e){const t=p(e);if(t.length===0)return{success:!1,error:"Select at least one product."};const r=o.createClient(),{error:s}=await r.from("products").update({status:"draft",updated_at:new Date().toISOString()}).in("id",t);return s?{success:!1,error:s.message}:(a.revalidatePath("/cms/products"),{success:!0,count:t.length})}async function y(e){const t=String(e||"").trim();if(!t)return{error:"Missing product id."};const r=o.createClient(),{data:{user:s}}=await r.auth.getUser();if(!s)return{error:"You must be signed in to publish a product."};const{data:c,error:i}=await r.from("products").update({status:"active",updated_at:new Date().toISOString()}).eq("id",t).select("slug").single();return i||!c?{error:i?.message||"Could not publish the product."}:(a.revalidatePath("/cms/products"),a.revalidatePath(`/cms/products/${t}/edit`),c.slug&&a.revalidatePath(`/product/${c.slug}`),{})}async function S(e){const t=o.getServiceRoleSupabaseClient(),r=e.name.trim(),s=u(e.slug?.trim()||e.name);if(!r||!s)return{success:!1,error:"Attribute name is required."};const{error:c}=await t.from("product_attributes").insert({name:r,slug:s});return c?{success:!1,error:c.message}:(a.revalidatePath("/cms/products/attributes"),a.revalidatePath("/cms/products/new"),a.revalidatePath("/cms/products"),{success:!0})}async function w(e){const t=o.getServiceRoleSupabaseClient(),{error:r}=await t.from("product_attributes").delete().eq("id",e);return r?{success:!1,error:r.message}:(a.revalidatePath("/cms/products/attributes"),a.revalidatePath("/cms/products/new"),a.revalidatePath("/cms/products"),{success:!0})}async function C(e){const t=o.getServiceRoleSupabaseClient(),r=e.value.trim(),s=u(e.slug?.trim()||e.value);if(!r||!s)return{success:!1,error:"Term value is required."};const{data:c}=await t.from("product_attribute_terms").select("sort_order").eq("attribute_id",e.attributeId).order("sort_order",{ascending:!1}).limit(1),i=typeof c?.[0]?.sort_order=="number"?c[0].sort_order+1:0,{error:n}=await t.from("product_attribute_terms").insert({attribute_id:e.attributeId,value:r,slug:s,sort_order:i});return n?{success:!1,error:n.message}:(a.revalidatePath("/cms/products/attributes"),a.revalidatePath("/cms/products/new"),a.revalidatePath("/cms/products"),{success:!0})}async function q(e){const t=o.getServiceRoleSupabaseClient();for(const[r,s]of e.orderedTermIds.entries()){const{error:c}=await t.from("product_attribute_terms").update({sort_order:r,updated_at:new Date().toISOString()}).eq("id",s).eq("attribute_id",e.attributeId);if(c)return{success:!1,error:c.message}}return a.revalidatePath("/cms/products/attributes"),a.revalidatePath("/cms/products/new"),a.revalidatePath("/cms/products"),{success:!0}}async function T(e){const t=o.getServiceRoleSupabaseClient(),{error:r}=await t.from("product_attributes").update({name_translations:e.nameTranslations,updated_at:new Date().toISOString()}).eq("id",e.attributeId);if(r)return{success:!1,error:r.message};for(const s of e.termTranslations){const{error:c}=await t.from("product_attribute_terms").update({value_translations:s.valueTranslations,updated_at:new Date().toISOString()}).eq("id",s.termId).eq("attribute_id",e.attributeId);if(c)return{success:!1,error:c.message}}return a.revalidatePath("/cms/products/attributes"),a.revalidatePath("/cms/products/new"),a.revalidatePath("/cms/products"),{success:!0}}async function I(e){const t=o.getServiceRoleSupabaseClient(),{error:r}=await t.from("product_attribute_terms").delete().eq("id",e);return r?{success:!1,error:r.message}:(a.revalidatePath("/cms/products/attributes"),a.revalidatePath("/cms/products/new"),a.revalidatePath("/cms/products"),{success:!0})}async function R(e){const t=o.getServiceRoleSupabaseClient(),r=e.name.trim(),s=u(e.slug?.trim()||e.name);if(!r||!s)return{success:!1,error:"Category name is required."};const{data:c,error:i}=await t.from("categories").insert({name:r,slug:s,description:e.description?.trim()||null,name_translations:e.nameTranslations||{},description_translations:e.descriptionTranslations||{}}).select().single();return i?{success:!1,error:i.message}:(a.revalidatePath("/cms/products/categories"),a.revalidatePath("/cms/products/new"),a.revalidatePath("/cms/products"),{success:!0,category:c})}async function D(e,t){const r=o.getServiceRoleSupabaseClient(),s=t.name.trim(),c=u(t.slug?.trim()||t.name);if(!s||!c)return{success:!1,error:"Category name is required."};const{error:i}=await r.from("categories").update({name:s,slug:c,description:t.description?.trim()||null,name_translations:t.nameTranslations||{},description_translations:t.descriptionTranslations||{}}).eq("id",e);return i?{success:!1,error:i.message}:(a.revalidatePath("/cms/products/categories"),a.revalidatePath("/cms/products/new"),a.revalidatePath("/cms/products"),{success:!0})}async function x(e){const t=o.getServiceRoleSupabaseClient(),{error:r}=await t.from("categories").delete().eq("id",e);return r?{success:!1,error:r.message}:(a.revalidatePath("/cms/products/categories"),a.revalidatePath("/cms/products/new"),a.revalidatePath("/cms/products"),{success:!0})}async function F(e,t){const r=o.getServiceRoleSupabaseClient();try{return await d.syncCategoriesForTranslationGroup(r,e,t),a.revalidatePath("/cms/products"),a.revalidatePath(`/cms/products/${e}/edit`),{success:!0}}catch(s){return{success:!1,error:s.message}}}exports.bulkDeleteProductsAction=v;exports.bulkDraftProductsAction=A;exports.createCategoryAction=R;exports.createProductAction=_;exports.createProductAttributeAction=S;exports.createProductAttributeTermAction=C;exports.deleteCategoryAction=x;exports.deleteProductAction=h;exports.deleteProductAttributeAction=w;exports.deleteProductAttributeTermAction=I;exports.publishProductAction=y;exports.reorderProductAttributeTermsAction=q;exports.syncProductCategoriesAction=F;exports.updateCategoryAction=D;exports.updateProductAction=P;exports.updateProductAttributeTranslationsAction=T;
|
|
@@ -22,6 +22,16 @@ export declare function bulkDraftProductsAction(productIds: string[]): Promise<{
|
|
|
22
22
|
count: number;
|
|
23
23
|
error?: undefined;
|
|
24
24
|
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Publish a single product directly (status -> "active") so it becomes visible on
|
|
27
|
+
* the storefront. Used by the draft-aware "View Live" button when an admin chooses
|
|
28
|
+
* to publish a still-draft product. A plain status write (mirrors
|
|
29
|
+
* bulkDraftProductsAction) — it does NOT touch variants, prices, or the sale
|
|
30
|
+
* schedule.
|
|
31
|
+
*/
|
|
32
|
+
export declare function publishProductAction(productId: string): Promise<{
|
|
33
|
+
error?: string;
|
|
34
|
+
} | void>;
|
|
25
35
|
export declare function createProductAttributeAction(input: {
|
|
26
36
|
name: string;
|
|
27
37
|
slug?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use server';
|
|
2
|
-
import { getServiceRoleSupabaseClient as n, createClient as
|
|
3
|
-
import { createProduct as
|
|
2
|
+
import { getServiceRoleSupabaseClient as n, createClient as u } from "@nextblock-cms/db/server";
|
|
3
|
+
import { createProduct as g, deleteProduct as _, syncCategoriesForTranslationGroup as b } from "../../../product-actions.es.js";
|
|
4
4
|
import { syncProductSaleCouponToFreemius as w } from "../../../freemius-coupons.es.js";
|
|
5
5
|
import { normalizeCurrencyRecord as m } from "../../../currency.es.js";
|
|
6
6
|
import { sanitizeProductFormValuesForStoreManagedCurrencies as l } from "./product-price-sync.es.js";
|
|
@@ -10,48 +10,48 @@ function d(e) {
|
|
|
10
10
|
return e.toLowerCase().trim().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
11
11
|
}
|
|
12
12
|
async function C(e) {
|
|
13
|
-
const r =
|
|
13
|
+
const r = u(), { data: t } = await r.from("currencies").select(
|
|
14
14
|
"code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount"
|
|
15
15
|
).eq("is_active", !0).order("code", { ascending: !0 }), c = l(
|
|
16
16
|
e,
|
|
17
|
-
(t || []).map((
|
|
18
|
-
),
|
|
19
|
-
if (c.payment_provider === "freemius" &&
|
|
17
|
+
(t || []).map((a) => m(a))
|
|
18
|
+
), o = await g(r, c);
|
|
19
|
+
if (c.payment_provider === "freemius" && o?.id)
|
|
20
20
|
try {
|
|
21
21
|
await w({
|
|
22
|
-
productId:
|
|
22
|
+
productId: o.id,
|
|
23
23
|
client: n()
|
|
24
24
|
});
|
|
25
|
-
} catch (
|
|
26
|
-
console.error("Failed to sync Freemius sale coupon on create:",
|
|
25
|
+
} catch (a) {
|
|
26
|
+
console.error("Failed to sync Freemius sale coupon on create:", a);
|
|
27
27
|
}
|
|
28
28
|
s("/cms/products"), y("/cms/products");
|
|
29
29
|
}
|
|
30
30
|
async function I(e, r) {
|
|
31
|
-
const t =
|
|
31
|
+
const t = u(), { data: { user: c } } = await t.auth.getUser();
|
|
32
32
|
if (!c)
|
|
33
33
|
throw new Error("User not authenticated.");
|
|
34
|
-
const { data:
|
|
34
|
+
const { data: o } = await t.from("currencies").select(
|
|
35
35
|
"code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount"
|
|
36
|
-
).eq("is_active", !0).order("code", { ascending: !0 }),
|
|
36
|
+
).eq("is_active", !0).order("code", { ascending: !0 }), a = l(
|
|
37
37
|
r,
|
|
38
|
-
(
|
|
39
|
-
), { error:
|
|
38
|
+
(o || []).map((f) => m(f))
|
|
39
|
+
), { error: i } = await t.from("product_drafts").upsert(
|
|
40
40
|
{
|
|
41
41
|
product_id: e,
|
|
42
42
|
author_id: c.id,
|
|
43
|
-
meta:
|
|
43
|
+
meta: a,
|
|
44
44
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
45
45
|
},
|
|
46
46
|
{ onConflict: "product_id" }
|
|
47
47
|
);
|
|
48
|
-
if (
|
|
49
|
-
throw new Error(`Failed to save product draft: ${
|
|
48
|
+
if (i)
|
|
49
|
+
throw new Error(`Failed to save product draft: ${i.message}`);
|
|
50
50
|
return { success: !0 };
|
|
51
51
|
}
|
|
52
52
|
async function x(e) {
|
|
53
|
-
const r =
|
|
54
|
-
await
|
|
53
|
+
const r = u();
|
|
54
|
+
await _(r, e), s("/cms/products");
|
|
55
55
|
}
|
|
56
56
|
function p(e) {
|
|
57
57
|
return Array.from(
|
|
@@ -64,54 +64,69 @@ async function D(e) {
|
|
|
64
64
|
const r = p(e);
|
|
65
65
|
if (r.length === 0)
|
|
66
66
|
return { success: !1, error: "Select at least one product." };
|
|
67
|
-
const t =
|
|
67
|
+
const t = u(), { error: c } = await t.from("products").delete().in("id", r);
|
|
68
68
|
return c ? { success: !1, error: c.message } : (s("/cms/products"), { success: !0, count: r.length });
|
|
69
69
|
}
|
|
70
70
|
async function F(e) {
|
|
71
71
|
const r = p(e);
|
|
72
72
|
if (r.length === 0)
|
|
73
73
|
return { success: !1, error: "Select at least one product." };
|
|
74
|
-
const t =
|
|
74
|
+
const t = u(), { error: c } = await t.from("products").update({
|
|
75
75
|
status: "draft",
|
|
76
76
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
77
77
|
}).in("id", r);
|
|
78
78
|
return c ? { success: !1, error: c.message } : (s("/cms/products"), { success: !0, count: r.length });
|
|
79
79
|
}
|
|
80
|
+
async function O(e) {
|
|
81
|
+
const r = String(e || "").trim();
|
|
82
|
+
if (!r)
|
|
83
|
+
return { error: "Missing product id." };
|
|
84
|
+
const t = u(), {
|
|
85
|
+
data: { user: c }
|
|
86
|
+
} = await t.auth.getUser();
|
|
87
|
+
if (!c)
|
|
88
|
+
return { error: "You must be signed in to publish a product." };
|
|
89
|
+
const { data: o, error: a } = await t.from("products").update({
|
|
90
|
+
status: "active",
|
|
91
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
92
|
+
}).eq("id", r).select("slug").single();
|
|
93
|
+
return a || !o ? { error: a?.message || "Could not publish the product." } : (s("/cms/products"), s(`/cms/products/${r}/edit`), o.slug && s(`/product/${o.slug}`), {});
|
|
94
|
+
}
|
|
80
95
|
async function z(e) {
|
|
81
96
|
const r = n(), t = e.name.trim(), c = d(e.slug?.trim() || e.name);
|
|
82
97
|
if (!t || !c)
|
|
83
98
|
return { success: !1, error: "Attribute name is required." };
|
|
84
|
-
const { error:
|
|
99
|
+
const { error: o } = await r.from("product_attributes").insert({
|
|
85
100
|
name: t,
|
|
86
101
|
slug: c
|
|
87
102
|
});
|
|
88
|
-
return
|
|
103
|
+
return o ? { success: !1, error: o.message } : (s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
|
|
89
104
|
}
|
|
90
|
-
async function
|
|
105
|
+
async function E(e) {
|
|
91
106
|
const r = n(), { error: t } = await r.from("product_attributes").delete().eq("id", e);
|
|
92
107
|
return t ? { success: !1, error: t.message } : (s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
|
|
93
108
|
}
|
|
94
|
-
async function
|
|
109
|
+
async function $(e) {
|
|
95
110
|
const r = n(), t = e.value.trim(), c = d(e.slug?.trim() || e.value);
|
|
96
111
|
if (!t || !c)
|
|
97
112
|
return { success: !1, error: "Term value is required." };
|
|
98
|
-
const { data:
|
|
113
|
+
const { data: o } = await r.from("product_attribute_terms").select("sort_order").eq("attribute_id", e.attributeId).order("sort_order", { ascending: !1 }).limit(1), a = typeof o?.[0]?.sort_order == "number" ? o[0].sort_order + 1 : 0, { error: i } = await r.from("product_attribute_terms").insert({
|
|
99
114
|
attribute_id: e.attributeId,
|
|
100
115
|
value: t,
|
|
101
116
|
slug: c,
|
|
102
|
-
sort_order:
|
|
117
|
+
sort_order: a
|
|
103
118
|
});
|
|
104
|
-
return
|
|
119
|
+
return i ? { success: !1, error: i.message } : (s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
|
|
105
120
|
}
|
|
106
|
-
async function
|
|
121
|
+
async function U(e) {
|
|
107
122
|
const r = n();
|
|
108
123
|
for (const [t, c] of e.orderedTermIds.entries()) {
|
|
109
|
-
const { error:
|
|
124
|
+
const { error: o } = await r.from("product_attribute_terms").update({
|
|
110
125
|
sort_order: t,
|
|
111
126
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
112
127
|
}).eq("id", c).eq("attribute_id", e.attributeId);
|
|
113
|
-
if (
|
|
114
|
-
return { success: !1, error:
|
|
128
|
+
if (o)
|
|
129
|
+
return { success: !1, error: o.message };
|
|
115
130
|
}
|
|
116
131
|
return s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 };
|
|
117
132
|
}
|
|
@@ -123,44 +138,44 @@ async function k(e) {
|
|
|
123
138
|
if (t)
|
|
124
139
|
return { success: !1, error: t.message };
|
|
125
140
|
for (const c of e.termTranslations) {
|
|
126
|
-
const { error:
|
|
141
|
+
const { error: o } = await r.from("product_attribute_terms").update({
|
|
127
142
|
value_translations: c.valueTranslations,
|
|
128
143
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
129
144
|
}).eq("id", c.termId).eq("attribute_id", e.attributeId);
|
|
130
|
-
if (
|
|
131
|
-
return { success: !1, error:
|
|
145
|
+
if (o)
|
|
146
|
+
return { success: !1, error: o.message };
|
|
132
147
|
}
|
|
133
148
|
return s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 };
|
|
134
149
|
}
|
|
135
|
-
async function
|
|
150
|
+
async function M(e) {
|
|
136
151
|
const r = n(), { error: t } = await r.from("product_attribute_terms").delete().eq("id", e);
|
|
137
152
|
return t ? { success: !1, error: t.message } : (s("/cms/products/attributes"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
|
|
138
153
|
}
|
|
139
|
-
async function
|
|
154
|
+
async function R(e) {
|
|
140
155
|
const r = n(), t = e.name.trim(), c = d(e.slug?.trim() || e.name);
|
|
141
156
|
if (!t || !c)
|
|
142
157
|
return { success: !1, error: "Category name is required." };
|
|
143
|
-
const { data:
|
|
158
|
+
const { data: o, error: a } = await r.from("categories").insert({
|
|
144
159
|
name: t,
|
|
145
160
|
slug: c,
|
|
146
161
|
description: e.description?.trim() || null,
|
|
147
162
|
name_translations: e.nameTranslations || {},
|
|
148
163
|
description_translations: e.descriptionTranslations || {}
|
|
149
164
|
}).select().single();
|
|
150
|
-
return
|
|
165
|
+
return a ? { success: !1, error: a.message } : (s("/cms/products/categories"), s("/cms/products/new"), s("/cms/products"), { success: !0, category: o });
|
|
151
166
|
}
|
|
152
167
|
async function B(e, r) {
|
|
153
|
-
const t = n(), c = r.name.trim(),
|
|
154
|
-
if (!c || !
|
|
168
|
+
const t = n(), c = r.name.trim(), o = d(r.slug?.trim() || r.name);
|
|
169
|
+
if (!c || !o)
|
|
155
170
|
return { success: !1, error: "Category name is required." };
|
|
156
|
-
const { error:
|
|
171
|
+
const { error: a } = await t.from("categories").update({
|
|
157
172
|
name: c,
|
|
158
|
-
slug:
|
|
173
|
+
slug: o,
|
|
159
174
|
description: r.description?.trim() || null,
|
|
160
175
|
name_translations: r.nameTranslations || {},
|
|
161
176
|
description_translations: r.descriptionTranslations || {}
|
|
162
177
|
}).eq("id", e);
|
|
163
|
-
return
|
|
178
|
+
return a ? { success: !1, error: a.message } : (s("/cms/products/categories"), s("/cms/products/new"), s("/cms/products"), { success: !0 });
|
|
164
179
|
}
|
|
165
180
|
async function G(e) {
|
|
166
181
|
const r = n(), { error: t } = await r.from("categories").delete().eq("id", e);
|
|
@@ -177,15 +192,16 @@ async function L(e, r) {
|
|
|
177
192
|
export {
|
|
178
193
|
D as bulkDeleteProductsAction,
|
|
179
194
|
F as bulkDraftProductsAction,
|
|
180
|
-
|
|
195
|
+
R as createCategoryAction,
|
|
181
196
|
C as createProductAction,
|
|
182
197
|
z as createProductAttributeAction,
|
|
183
|
-
|
|
198
|
+
$ as createProductAttributeTermAction,
|
|
184
199
|
G as deleteCategoryAction,
|
|
185
200
|
x as deleteProductAction,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
201
|
+
E as deleteProductAttributeAction,
|
|
202
|
+
M as deleteProductAttributeTermAction,
|
|
203
|
+
O as publishProductAction,
|
|
204
|
+
U as reorderProductAttributeTermsAction,
|
|
189
205
|
L as syncProductCategoriesAction,
|
|
190
206
|
B as updateCategoryAction,
|
|
191
207
|
I as updateProductAction,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextblock-cms/ecom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nextblock-cms/db": "^0.
|
|
14
|
-
"@nextblock-cms/ui": "^0.
|
|
15
|
-
"@nextblock-cms/utils": "^0.
|
|
13
|
+
"@nextblock-cms/db": "^0.13.2",
|
|
14
|
+
"@nextblock-cms/ui": "^0.13.2",
|
|
15
|
+
"@nextblock-cms/utils": "^0.13.2",
|
|
16
16
|
"@freemius/checkout": "^1.4.1",
|
|
17
17
|
"@freemius/sdk": "^0.3.0",
|
|
18
18
|
"@hookform/resolvers": "^5.2.2",
|
package/server.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./lib/payment-config.cjs.js"),h=require("./lib/stripe/client.cjs.js"),O=require("./lib/stripe/checkout.cjs.js"),A=require("./lib/stripe/order-sync.cjs.js"),R=require("./lib/stripe/webhooks.cjs.js"),T=require("./lib/order-inventory.cjs.js"),o=require("./lib/order-tax-details.cjs.js"),n=require("./lib/invoice.cjs.js"),g=require("./lib/invoice-server.cjs.js"),l=require("./lib/customer-orders.cjs.js"),C=require("./lib/coupon-server.cjs.js"),P=require("./lib/freemius-coupons.cjs.js"),d=require("./lib/customer.cjs.js"),m=require("./lib/customer-addresses.cjs.js"),e=require("./lib/currency.cjs.js"),q=require("./lib/currency-constants.cjs.js"),p=require("./lib/currency-sync.cjs.js"),D=require("./lib/product-schema.cjs.js"),r=require("./lib/product-actions.cjs.js"),E=require("./lib/factory.cjs.js"),I=require("./lib/providers/stripe.cjs.js"),c=require("./lib/providers/freemius.cjs.js"),i=require("./lib/freemius-order-sync.cjs.js"),b=require("./lib/freemius-license.cjs.js"),a=require("./lib/pages/cms/products/actions.cjs.js"),s=require("./lib/pages/cms/products/server-actions.cjs.js"),y=require("./lib/pages/cms/payments/queries.cjs.js"),f=require("./lib/pages/cms/orders/OrdersPage.cjs.js"),x=require("./lib/pages/cms/orders/OrderDetailPage.cjs.js"),k=require("./lib/pages/cms/orders/ExportReportsDialog.cjs.js"),M=require("./lib/pages/cms/orders/export-actions.cjs.js"),v=require("./lib/pages/cms/orders/actions.cjs.js"),L=require("./lib/pages/cms/products/ProductsPage.cjs.js"),N=require("./lib/pages/cms/products/inventory/InventoryPage.cjs.js"),z=require("./lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js"),_=require("./lib/pages/cms/products/new/NewProductPage.cjs.js"),U=require("./lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js"),W=require("./lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js"),G=require("./lib/pages/cms/products/categories/CategoryManagementPage.cjs.js"),w=require("./lib/pages/cms/payments/PaymentsPage.cjs.js"),F=require("./lib/pages/cms/payments/actions.cjs.js"),K=require("./lib/pages/cms/shipping/ShippingPage.cjs.js"),u=require("./lib/pages/cms/shipping/server-actions.cjs.js"),V=require("./lib/pages/cms/taxes/TaxesPage.cjs.js"),S=require("./lib/pages/cms/taxes/actions.cjs.js"),B=require("./lib/pages/cms/coupons/CouponsPage.cjs.js"),Y=require("./lib/pages/cms/coupons/EditCouponPage.cjs.js");exports.clearPaymentConfigCache=t.clearPaymentConfigCache;exports.getPaymentConfigStatus=t.getPaymentConfigStatus;exports.getPaymentCredentialsView=t.getPaymentCredentialsView;exports.hydrateFreemiusEnvFromDb=t.hydrateFreemiusEnvFromDb;exports.resolveStripePublishableKey=t.resolveStripePublishableKey;exports.resolveStripeSecretKey=t.resolveStripeSecretKey;exports.resolveStripeWebhookSecret=t.resolveStripeWebhookSecret;exports.savePaymentCredentials=t.savePaymentCredentials;exports.getStripeClient=h.getStripeClient;exports.createCheckoutSession=O.createCheckoutSession;exports.syncStripeOrderFromSession=A.syncStripeOrderFromSession;exports.handleStripeWebhook=R.handleStripeWebhook;exports.applyOrderInventoryDeduction=T.applyOrderInventoryDeduction;exports.aggregateOrderTaxLines=o.aggregateOrderTaxLines;exports.buildOrderTaxDetailsFromCalculation=o.buildOrderTaxDetailsFromCalculation;exports.buildOrderTaxDetailsFromStripeSession=o.buildOrderTaxDetailsFromStripeSession;exports.getOrderTaxRateJurisdiction=o.getOrderTaxRateJurisdiction;exports.getOrderTaxRateLabel=o.getOrderTaxRateLabel;exports.getOrderTaxRatePercentage=o.getOrderTaxRatePercentage;exports.normalizeOrderTaxDetails=o.normalizeOrderTaxDetails;exports.DEFAULT_INVOICE_SETTINGS=n.DEFAULT_INVOICE_SETTINGS;exports.INVOICE_SETTINGS_KEY=n.INVOICE_SETTINGS_KEY;exports.formatInvoiceCurrency=n.formatInvoiceCurrency;exports.formatInvoiceDate=n.formatInvoiceDate;exports.getInvoiceAddressLines=n.getInvoiceAddressLines;exports.normalizeInvoiceSettings=n.normalizeInvoiceSettings;exports.serializeInvoiceSettings=n.serializeInvoiceSettings;exports.assignInvoiceMetadata=g.assignInvoiceMetadata;exports.getInvoiceBrandingData=g.getInvoiceBrandingData;exports.getInvoiceOrder=g.getInvoiceOrder;exports.getInvoicePresentationData=g.getInvoicePresentationData;exports.getCurrentCustomerOrder=l.getCurrentCustomerOrder;exports.getCurrentCustomerOrderInvoice=l.getCurrentCustomerOrderInvoice;exports.getCurrentCustomerOrders=l.getCurrentCustomerOrders;exports.getCouponQuote=C.getCouponQuote;exports.getQuoteLineDiscountMap=C.getQuoteLineDiscountMap;exports.recordCouponRedemption=C.recordCouponRedemption;exports.deleteCouponFromFreemius=P.deleteCouponFromFreemius;exports.syncCouponToFreemius=P.syncCouponToFreemius;exports.syncProductSaleCouponToFreemius=P.syncProductSaleCouponToFreemius;exports.addressesMatch=d.addressesMatch;exports.emptyCustomerAddress=d.emptyCustomerAddress;exports.isCustomerAddressComplete=d.isCustomerAddressComplete;exports.normalizeCustomerAddress=d.normalizeCustomerAddress;exports.normalizeOrderCustomerDetails=d.normalizeOrderCustomerDetails;exports.fillMissingUserProfileCheckoutDetails=m.fillMissingUserProfileCheckoutDetails;exports.getDefaultUserAddresses=m.getDefaultUserAddresses;exports.upsertDefaultUserAddresses=m.upsertDefaultUserAddresses;exports.CURRENCY_ROUNDING_MODES=e.CURRENCY_ROUNDING_MODES;exports.applyCurrencyRounding=e.applyCurrencyRounding;exports.convertMinorUnitAmount=e.convertMinorUnitAmount;exports.describeCurrencyRoundingRule=e.describeCurrencyRoundingRule;exports.getCurrencyLookup=e.getCurrencyLookup;exports.getDefaultCurrency=e.getDefaultCurrency;exports.getExchangeRateForCurrency=e.getExchangeRateForCurrency;exports.inferCurrencyCodeFromLocale=e.inferCurrencyCodeFromLocale;exports.isSaleWindowActive=e.isSaleWindowActive;exports.isScheduledPriceDue=e.isScheduledPriceDue;exports.normalizeCurrencyRecord=e.normalizeCurrencyRecord;exports.normalizeCurrencyRoundingMode=e.normalizeCurrencyRoundingMode;exports.normalizePriceMap=e.normalizePriceMap;exports.normalizeSalePriceMap=e.normalizeSalePriceMap;exports.resolveEffectivePriceForCurrency=e.resolveEffectivePriceForCurrency;exports.resolvePriceForCurrency=e.resolvePriceForCurrency;exports.resolvePriceRangeForCurrency=e.resolvePriceRangeForCurrency;exports.sortCurrencies=e.sortCurrencies;exports.CURRENCY_COOKIE_NAME=q.CURRENCY_COOKIE_NAME;exports.clearAutoSyncedCurrencyPriceOverrides=p.clearAutoSyncedCurrencyPriceOverrides;exports.rebaseStoreCurrencyExchangeRates=p.rebaseStoreCurrencyExchangeRates;exports.syncStoreCurrencyRates=p.syncStoreCurrencyRates;exports.productSchema=D.productSchema;exports.copyProductFromLanguage=r.copyProductFromLanguage;exports.createProduct=r.createProduct;exports.deleteProduct=r.deleteProduct;exports.fetchTranslatedProductsForCartInternal=r.fetchTranslatedProductsForCartInternal;exports.getProduct=r.getProduct;exports.getProductBySlug=r.getProductBySlug;exports.getProducts=r.getProducts;exports.syncCategoriesForTranslationGroup=r.syncCategoriesForTranslationGroup;exports.updateProduct=r.updateProduct;exports.getPaymentProvider=E.getPaymentProvider;exports.StripeProvider=I.StripeProvider;exports.FreemiusProvider=c.FreemiusProvider;exports.parseFreemiusCheckoutCredentialsMap=c.parseFreemiusCheckoutCredentialsMap;exports.readFreemiusEnvValue=c.readFreemiusEnvValue;exports.resolveFreemiusCheckoutCredentials=c.resolveFreemiusCheckoutCredentials;exports.syncFreemiusProductsToSupabase=c.syncFreemiusProductsToSupabase;exports.syncSingleFreemiusProduct=c.syncSingleFreemiusProduct;exports.extractFreemiusCheckoutMetadata=i.extractFreemiusCheckoutMetadata;exports.getFreemiusWebhookSecretCandidates=i.getFreemiusWebhookSecretCandidates;exports.resolveFreemiusStatusFromCheckoutResponse=i.resolveFreemiusStatusFromCheckoutResponse;exports.resolveFreemiusStatusFromWebhookEvent=i.resolveFreemiusStatusFromWebhookEvent;exports.syncFreemiusCheckoutOrder=i.syncFreemiusCheckoutOrder;exports.syncFreemiusOrderFromWebhookEvent=i.syncFreemiusOrderFromWebhookEvent;exports.verifyFreemiusWebhookSignature=i.verifyFreemiusWebhookSignature;exports.getFreemiusOrderLicense=b.getFreemiusOrderLicense;exports.getCategoriesWithCount=a.getCategoriesWithCount;exports.getCategoryBySlug=a.getCategoryBySlug;exports.getCmsProduct=a.getProduct;exports.getCmsProducts=a.getProducts;exports.getGlobalProductAttributes=a.getGlobalProductAttributes;exports.getProductCategories=a.getProductCategories;exports.getProductTranslations=a.getProductTranslations;exports.createCategoryAction=s.createCategoryAction;exports.createProductAction=s.createProductAction;exports.deleteCategoryAction=s.deleteCategoryAction;exports.deleteProductAction=s.deleteProductAction;exports.syncProductCategoriesAction=s.syncProductCategoriesAction;exports.updateCategoryAction=s.updateCategoryAction;exports.updateProductAction=s.updateProductAction;exports.getEnabledPaymentProviders=y.getEnabledPaymentProviders;exports.getPaymentSettings=y.getPaymentSettings;exports.getStoreConfigStatus=y.getStoreConfigStatus;exports.OrdersPage=f.OrdersPage;exports.OrderDetailPage=x.OrderDetailPage;exports.ExportReportsDialog=k.ExportReportsDialog;exports.fetchOrderReportData=M.fetchOrderReportData;exports.getOrderDetails=v.getOrderDetails;exports.getOrders=v.getOrders;exports.ProductsPage=L.ProductsPage;exports.InventoryPage=N.InventoryPage;exports.AttributeManagementPage=z.AttributeManagementPage;exports.NewProductPage=_.NewProductPage;exports.EditProductPage=U.EditProductPage;exports.CopyProductFromLanguage=W.CopyProductFromLanguage;exports.CategoryManagementPage=G.CategoryManagementPage;exports.PaymentsPage=w.PaymentsPage;exports.savePaymentProviderCredentials=F.savePaymentProviderCredentials;exports.updatePaymentSettings=F.updatePaymentSettings;exports.ShippingPage=K.ShippingPage;exports.createShippingRate=u.createShippingRate;exports.createShippingZone=u.createShippingZone;exports.deleteShippingRate=u.deleteShippingRate;exports.deleteShippingZone=u.deleteShippingZone;exports.updateInventoryTrackingAction=u.updateInventoryTrackingAction;exports.updateShippingRate=u.updateShippingRate;exports.updateShippingZone=u.updateShippingZone;exports.TaxesPage=V.TaxesPage;exports.deleteTaxRateAction=S.deleteTaxRateAction;exports.saveTaxRateAction=S.saveTaxRateAction;exports.updateTaxSettingsAction=S.updateTaxSettingsAction;exports.CouponsPage=B.CouponsPage;exports.EditCouponPage=Y.EditCouponPage;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./lib/payment-config.cjs.js"),h=require("./lib/stripe/client.cjs.js"),O=require("./lib/stripe/checkout.cjs.js"),A=require("./lib/stripe/order-sync.cjs.js"),R=require("./lib/stripe/webhooks.cjs.js"),T=require("./lib/order-inventory.cjs.js"),n=require("./lib/order-tax-details.cjs.js"),i=require("./lib/invoice.cjs.js"),g=require("./lib/invoice-server.cjs.js"),l=require("./lib/customer-orders.cjs.js"),C=require("./lib/coupon-server.cjs.js"),P=require("./lib/freemius-coupons.cjs.js"),d=require("./lib/customer.cjs.js"),m=require("./lib/customer-addresses.cjs.js"),e=require("./lib/currency.cjs.js"),q=require("./lib/currency-constants.cjs.js"),p=require("./lib/currency-sync.cjs.js"),D=require("./lib/product-schema.cjs.js"),r=require("./lib/product-actions.cjs.js"),E=require("./lib/factory.cjs.js"),b=require("./lib/providers/stripe.cjs.js"),c=require("./lib/providers/freemius.cjs.js"),a=require("./lib/freemius-order-sync.cjs.js"),I=require("./lib/freemius-license.cjs.js"),s=require("./lib/pages/cms/products/actions.cjs.js"),o=require("./lib/pages/cms/products/server-actions.cjs.js"),y=require("./lib/pages/cms/payments/queries.cjs.js"),f=require("./lib/pages/cms/orders/OrdersPage.cjs.js"),x=require("./lib/pages/cms/orders/OrderDetailPage.cjs.js"),k=require("./lib/pages/cms/orders/ExportReportsDialog.cjs.js"),M=require("./lib/pages/cms/orders/export-actions.cjs.js"),v=require("./lib/pages/cms/orders/actions.cjs.js"),L=require("./lib/pages/cms/products/ProductsPage.cjs.js"),N=require("./lib/pages/cms/products/inventory/InventoryPage.cjs.js"),z=require("./lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js"),_=require("./lib/pages/cms/products/new/NewProductPage.cjs.js"),U=require("./lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js"),W=require("./lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js"),G=require("./lib/pages/cms/products/categories/CategoryManagementPage.cjs.js"),w=require("./lib/pages/cms/payments/PaymentsPage.cjs.js"),F=require("./lib/pages/cms/payments/actions.cjs.js"),K=require("./lib/pages/cms/shipping/ShippingPage.cjs.js"),u=require("./lib/pages/cms/shipping/server-actions.cjs.js"),V=require("./lib/pages/cms/taxes/TaxesPage.cjs.js"),S=require("./lib/pages/cms/taxes/actions.cjs.js"),B=require("./lib/pages/cms/coupons/CouponsPage.cjs.js"),Y=require("./lib/pages/cms/coupons/EditCouponPage.cjs.js");exports.clearPaymentConfigCache=t.clearPaymentConfigCache;exports.getPaymentConfigStatus=t.getPaymentConfigStatus;exports.getPaymentCredentialsView=t.getPaymentCredentialsView;exports.hydrateFreemiusEnvFromDb=t.hydrateFreemiusEnvFromDb;exports.resolveStripePublishableKey=t.resolveStripePublishableKey;exports.resolveStripeSecretKey=t.resolveStripeSecretKey;exports.resolveStripeWebhookSecret=t.resolveStripeWebhookSecret;exports.savePaymentCredentials=t.savePaymentCredentials;exports.getStripeClient=h.getStripeClient;exports.createCheckoutSession=O.createCheckoutSession;exports.syncStripeOrderFromSession=A.syncStripeOrderFromSession;exports.handleStripeWebhook=R.handleStripeWebhook;exports.applyOrderInventoryDeduction=T.applyOrderInventoryDeduction;exports.aggregateOrderTaxLines=n.aggregateOrderTaxLines;exports.buildOrderTaxDetailsFromCalculation=n.buildOrderTaxDetailsFromCalculation;exports.buildOrderTaxDetailsFromStripeSession=n.buildOrderTaxDetailsFromStripeSession;exports.getOrderTaxRateJurisdiction=n.getOrderTaxRateJurisdiction;exports.getOrderTaxRateLabel=n.getOrderTaxRateLabel;exports.getOrderTaxRatePercentage=n.getOrderTaxRatePercentage;exports.normalizeOrderTaxDetails=n.normalizeOrderTaxDetails;exports.DEFAULT_INVOICE_SETTINGS=i.DEFAULT_INVOICE_SETTINGS;exports.INVOICE_SETTINGS_KEY=i.INVOICE_SETTINGS_KEY;exports.formatInvoiceCurrency=i.formatInvoiceCurrency;exports.formatInvoiceDate=i.formatInvoiceDate;exports.getInvoiceAddressLines=i.getInvoiceAddressLines;exports.normalizeInvoiceSettings=i.normalizeInvoiceSettings;exports.serializeInvoiceSettings=i.serializeInvoiceSettings;exports.assignInvoiceMetadata=g.assignInvoiceMetadata;exports.getInvoiceBrandingData=g.getInvoiceBrandingData;exports.getInvoiceOrder=g.getInvoiceOrder;exports.getInvoicePresentationData=g.getInvoicePresentationData;exports.getCurrentCustomerOrder=l.getCurrentCustomerOrder;exports.getCurrentCustomerOrderInvoice=l.getCurrentCustomerOrderInvoice;exports.getCurrentCustomerOrders=l.getCurrentCustomerOrders;exports.getCouponQuote=C.getCouponQuote;exports.getQuoteLineDiscountMap=C.getQuoteLineDiscountMap;exports.recordCouponRedemption=C.recordCouponRedemption;exports.deleteCouponFromFreemius=P.deleteCouponFromFreemius;exports.syncCouponToFreemius=P.syncCouponToFreemius;exports.syncProductSaleCouponToFreemius=P.syncProductSaleCouponToFreemius;exports.addressesMatch=d.addressesMatch;exports.emptyCustomerAddress=d.emptyCustomerAddress;exports.isCustomerAddressComplete=d.isCustomerAddressComplete;exports.normalizeCustomerAddress=d.normalizeCustomerAddress;exports.normalizeOrderCustomerDetails=d.normalizeOrderCustomerDetails;exports.fillMissingUserProfileCheckoutDetails=m.fillMissingUserProfileCheckoutDetails;exports.getDefaultUserAddresses=m.getDefaultUserAddresses;exports.upsertDefaultUserAddresses=m.upsertDefaultUserAddresses;exports.CURRENCY_ROUNDING_MODES=e.CURRENCY_ROUNDING_MODES;exports.applyCurrencyRounding=e.applyCurrencyRounding;exports.convertMinorUnitAmount=e.convertMinorUnitAmount;exports.describeCurrencyRoundingRule=e.describeCurrencyRoundingRule;exports.getCurrencyLookup=e.getCurrencyLookup;exports.getDefaultCurrency=e.getDefaultCurrency;exports.getExchangeRateForCurrency=e.getExchangeRateForCurrency;exports.inferCurrencyCodeFromLocale=e.inferCurrencyCodeFromLocale;exports.isSaleWindowActive=e.isSaleWindowActive;exports.isScheduledPriceDue=e.isScheduledPriceDue;exports.normalizeCurrencyRecord=e.normalizeCurrencyRecord;exports.normalizeCurrencyRoundingMode=e.normalizeCurrencyRoundingMode;exports.normalizePriceMap=e.normalizePriceMap;exports.normalizeSalePriceMap=e.normalizeSalePriceMap;exports.resolveEffectivePriceForCurrency=e.resolveEffectivePriceForCurrency;exports.resolvePriceForCurrency=e.resolvePriceForCurrency;exports.resolvePriceRangeForCurrency=e.resolvePriceRangeForCurrency;exports.sortCurrencies=e.sortCurrencies;exports.CURRENCY_COOKIE_NAME=q.CURRENCY_COOKIE_NAME;exports.clearAutoSyncedCurrencyPriceOverrides=p.clearAutoSyncedCurrencyPriceOverrides;exports.rebaseStoreCurrencyExchangeRates=p.rebaseStoreCurrencyExchangeRates;exports.syncStoreCurrencyRates=p.syncStoreCurrencyRates;exports.productSchema=D.productSchema;exports.copyProductFromLanguage=r.copyProductFromLanguage;exports.createProduct=r.createProduct;exports.deleteProduct=r.deleteProduct;exports.fetchTranslatedProductsForCartInternal=r.fetchTranslatedProductsForCartInternal;exports.getProduct=r.getProduct;exports.getProductBySlug=r.getProductBySlug;exports.getProducts=r.getProducts;exports.syncCategoriesForTranslationGroup=r.syncCategoriesForTranslationGroup;exports.updateProduct=r.updateProduct;exports.getPaymentProvider=E.getPaymentProvider;exports.StripeProvider=b.StripeProvider;exports.FreemiusProvider=c.FreemiusProvider;exports.parseFreemiusCheckoutCredentialsMap=c.parseFreemiusCheckoutCredentialsMap;exports.readFreemiusEnvValue=c.readFreemiusEnvValue;exports.resolveFreemiusCheckoutCredentials=c.resolveFreemiusCheckoutCredentials;exports.syncFreemiusProductsToSupabase=c.syncFreemiusProductsToSupabase;exports.syncSingleFreemiusProduct=c.syncSingleFreemiusProduct;exports.extractFreemiusCheckoutMetadata=a.extractFreemiusCheckoutMetadata;exports.getFreemiusWebhookSecretCandidates=a.getFreemiusWebhookSecretCandidates;exports.resolveFreemiusStatusFromCheckoutResponse=a.resolveFreemiusStatusFromCheckoutResponse;exports.resolveFreemiusStatusFromWebhookEvent=a.resolveFreemiusStatusFromWebhookEvent;exports.syncFreemiusCheckoutOrder=a.syncFreemiusCheckoutOrder;exports.syncFreemiusOrderFromWebhookEvent=a.syncFreemiusOrderFromWebhookEvent;exports.verifyFreemiusWebhookSignature=a.verifyFreemiusWebhookSignature;exports.getFreemiusOrderLicense=I.getFreemiusOrderLicense;exports.getCategoriesWithCount=s.getCategoriesWithCount;exports.getCategoryBySlug=s.getCategoryBySlug;exports.getCmsProduct=s.getProduct;exports.getCmsProducts=s.getProducts;exports.getGlobalProductAttributes=s.getGlobalProductAttributes;exports.getProductCategories=s.getProductCategories;exports.getProductTranslations=s.getProductTranslations;exports.createCategoryAction=o.createCategoryAction;exports.createProductAction=o.createProductAction;exports.deleteCategoryAction=o.deleteCategoryAction;exports.deleteProductAction=o.deleteProductAction;exports.publishProductAction=o.publishProductAction;exports.syncProductCategoriesAction=o.syncProductCategoriesAction;exports.updateCategoryAction=o.updateCategoryAction;exports.updateProductAction=o.updateProductAction;exports.getEnabledPaymentProviders=y.getEnabledPaymentProviders;exports.getPaymentSettings=y.getPaymentSettings;exports.getStoreConfigStatus=y.getStoreConfigStatus;exports.OrdersPage=f.OrdersPage;exports.OrderDetailPage=x.OrderDetailPage;exports.ExportReportsDialog=k.ExportReportsDialog;exports.fetchOrderReportData=M.fetchOrderReportData;exports.getOrderDetails=v.getOrderDetails;exports.getOrders=v.getOrders;exports.ProductsPage=L.ProductsPage;exports.InventoryPage=N.InventoryPage;exports.AttributeManagementPage=z.AttributeManagementPage;exports.NewProductPage=_.NewProductPage;exports.EditProductPage=U.EditProductPage;exports.CopyProductFromLanguage=W.CopyProductFromLanguage;exports.CategoryManagementPage=G.CategoryManagementPage;exports.PaymentsPage=w.PaymentsPage;exports.savePaymentProviderCredentials=F.savePaymentProviderCredentials;exports.updatePaymentSettings=F.updatePaymentSettings;exports.ShippingPage=K.ShippingPage;exports.createShippingRate=u.createShippingRate;exports.createShippingZone=u.createShippingZone;exports.deleteShippingRate=u.deleteShippingRate;exports.deleteShippingZone=u.deleteShippingZone;exports.updateInventoryTrackingAction=u.updateInventoryTrackingAction;exports.updateShippingRate=u.updateShippingRate;exports.updateShippingZone=u.updateShippingZone;exports.TaxesPage=V.TaxesPage;exports.deleteTaxRateAction=S.deleteTaxRateAction;exports.saveTaxRateAction=S.saveTaxRateAction;exports.updateTaxSettingsAction=S.updateTaxSettingsAction;exports.CouponsPage=B.CouponsPage;exports.EditCouponPage=Y.EditCouponPage;
|
package/server.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export * from './lib/providers/freemius';
|
|
|
23
23
|
export * from './lib/freemius-order-sync';
|
|
24
24
|
export * from './lib/freemius-license';
|
|
25
25
|
export { getProduct as getCmsProduct, getProducts as getCmsProducts, getGlobalProductAttributes, getProductTranslations, getCategoriesWithCount, getProductCategories, getCategoryBySlug, } from './lib/pages/cms/products/actions';
|
|
26
|
-
export { createProductAction, updateProductAction, deleteProductAction, createCategoryAction, updateCategoryAction, deleteCategoryAction, syncProductCategoriesAction, } from './lib/pages/cms/products/server-actions';
|
|
26
|
+
export { createProductAction, updateProductAction, publishProductAction, deleteProductAction, createCategoryAction, updateCategoryAction, deleteCategoryAction, syncProductCategoriesAction, } from './lib/pages/cms/products/server-actions';
|
|
27
27
|
export { getEnabledPaymentProviders, getPaymentSettings, getStoreConfigStatus, } from './lib/pages/cms/payments/queries';
|
|
28
28
|
export * from './lib/pages/cms/orders';
|
|
29
29
|
export * from './lib/pages/cms/products';
|
package/server.es.js
CHANGED
|
@@ -23,50 +23,50 @@ import { FreemiusProvider as He, parseFreemiusCheckoutCredentialsMap as Xe, read
|
|
|
23
23
|
import { extractFreemiusCheckoutMetadata as ar, getFreemiusWebhookSecretCandidates as nr, resolveFreemiusStatusFromCheckoutResponse as ir, resolveFreemiusStatusFromWebhookEvent as sr, syncFreemiusCheckoutOrder as ur, syncFreemiusOrderFromWebhookEvent as cr, verifyFreemiusWebhookSignature as dr } from "./lib/freemius-order-sync.es.js";
|
|
24
24
|
import { getFreemiusOrderLicense as pr } from "./lib/freemius-license.es.js";
|
|
25
25
|
import { getCategoriesWithCount as lr, getCategoryBySlug as Cr, getProduct as Pr, getProducts as fr, getGlobalProductAttributes as xr, getProductCategories as yr, getProductTranslations as Sr } from "./lib/pages/cms/products/actions.es.js";
|
|
26
|
-
import { createCategoryAction as Fr, createProductAction as hr, deleteCategoryAction as Or, deleteProductAction as Rr,
|
|
27
|
-
import { getEnabledPaymentProviders as
|
|
28
|
-
import { OrdersPage as
|
|
29
|
-
import { OrderDetailPage as
|
|
30
|
-
import { ExportReportsDialog as
|
|
31
|
-
import { fetchOrderReportData as
|
|
32
|
-
import { getOrderDetails as
|
|
33
|
-
import { ProductsPage as
|
|
34
|
-
import { InventoryPage as
|
|
35
|
-
import { AttributeManagementPage as
|
|
36
|
-
import { NewProductPage as
|
|
37
|
-
import { EditProductPage as
|
|
38
|
-
import { CopyProductFromLanguage as
|
|
39
|
-
import { CategoryManagementPage as
|
|
40
|
-
import { PaymentsPage as
|
|
41
|
-
import { savePaymentProviderCredentials as
|
|
42
|
-
import { ShippingPage as
|
|
43
|
-
import { createShippingRate as
|
|
44
|
-
import { TaxesPage as
|
|
45
|
-
import { deleteTaxRateAction as
|
|
46
|
-
import { CouponsPage as
|
|
47
|
-
import { EditCouponPage as
|
|
26
|
+
import { createCategoryAction as Fr, createProductAction as hr, deleteCategoryAction as Or, deleteProductAction as Rr, publishProductAction as Ar, syncProductCategoriesAction as Tr, updateCategoryAction as Dr, updateProductAction as Er } from "./lib/pages/cms/products/server-actions.es.js";
|
|
27
|
+
import { getEnabledPaymentProviders as br, getPaymentSettings as kr, getStoreConfigStatus as Mr } from "./lib/pages/cms/payments/queries.es.js";
|
|
28
|
+
import { OrdersPage as Nr } from "./lib/pages/cms/orders/OrdersPage.es.js";
|
|
29
|
+
import { OrderDetailPage as Ur } from "./lib/pages/cms/orders/OrderDetailPage.es.js";
|
|
30
|
+
import { ExportReportsDialog as _r } from "./lib/pages/cms/orders/ExportReportsDialog.es.js";
|
|
31
|
+
import { fetchOrderReportData as Kr } from "./lib/pages/cms/orders/export-actions.es.js";
|
|
32
|
+
import { getOrderDetails as wr, getOrders as Br } from "./lib/pages/cms/orders/actions.es.js";
|
|
33
|
+
import { ProductsPage as Zr } from "./lib/pages/cms/products/ProductsPage.es.js";
|
|
34
|
+
import { InventoryPage as Jr } from "./lib/pages/cms/products/inventory/InventoryPage.es.js";
|
|
35
|
+
import { AttributeManagementPage as qr } from "./lib/pages/cms/products/attributes/AttributeManagementPage.es.js";
|
|
36
|
+
import { NewProductPage as Xr } from "./lib/pages/cms/products/new/NewProductPage.es.js";
|
|
37
|
+
import { EditProductPage as et } from "./lib/pages/cms/products/_id_/edit/EditProductPage.es.js";
|
|
38
|
+
import { CopyProductFromLanguage as tt } from "./lib/pages/cms/products/components/CopyProductFromLanguage.es.js";
|
|
39
|
+
import { CategoryManagementPage as at } from "./lib/pages/cms/products/categories/CategoryManagementPage.es.js";
|
|
40
|
+
import { PaymentsPage as it } from "./lib/pages/cms/payments/PaymentsPage.es.js";
|
|
41
|
+
import { savePaymentProviderCredentials as ut, updatePaymentSettings as ct } from "./lib/pages/cms/payments/actions.es.js";
|
|
42
|
+
import { ShippingPage as mt } from "./lib/pages/cms/shipping/ShippingPage.es.js";
|
|
43
|
+
import { createShippingRate as gt, createShippingZone as lt, deleteShippingRate as Ct, deleteShippingZone as Pt, updateInventoryTrackingAction as ft, updateShippingRate as xt, updateShippingZone as yt } from "./lib/pages/cms/shipping/server-actions.es.js";
|
|
44
|
+
import { TaxesPage as vt } from "./lib/pages/cms/taxes/TaxesPage.es.js";
|
|
45
|
+
import { deleteTaxRateAction as ht, saveTaxRateAction as Ot, updateTaxSettingsAction as Rt } from "./lib/pages/cms/taxes/actions.es.js";
|
|
46
|
+
import { CouponsPage as Tt } from "./lib/pages/cms/coupons/CouponsPage.es.js";
|
|
47
|
+
import { EditCouponPage as Et } from "./lib/pages/cms/coupons/EditCouponPage.es.js";
|
|
48
48
|
export {
|
|
49
|
-
|
|
49
|
+
qr as AttributeManagementPage,
|
|
50
50
|
Ee as CURRENCY_COOKIE_NAME,
|
|
51
51
|
de as CURRENCY_ROUNDING_MODES,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
at as CategoryManagementPage,
|
|
53
|
+
tt as CopyProductFromLanguage,
|
|
54
|
+
Tt as CouponsPage,
|
|
55
55
|
E as DEFAULT_INVOICE_SETTINGS,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
Et as EditCouponPage,
|
|
57
|
+
et as EditProductPage,
|
|
58
|
+
_r as ExportReportsDialog,
|
|
59
59
|
He as FreemiusProvider,
|
|
60
60
|
I as INVOICE_SETTINGS_KEY,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
Jr as InventoryPage,
|
|
62
|
+
Xr as NewProductPage,
|
|
63
|
+
Ur as OrderDetailPage,
|
|
64
|
+
Nr as OrdersPage,
|
|
65
|
+
it as PaymentsPage,
|
|
66
|
+
Zr as ProductsPage,
|
|
67
|
+
mt as ShippingPage,
|
|
68
68
|
je as StripeProvider,
|
|
69
|
-
|
|
69
|
+
vt as TaxesPage,
|
|
70
70
|
ee as addressesMatch,
|
|
71
71
|
v as aggregateOrderTaxLines,
|
|
72
72
|
me as applyCurrencyRounding,
|
|
@@ -82,19 +82,19 @@ export {
|
|
|
82
82
|
g as createCheckoutSession,
|
|
83
83
|
We as createProduct,
|
|
84
84
|
hr as createProductAction,
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
gt as createShippingRate,
|
|
86
|
+
lt as createShippingZone,
|
|
87
87
|
Or as deleteCategoryAction,
|
|
88
88
|
q as deleteCouponFromFreemius,
|
|
89
89
|
_e as deleteProduct,
|
|
90
90
|
Rr as deleteProductAction,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
Ct as deleteShippingRate,
|
|
92
|
+
Pt as deleteShippingZone,
|
|
93
|
+
ht as deleteTaxRateAction,
|
|
94
94
|
ge as describeCurrencyRoundingRule,
|
|
95
95
|
re as emptyCustomerAddress,
|
|
96
96
|
ar as extractFreemiusCheckoutMetadata,
|
|
97
|
-
|
|
97
|
+
Kr as fetchOrderReportData,
|
|
98
98
|
Ge as fetchTranslatedProductsForCartInternal,
|
|
99
99
|
ie as fillMissingUserProfileCheckoutDetails,
|
|
100
100
|
b as formatInvoiceCurrency,
|
|
@@ -110,7 +110,7 @@ export {
|
|
|
110
110
|
B as getCurrentCustomerOrders,
|
|
111
111
|
Ce as getDefaultCurrency,
|
|
112
112
|
se as getDefaultUserAddresses,
|
|
113
|
-
|
|
113
|
+
br as getEnabledPaymentProviders,
|
|
114
114
|
Pe as getExchangeRateForCurrency,
|
|
115
115
|
pr as getFreemiusOrderLicense,
|
|
116
116
|
nr as getFreemiusWebhookSecretCandidates,
|
|
@@ -119,22 +119,22 @@ export {
|
|
|
119
119
|
W as getInvoiceBrandingData,
|
|
120
120
|
_ as getInvoiceOrder,
|
|
121
121
|
G as getInvoicePresentationData,
|
|
122
|
-
|
|
122
|
+
wr as getOrderDetails,
|
|
123
123
|
O as getOrderTaxRateJurisdiction,
|
|
124
124
|
R as getOrderTaxRateLabel,
|
|
125
125
|
A as getOrderTaxRatePercentage,
|
|
126
|
-
|
|
126
|
+
Br as getOrders,
|
|
127
127
|
o as getPaymentConfigStatus,
|
|
128
128
|
a as getPaymentCredentialsView,
|
|
129
129
|
Qe as getPaymentProvider,
|
|
130
|
-
|
|
130
|
+
kr as getPaymentSettings,
|
|
131
131
|
Ke as getProduct,
|
|
132
132
|
Ve as getProductBySlug,
|
|
133
133
|
yr as getProductCategories,
|
|
134
134
|
Sr as getProductTranslations,
|
|
135
135
|
we as getProducts,
|
|
136
136
|
Q as getQuoteLineDiscountMap,
|
|
137
|
-
|
|
137
|
+
Mr as getStoreConfigStatus,
|
|
138
138
|
m as getStripeClient,
|
|
139
139
|
f as handleStripeWebhook,
|
|
140
140
|
n as hydrateFreemiusEnvFromDb,
|
|
@@ -152,6 +152,7 @@ export {
|
|
|
152
152
|
he as normalizeSalePriceMap,
|
|
153
153
|
Xe as parseFreemiusCheckoutCredentialsMap,
|
|
154
154
|
Ne as productSchema,
|
|
155
|
+
Ar as publishProductAction,
|
|
155
156
|
$e as readFreemiusEnvValue,
|
|
156
157
|
ke as rebaseStoreCurrencyExchangeRates,
|
|
157
158
|
J as recordCouponRedemption,
|
|
@@ -165,8 +166,8 @@ export {
|
|
|
165
166
|
s as resolveStripeSecretKey,
|
|
166
167
|
u as resolveStripeWebhookSecret,
|
|
167
168
|
c as savePaymentCredentials,
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
ut as savePaymentProviderCredentials,
|
|
170
|
+
Ot as saveTaxRateAction,
|
|
170
171
|
N as serializeInvoiceSettings,
|
|
171
172
|
Te as sortCurrencies,
|
|
172
173
|
Be as syncCategoriesForTranslationGroup,
|
|
@@ -174,19 +175,19 @@ export {
|
|
|
174
175
|
ur as syncFreemiusCheckoutOrder,
|
|
175
176
|
cr as syncFreemiusOrderFromWebhookEvent,
|
|
176
177
|
rr as syncFreemiusProductsToSupabase,
|
|
177
|
-
|
|
178
|
+
Tr as syncProductCategoriesAction,
|
|
178
179
|
X as syncProductSaleCouponToFreemius,
|
|
179
180
|
tr as syncSingleFreemiusProduct,
|
|
180
181
|
Me as syncStoreCurrencyRates,
|
|
181
182
|
C as syncStripeOrderFromSession,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
Dr as updateCategoryAction,
|
|
184
|
+
ft as updateInventoryTrackingAction,
|
|
185
|
+
ct as updatePaymentSettings,
|
|
185
186
|
Ye as updateProduct,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
Er as updateProductAction,
|
|
188
|
+
xt as updateShippingRate,
|
|
189
|
+
yt as updateShippingZone,
|
|
190
|
+
Rt as updateTaxSettingsAction,
|
|
190
191
|
ue as upsertDefaultUserAddresses,
|
|
191
192
|
dr as verifyFreemiusWebhookSignature
|
|
192
193
|
};
|