@nextblock-cms/ecom 0.12.16 → 0.13.1
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.
|
@@ -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
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextblock-cms/ecom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
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.1",
|
|
14
|
+
"@nextblock-cms/ui": "^0.13.1",
|
|
15
|
+
"@nextblock-cms/utils": "^0.13.1",
|
|
16
16
|
"@freemius/checkout": "^1.4.1",
|
|
17
17
|
"@freemius/sdk": "^0.3.0",
|
|
18
18
|
"@hookform/resolvers": "^5.2.2",
|