@nextblock-cms/ecom 0.12.13 → 0.12.15

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"),_=require("react"),K=require("react-hook-form"),Q=require("./AccountNavigationMenu.cjs.js"),S=require("@nextblock-cms/ui/avatar"),Y=require("@nextblock-cms/ui/badge"),T=require("@nextblock-cms/ui/button"),o=require("@nextblock-cms/ui/card"),Z=require("@nextblock-cms/ui/checkbox"),i=require("@nextblock-cms/ui/input"),a=require("@nextblock-cms/ui/label"),x=require("@nextblock-cms/ui/select"),D=require("@nextblock-cms/ui/separator"),ee=require("../server-actions/customer-actions.cjs.js"),C=require("../customer.cjs.js"),B=require("@nextblock-cms/db"),u=require("lucide-react"),P=require("@nextblock-cms/utils"),H=require("../countries.cjs.js");function se(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 I(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:H.normalizeCountryCode(s?.country_code)||"CA"}}function G({prefix:s,title:j,register:c}){const{t:n}=P.useTranslations(),w=n("company_name")==="company_name"?"Company name":n("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:j}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("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(a.Label,{htmlFor:`${s}-company_name`,children:w}),e.jsx(i.Input,{id:`${s}-company_name`,...c(`${s}.company_name`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-recipient_name`,children:n("full_name")}),e.jsx(i.Input,{id:`${s}-recipient_name`,...c(`${s}.recipient_name`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-country_code`,children:n("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:H.countries.map(g=>e.jsx("option",{value:g.code,children:g.name},g.code))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-line1`,children:n("address_line_1")}),e.jsx(i.Input,{id:`${s}-line1`,...c(`${s}.line1`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-line2`,children:n("address_line_2")}),e.jsx(i.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(a.Label,{htmlFor:`${s}-city`,children:n("city")}),e.jsx(i.Input,{id:`${s}-city`,...c(`${s}.city`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-state`,children:n("state_province")}),e.jsx(i.Input,{id:`${s}-state`,...c(`${s}.state`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:`${s}-postal_code`,children:n("postal_zip_code")}),e.jsx(i.Input,{id:`${s}-postal_code`,...c(`${s}.postal_code`)})]})]})]})}function le({initialData:s,MediaPickerComponent:j,isAdmin:c,email:n,accountLinks:w,onAction:g,initialSuccessMessage:f}){const{t:l}=P.useTranslations(),[E,F]=_.useState(!1),[L,y]=_.useState(f?{type:"success",text:f}:null),[A,V]=_.useState(!1),[U,X]=_.useState(null),z=s?.use_billing_for_shipping??(!s?.shipping_address||C.addressesMatch(s?.billing_address,s?.shipping_address)),{register:p,handleSubmit:M,setValue:m,getValues:$,watch:v,reset:q}=K.useForm({defaultValues:{full_name:s?.full_name||"",avatar_url:s?.avatar_url||"",website:s?.website||"",github_username:s?.github_username||"",phone:s?.phone||"",role:s?.role,use_billing_for_shipping:z,billing_address:I(s?.billing_address),shipping_address:I(s?.shipping_address)}});_.useEffect(()=>{s&&q({full_name:s.full_name||"",avatar_url:s.avatar_url||"",website:s.website||"",github_username:s.github_username||"",phone:s.phone||"",role:s.role,use_billing_for_shipping:s.use_billing_for_shipping??(!s.shipping_address||C.addressesMatch(s.billing_address,s.shipping_address)),billing_address:I(s.billing_address),shipping_address:I(s.shipping_address)})},[s,q]),_.useEffect(()=>{f&&y({type:"success",text:f})},[f]),_.useEffect(()=>{const r=B.createClient();(async()=>{const{data:{user:h}}=await r.auth.getUser();if(!h)return;const t=h.identities?.find(b=>b.provider==="github");if(t){V(!0);const b=t.identity_data?.email||(h.app_metadata.provider==="github"?h.email:null);if(X(b),!$("website")){const N=t.identity_data?.custom_claims?.blog||t.identity_data?.blog||t.identity_data?.html_url;N&&m("website",N)}if(!$("avatar_url")){const N=t.identity_data?.avatar_url;N&&m("avatar_url",N)}const k=t.identity_data?.user_name||t.identity_data?.preferred_username;k&&m("github_username",k)}!$("full_name")&&h.user_metadata?.full_name&&m("full_name",h.user_metadata.full_name)})()},[$,m]);const W=async()=>{const r=B.createClient(),{error:d}=await r.auth.linkIdentity({provider:"github"});d&&(console.error("Error linking GitHub:",d),y({type:"error",text:l("github_link_failed")||"Failed to link GitHub account"}))},O=r=>{const d=se(r?.object_key??r?.file_path);d&&m("avatar_url",d)},J=async r=>{F(!0),y(null);const d=C.normalizeCustomerAddress(r.billing_address)??C.emptyCustomerAddress(),h=r.use_billing_for_shipping?d:C.normalizeCustomerAddress(r.shipping_address);try{const t={...r,billing_address:d,shipping_address:h};if(g){const b=await g(t);if(b?.error)throw new Error(b.error)}else await ee.updateProfile(t);y({type:"success",text:l("profile_updated_success")})}catch(t){if(t.message==="NEXT_REDIRECT"||t.message?.includes("NEXT_REDIRECT"))return;console.error(t),y({type:"error",text:t.message||l("profile_update_failed")})}finally{F(!1)}},R=v("use_billing_for_shipping");return e.jsxs("div",{className:"grid gap-6 md:grid-cols-12 max-w-5xl mx-auto",children:[e.jsxs(o.Card,{className:"md:col-span-4 h-fit",children:[e.jsx(o.CardHeader,{children:e.jsx(o.CardTitle,{className:"text-xl",children:l("public_profile")})}),e.jsxs(o.CardContent,{className:"flex flex-col items-center text-center space-y-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs(S.Avatar,{className:"h-32 w-32 border-4 border-muted",children:[e.jsx(S.AvatarImage,{src:v("avatar_url")||void 0,className:"object-cover"}),e.jsx(S.AvatarFallback,{className:"text-4xl bg-secondary",children:v("full_name")?.charAt(0)?.toUpperCase()||e.jsx(u.User,{className:"h-12 w-12"})})]}),j&&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(j,{triggerLabel:e.jsx(u.Upload,{className:"h-6 w-6 text-white"}),triggerVariant:"ghost",title:l("customer_profile"),onSelect:O,accept:r=>r.file_type.startsWith("image/"),hideTrigger:!1})})]}),!j&&e.jsxs("div",{className:"w-full",children:[e.jsx(a.Label,{htmlFor:"avatar_url",className:"sr-only",children:l("avatar_url")}),e.jsx(i.Input,{id:"avatar_url",...p("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:v("full_name")||l("full_name")})}),A&&e.jsxs(Y.Badge,{variant:"secondary",className:"mt-2 w-fit gap-1",children:[e.jsx(u.Github,{className:"h-3 w-3"})," ",l("github_connected")||"GitHub Connected"]})]}),w?.length?e.jsx(Q.AccountNavigationMenu,{links:w,className:"mt-2 text-left"}):null]})]}),e.jsx(o.Card,{className:"md:col-span-8",children:e.jsxs("form",{onSubmit:M(J),children:[e.jsx(o.CardHeader,{children:e.jsx(o.CardTitle,{children:l("details")})}),e.jsxs(o.CardContent,{className:"space-y-6",children:[n&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(a.Label,{htmlFor:"email",children:[l("email")||"Email"," (Read-only)"]}),e.jsx(i.Input,{id:"email",value:n,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(a.Label,{htmlFor:"full_name",className:"flex items-center gap-2",children:[e.jsx(u.User,{className:"h-4 w-4"})," ",l("full_name")]}),e.jsx(i.Input,{id:"full_name",...p("full_name")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(a.Label,{htmlFor:"phone",className:"flex items-center gap-2",children:[e.jsx(u.Phone,{className:"h-4 w-4"})," ",l("phone_number")]}),e.jsx(i.Input,{id:"phone",...p("phone")})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(a.Label,{htmlFor:"website",className:"flex items-center gap-2",children:[e.jsx(u.Globe,{className:"h-4 w-4"})," ",l("website")]}),e.jsx(i.Input,{id:"website",...p("website"),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(a.Label,{htmlFor:"github_username",className:"flex items-center gap-2",children:[e.jsx(u.Github,{className:"h-4 w-4"})," ",l("github_username")]}),A?e.jsxs("div",{className:"space-y-2",children:[e.jsx(i.Input,{id:"github_username",...p("github_username"),disabled:!0,className:"bg-muted"}),U&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(u.Mail,{className:"h-3 w-3"})," ",l("linked_to")||"Linked to"," ",U]})]}):e.jsxs(T.Button,{type:"button",variant:"outline",className:"w-full",onClick:W,children:[e.jsx(u.Github,{className:"mr-2 h-4 w-4"}),l("connect_github")]})]})]}),e.jsx(D.Separator,{className:"my-2"}),e.jsx(G,{prefix:"billing_address",title:l("billing_address"),register:p}),e.jsxs("div",{className:"flex items-center space-x-3 rounded-lg border p-4",children:[e.jsx(Z.Checkbox,{id:"use_billing_for_shipping",checked:!!R,onCheckedChange:r=>m("use_billing_for_shipping",!!r,{shouldDirty:!0})}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.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")})]})]}),!R&&e.jsx(G,{prefix:"shipping_address",title:l("shipping_address"),register:p}),L&&e.jsx("div",{className:`mt-4 rounded-xl border p-4 text-sm ${L.type==="success"?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-red-200 bg-red-50 text-red-700"}`,children:L.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(a.Label,{htmlFor:"role",children:"Role"}),e.jsxs(x.Select,{value:v("role")||"USER",onValueChange:r=>m("role",r),children:[e.jsx(x.SelectTrigger,{children:e.jsx(x.SelectValue,{placeholder:"Select role"})}),e.jsxs(x.SelectContent,{children:[e.jsx(x.SelectItem,{value:"USER",children:"User"}),e.jsx(x.SelectItem,{value:"WRITER",children:"Writer"}),e.jsx(x.SelectItem,{value:"ADMIN",children:"Admin"})]})]})]})]})]}),e.jsx(o.CardFooter,{className:"flex justify-end",children:e.jsx(T.Button,{type:"submit",disabled:E,size:"lg",children:l(E?"saving":"save_changes")})})]})})]})}exports.CustomerProfileForm=le;
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,27 +1,26 @@
1
1
  'use client';
2
- import { jsxs as l, jsx as s } from "react/jsx-runtime";
3
- import E, { useState as w } from "react";
4
- import { useForm as ee } from "react-hook-form";
5
- import { AccountNavigationMenu as se } from "./AccountNavigationMenu.es.js";
6
- import { Avatar as le, AvatarImage as re, AvatarFallback as te } from "@nextblock-cms/ui/avatar";
7
- import { Badge as ae } from "@nextblock-cms/ui/badge";
8
- import { Button as B } from "@nextblock-cms/ui/button";
9
- import { Card as G, CardHeader as j, CardTitle as P, CardContent as V, CardFooter as ie } from "@nextblock-cms/ui/card";
10
- import { Checkbox as ne } from "@nextblock-cms/ui/checkbox";
2
+ import { jsxs as s, jsx as l } from "react/jsx-runtime";
3
+ import x, { useState as S } from "react";
4
+ import { useForm as H } from "react-hook-form";
5
+ import { AccountNavigationMenu as O } from "./AccountNavigationMenu.es.js";
6
+ import { Avatar as q, AvatarImage as J, AvatarFallback as K } from "@nextblock-cms/ui/avatar";
7
+ import { Button as M } from "@nextblock-cms/ui/button";
8
+ import { Card as R, CardHeader as T, CardTitle as B, CardContent as I, CardFooter as Q } from "@nextblock-cms/ui/card";
9
+ import { Checkbox as Y } from "@nextblock-cms/ui/checkbox";
11
10
  import { Input as d } from "@nextblock-cms/ui/input";
12
- import { Label as i } from "@nextblock-cms/ui/label";
13
- import { Select as de, SelectTrigger as ce, SelectValue as oe, SelectContent as me, SelectItem as F } from "@nextblock-cms/ui/select";
14
- import { Separator as ue } from "@nextblock-cms/ui/separator";
15
- import { updateProfile as he } from "../server-actions/customer-actions.es.js";
16
- import { addressesMatch as X, normalizeCustomerAddress as z, emptyCustomerAddress as pe } from "../customer.es.js";
17
- import { createClient as H } from "@nextblock-cms/db";
18
- import { User as W, Upload as _e, Github as U, Phone as ge, Globe as fe, Mail as be } from "lucide-react";
19
- import { useTranslations as O } from "@nextblock-cms/utils";
20
- import { normalizeCountryCode as ye, countries as Ne } from "../countries.es.js";
21
- function ve(e) {
11
+ import { Label as n } from "@nextblock-cms/ui/label";
12
+ import { Select as Z, SelectTrigger as D, SelectValue as ee, SelectContent as le, SelectItem as $ } from "@nextblock-cms/ui/select";
13
+ import { Separator as se } from "@nextblock-cms/ui/separator";
14
+ import { updateProfile as re } from "../server-actions/customer-actions.es.js";
15
+ import { addressesMatch as L, normalizeCustomerAddress as k, emptyCustomerAddress as ae } from "../customer.es.js";
16
+ import { createClient as ne } from "@nextblock-cms/db";
17
+ import { User as j, Upload as ce, Phone as de, Globe as ie } from "lucide-react";
18
+ import { useTranslations as V } from "@nextblock-cms/utils";
19
+ import { normalizeCountryCode as te, countries as oe } from "../countries.es.js";
20
+ function me(e) {
22
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;
23
22
  }
24
- function $(e) {
23
+ function y(e) {
25
24
  return {
26
25
  company_name: e?.company_name || "",
27
26
  recipient_name: e?.recipient_name || "",
@@ -30,318 +29,266 @@ function $(e) {
30
29
  city: e?.city || "",
31
30
  state: e?.state || "",
32
31
  postal_code: e?.postal_code || "",
33
- country_code: ye(e?.country_code) || "CA"
32
+ country_code: te(e?.country_code) || "CA"
34
33
  };
35
34
  }
36
- function M({
35
+ function P({
37
36
  prefix: e,
38
- title: g,
39
- register: c
37
+ title: h,
38
+ register: i
40
39
  }) {
41
- const { t: n } = O(), v = n("company_name") === "company_name" ? "Company name" : n("company_name");
42
- return /* @__PURE__ */ l("div", { className: "space-y-4 rounded-xl border p-4", children: [
43
- /* @__PURE__ */ l("div", { children: [
44
- /* @__PURE__ */ s("h3", { className: "text-lg font-medium", children: g }),
45
- /* @__PURE__ */ s("p", { className: "text-sm text-muted-foreground", children: n("profile_address_defaults_help") })
40
+ const { t: c } = V(), b = c("company_name") === "company_name" ? "Company name" : c("company_name");
41
+ return /* @__PURE__ */ s("div", { className: "space-y-4 rounded-xl border p-4", children: [
42
+ /* @__PURE__ */ s("div", { children: [
43
+ /* @__PURE__ */ l("h3", { className: "text-lg font-medium", children: h }),
44
+ /* @__PURE__ */ l("p", { className: "text-sm text-muted-foreground", children: c("profile_address_defaults_help") })
46
45
  ] }),
47
- /* @__PURE__ */ l("div", { className: "grid gap-4 md:grid-cols-3", children: [
48
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
49
- /* @__PURE__ */ s(i, { htmlFor: `${e}-company_name`, children: v }),
50
- /* @__PURE__ */ s(d, { id: `${e}-company_name`, ...c(`${e}.company_name`) })
46
+ /* @__PURE__ */ s("div", { className: "grid gap-4 md:grid-cols-3", children: [
47
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
48
+ /* @__PURE__ */ l(n, { htmlFor: `${e}-company_name`, children: b }),
49
+ /* @__PURE__ */ l(d, { id: `${e}-company_name`, ...i(`${e}.company_name`) })
51
50
  ] }),
52
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
53
- /* @__PURE__ */ s(i, { htmlFor: `${e}-recipient_name`, children: n("full_name") }),
54
- /* @__PURE__ */ s(d, { id: `${e}-recipient_name`, ...c(`${e}.recipient_name`) })
51
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
52
+ /* @__PURE__ */ l(n, { htmlFor: `${e}-recipient_name`, children: c("full_name") }),
53
+ /* @__PURE__ */ l(d, { id: `${e}-recipient_name`, ...i(`${e}.recipient_name`) })
55
54
  ] }),
56
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
57
- /* @__PURE__ */ s(i, { htmlFor: `${e}-country_code`, children: n("country") }),
58
- /* @__PURE__ */ s(
55
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
56
+ /* @__PURE__ */ l(n, { htmlFor: `${e}-country_code`, children: c("country") }),
57
+ /* @__PURE__ */ l(
59
58
  "select",
60
59
  {
61
60
  id: `${e}-country_code`,
62
61
  className: "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",
63
- ...c(`${e}.country_code`),
64
- children: Ne.map((p) => /* @__PURE__ */ s("option", { value: p.code, children: p.name }, p.code))
62
+ ...i(`${e}.country_code`),
63
+ children: oe.map((o) => /* @__PURE__ */ l("option", { value: o.code, children: o.name }, o.code))
65
64
  }
66
65
  )
67
66
  ] })
68
67
  ] }),
69
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
70
- /* @__PURE__ */ s(i, { htmlFor: `${e}-line1`, children: n("address_line_1") }),
71
- /* @__PURE__ */ s(d, { id: `${e}-line1`, ...c(`${e}.line1`) })
68
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
69
+ /* @__PURE__ */ l(n, { htmlFor: `${e}-line1`, children: c("address_line_1") }),
70
+ /* @__PURE__ */ l(d, { id: `${e}-line1`, ...i(`${e}.line1`) })
72
71
  ] }),
73
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
74
- /* @__PURE__ */ s(i, { htmlFor: `${e}-line2`, children: n("address_line_2") }),
75
- /* @__PURE__ */ s(d, { id: `${e}-line2`, ...c(`${e}.line2`) })
72
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
73
+ /* @__PURE__ */ l(n, { htmlFor: `${e}-line2`, children: c("address_line_2") }),
74
+ /* @__PURE__ */ l(d, { id: `${e}-line2`, ...i(`${e}.line2`) })
76
75
  ] }),
77
- /* @__PURE__ */ l("div", { className: "grid gap-4 md:grid-cols-3", children: [
78
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
79
- /* @__PURE__ */ s(i, { htmlFor: `${e}-city`, children: n("city") }),
80
- /* @__PURE__ */ s(d, { id: `${e}-city`, ...c(`${e}.city`) })
76
+ /* @__PURE__ */ s("div", { className: "grid gap-4 md:grid-cols-3", children: [
77
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
78
+ /* @__PURE__ */ l(n, { htmlFor: `${e}-city`, children: c("city") }),
79
+ /* @__PURE__ */ l(d, { id: `${e}-city`, ...i(`${e}.city`) })
81
80
  ] }),
82
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
83
- /* @__PURE__ */ s(i, { htmlFor: `${e}-state`, children: n("state_province") }),
84
- /* @__PURE__ */ s(d, { id: `${e}-state`, ...c(`${e}.state`) })
81
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
82
+ /* @__PURE__ */ l(n, { htmlFor: `${e}-state`, children: c("state_province") }),
83
+ /* @__PURE__ */ l(d, { id: `${e}-state`, ...i(`${e}.state`) })
85
84
  ] }),
86
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
87
- /* @__PURE__ */ s(i, { htmlFor: `${e}-postal_code`, children: n("postal_zip_code") }),
88
- /* @__PURE__ */ s(d, { id: `${e}-postal_code`, ...c(`${e}.postal_code`) })
85
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
86
+ /* @__PURE__ */ l(n, { htmlFor: `${e}-postal_code`, children: c("postal_zip_code") }),
87
+ /* @__PURE__ */ l(d, { id: `${e}-postal_code`, ...i(`${e}.postal_code`) })
89
88
  ] })
90
89
  ] })
91
90
  ] });
92
91
  }
93
- function Xe({
92
+ function Se({
94
93
  initialData: e,
95
- MediaPickerComponent: g,
96
- isAdmin: c,
97
- email: n,
98
- accountLinks: v,
99
- onAction: p,
100
- initialSuccessMessage: f
94
+ MediaPickerComponent: h,
95
+ isAdmin: i,
96
+ email: c,
97
+ accountLinks: b,
98
+ onAction: o,
99
+ initialSuccessMessage: u
101
100
  }) {
102
- const { t: r } = O(), [A, S] = w(!1), [C, b] = w(
103
- f ? { type: "success", text: f } : null
104
- ), [R, q] = w(!1), [k, J] = w(null), K = e?.use_billing_for_shipping ?? (!e?.shipping_address || X(e?.billing_address, e?.shipping_address)), {
105
- register: h,
106
- handleSubmit: Q,
107
- setValue: m,
108
- getValues: x,
109
- watch: y,
110
- reset: I
111
- } = ee({
101
+ const { t: r } = V(), [w, C] = S(!1), [v, N] = S(
102
+ u ? { type: "success", text: u } : null
103
+ ), X = e?.use_billing_for_shipping ?? (!e?.shipping_address || L(e?.billing_address, e?.shipping_address)), {
104
+ register: m,
105
+ handleSubmit: z,
106
+ setValue: _,
107
+ getValues: E,
108
+ watch: g,
109
+ reset: F
110
+ } = H({
112
111
  defaultValues: {
113
112
  full_name: e?.full_name || "",
114
113
  avatar_url: e?.avatar_url || "",
115
114
  website: e?.website || "",
116
- github_username: e?.github_username || "",
117
115
  phone: e?.phone || "",
118
116
  role: e?.role,
119
- use_billing_for_shipping: K,
120
- billing_address: $(e?.billing_address),
121
- shipping_address: $(e?.shipping_address)
117
+ use_billing_for_shipping: X,
118
+ billing_address: y(e?.billing_address),
119
+ shipping_address: y(e?.shipping_address)
122
120
  }
123
121
  });
124
- E.useEffect(() => {
125
- e && I({
122
+ x.useEffect(() => {
123
+ e && F({
126
124
  full_name: e.full_name || "",
127
125
  avatar_url: e.avatar_url || "",
128
126
  website: e.website || "",
129
- github_username: e.github_username || "",
130
127
  phone: e.phone || "",
131
128
  role: e.role,
132
- use_billing_for_shipping: e.use_billing_for_shipping ?? (!e.shipping_address || X(e.billing_address, e.shipping_address)),
133
- billing_address: $(e.billing_address),
134
- shipping_address: $(e.shipping_address)
129
+ use_billing_for_shipping: e.use_billing_for_shipping ?? (!e.shipping_address || L(e.billing_address, e.shipping_address)),
130
+ billing_address: y(e.billing_address),
131
+ shipping_address: y(e.shipping_address)
135
132
  });
136
- }, [e, I]), E.useEffect(() => {
137
- f && b({ type: "success", text: f });
138
- }, [f]), E.useEffect(() => {
139
- const t = H();
133
+ }, [e, F]), x.useEffect(() => {
134
+ u && N({ type: "success", text: u });
135
+ }, [u]), x.useEffect(() => {
136
+ const a = ne();
140
137
  (async () => {
141
138
  const {
142
- data: { user: u }
143
- } = await t.auth.getUser();
144
- if (!u)
145
- return;
146
- const a = u.identities?.find((_) => _.provider === "github");
147
- if (a) {
148
- q(!0);
149
- const _ = a.identity_data?.email || (u.app_metadata.provider === "github" ? u.email : null);
150
- if (J(_), !x("website")) {
151
- const N = a.identity_data?.custom_claims?.blog || a.identity_data?.blog || a.identity_data?.html_url;
152
- N && m("website", N);
153
- }
154
- if (!x("avatar_url")) {
155
- const N = a.identity_data?.avatar_url;
156
- N && m("avatar_url", N);
157
- }
158
- const T = a.identity_data?.user_name || a.identity_data?.preferred_username;
159
- T && m("github_username", T);
160
- }
161
- !x("full_name") && u.user_metadata?.full_name && m("full_name", u.user_metadata.full_name);
139
+ data: { user: f }
140
+ } = await a.auth.getUser();
141
+ f && !E("full_name") && f.user_metadata?.full_name && _("full_name", f.user_metadata.full_name);
162
142
  })();
163
- }, [x, m]);
164
- const Y = async () => {
165
- const t = H(), { error: o } = await t.auth.linkIdentity({ provider: "github" });
166
- o && (console.error("Error linking GitHub:", o), b({
167
- type: "error",
168
- text: r("github_link_failed") || "Failed to link GitHub account"
169
- }));
170
- }, Z = (t) => {
171
- const o = ve(t?.object_key ?? t?.file_path);
172
- o && m("avatar_url", o);
173
- }, D = async (t) => {
174
- S(!0), b(null);
175
- const o = z(t.billing_address) ?? pe(), u = t.use_billing_for_shipping ? o : z(t.shipping_address);
143
+ }, [E, _]);
144
+ const W = (a) => {
145
+ const p = me(a?.object_key ?? a?.file_path);
146
+ p && _("avatar_url", p);
147
+ }, G = async (a) => {
148
+ C(!0), N(null);
149
+ const p = k(a.billing_address) ?? ae(), f = a.use_billing_for_shipping ? p : k(a.shipping_address);
176
150
  try {
177
- const a = {
178
- ...t,
179
- billing_address: o,
180
- shipping_address: u
151
+ const t = {
152
+ ...a,
153
+ billing_address: p,
154
+ shipping_address: f
181
155
  };
182
- if (p) {
183
- const _ = await p(a);
184
- if (_?.error)
185
- throw new Error(_.error);
156
+ if (o) {
157
+ const A = await o(t);
158
+ if (A?.error)
159
+ throw new Error(A.error);
186
160
  } else
187
- await he(a);
188
- b({ type: "success", text: r("profile_updated_success") });
189
- } catch (a) {
190
- if (a.message === "NEXT_REDIRECT" || a.message?.includes("NEXT_REDIRECT"))
161
+ await re(t);
162
+ N({ type: "success", text: r("profile_updated_success") });
163
+ } catch (t) {
164
+ if (t.message === "NEXT_REDIRECT" || t.message?.includes("NEXT_REDIRECT"))
191
165
  return;
192
- console.error(a), b({ type: "error", text: a.message || r("profile_update_failed") });
166
+ console.error(t), N({ type: "error", text: t.message || r("profile_update_failed") });
193
167
  } finally {
194
- S(!1);
168
+ C(!1);
195
169
  }
196
- }, L = y("use_billing_for_shipping");
197
- return /* @__PURE__ */ l("div", { className: "grid gap-6 md:grid-cols-12 max-w-5xl mx-auto", children: [
198
- /* @__PURE__ */ l(G, { className: "md:col-span-4 h-fit", children: [
199
- /* @__PURE__ */ s(j, { children: /* @__PURE__ */ s(P, { className: "text-xl", children: r("public_profile") }) }),
200
- /* @__PURE__ */ l(V, { className: "flex flex-col items-center text-center space-y-4", children: [
201
- /* @__PURE__ */ l("div", { className: "relative group", children: [
202
- /* @__PURE__ */ l(le, { className: "h-32 w-32 border-4 border-muted", children: [
203
- /* @__PURE__ */ s(re, { src: y("avatar_url") || void 0, className: "object-cover" }),
204
- /* @__PURE__ */ s(te, { className: "text-4xl bg-secondary", children: y("full_name")?.charAt(0)?.toUpperCase() || /* @__PURE__ */ s(W, { className: "h-12 w-12" }) })
170
+ }, U = g("use_billing_for_shipping");
171
+ return /* @__PURE__ */ s("div", { className: "grid gap-6 md:grid-cols-12 max-w-5xl mx-auto", children: [
172
+ /* @__PURE__ */ s(R, { className: "md:col-span-4 h-fit", children: [
173
+ /* @__PURE__ */ l(T, { children: /* @__PURE__ */ l(B, { className: "text-xl", children: r("public_profile") }) }),
174
+ /* @__PURE__ */ s(I, { className: "flex flex-col items-center text-center space-y-4", children: [
175
+ /* @__PURE__ */ s("div", { className: "relative group", children: [
176
+ /* @__PURE__ */ s(q, { className: "h-32 w-32 border-4 border-muted", children: [
177
+ /* @__PURE__ */ l(J, { src: g("avatar_url") || void 0, className: "object-cover" }),
178
+ /* @__PURE__ */ l(K, { className: "text-4xl bg-secondary", children: g("full_name")?.charAt(0)?.toUpperCase() || /* @__PURE__ */ l(j, { className: "h-12 w-12" }) })
205
179
  ] }),
206
- g && /* @__PURE__ */ s("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__ */ s(
207
- g,
180
+ 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
+ h,
208
182
  {
209
- triggerLabel: /* @__PURE__ */ s(_e, { className: "h-6 w-6 text-white" }),
183
+ triggerLabel: /* @__PURE__ */ l(ce, { className: "h-6 w-6 text-white" }),
210
184
  triggerVariant: "ghost",
211
185
  title: r("customer_profile"),
212
- onSelect: Z,
213
- accept: (t) => t.file_type.startsWith("image/"),
186
+ onSelect: W,
187
+ accept: (a) => a.file_type.startsWith("image/"),
214
188
  hideTrigger: !1
215
189
  }
216
190
  ) })
217
191
  ] }),
218
- !g && /* @__PURE__ */ l("div", { className: "w-full", children: [
219
- /* @__PURE__ */ s(i, { htmlFor: "avatar_url", className: "sr-only", children: r("avatar_url") }),
220
- /* @__PURE__ */ s(d, { id: "avatar_url", ...h("avatar_url"), placeholder: "https://...", className: "mt-2" })
192
+ !h && /* @__PURE__ */ s("div", { className: "w-full", children: [
193
+ /* @__PURE__ */ l(n, { htmlFor: "avatar_url", className: "sr-only", children: r("avatar_url") }),
194
+ /* @__PURE__ */ l(d, { id: "avatar_url", ...m("avatar_url"), placeholder: "https://...", className: "mt-2" })
221
195
  ] }),
222
- /* @__PURE__ */ l("div", { className: "w-full space-y-1 text-left mt-4", children: [
223
- /* @__PURE__ */ s("div", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wider", children: r("identity") }),
224
- /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ s("span", { className: "font-semibold text-lg", children: y("full_name") || r("full_name") }) }),
225
- R && /* @__PURE__ */ l(ae, { variant: "secondary", className: "mt-2 w-fit gap-1", children: [
226
- /* @__PURE__ */ s(U, { className: "h-3 w-3" }),
227
- " ",
228
- r("github_connected") || "GitHub Connected"
229
- ] })
196
+ /* @__PURE__ */ s("div", { className: "w-full space-y-1 text-left mt-4", children: [
197
+ /* @__PURE__ */ l("div", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wider", children: r("identity") }),
198
+ /* @__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") }) })
230
199
  ] }),
231
- v?.length ? /* @__PURE__ */ s(
232
- se,
200
+ b?.length ? /* @__PURE__ */ l(
201
+ O,
233
202
  {
234
- links: v,
203
+ links: b,
235
204
  className: "mt-2 text-left"
236
205
  }
237
206
  ) : null
238
207
  ] })
239
208
  ] }),
240
- /* @__PURE__ */ s(G, { className: "md:col-span-8", children: /* @__PURE__ */ l("form", { onSubmit: Q(D), children: [
241
- /* @__PURE__ */ s(j, { children: /* @__PURE__ */ s(P, { children: r("details") }) }),
242
- /* @__PURE__ */ l(V, { className: "space-y-6", children: [
243
- n && /* @__PURE__ */ l("div", { className: "space-y-2", children: [
244
- /* @__PURE__ */ l(i, { htmlFor: "email", children: [
209
+ /* @__PURE__ */ l(R, { className: "md:col-span-8", children: /* @__PURE__ */ s("form", { onSubmit: z(G), children: [
210
+ /* @__PURE__ */ l(T, { children: /* @__PURE__ */ l(B, { children: r("details") }) }),
211
+ /* @__PURE__ */ s(I, { className: "space-y-6", children: [
212
+ c && /* @__PURE__ */ s("div", { className: "space-y-2", children: [
213
+ /* @__PURE__ */ s(n, { htmlFor: "email", children: [
245
214
  r("email") || "Email",
246
215
  " (Read-only)"
247
216
  ] }),
248
- /* @__PURE__ */ s(d, { id: "email", value: n, readOnly: !0, disabled: !0, className: "bg-muted/50" })
217
+ /* @__PURE__ */ l(d, { id: "email", value: c, readOnly: !0, disabled: !0, className: "bg-muted/50" })
249
218
  ] }),
250
- /* @__PURE__ */ s("div", { className: "rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground", children: r("profile_basic_info_help") }),
251
- /* @__PURE__ */ l("div", { className: "grid gap-4 md:grid-cols-2", children: [
252
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
253
- /* @__PURE__ */ l(i, { htmlFor: "full_name", className: "flex items-center gap-2", children: [
254
- /* @__PURE__ */ s(W, { className: "h-4 w-4" }),
219
+ /* @__PURE__ */ l("div", { className: "rounded-xl border bg-muted/20 p-4 text-sm text-muted-foreground", children: r("profile_basic_info_help") }),
220
+ /* @__PURE__ */ s("div", { className: "grid gap-4 md:grid-cols-2", children: [
221
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
222
+ /* @__PURE__ */ s(n, { htmlFor: "full_name", className: "flex items-center gap-2", children: [
223
+ /* @__PURE__ */ l(j, { className: "h-4 w-4" }),
255
224
  " ",
256
225
  r("full_name")
257
226
  ] }),
258
- /* @__PURE__ */ s(d, { id: "full_name", ...h("full_name") })
227
+ /* @__PURE__ */ l(d, { id: "full_name", ...m("full_name") })
259
228
  ] }),
260
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
261
- /* @__PURE__ */ l(i, { htmlFor: "phone", className: "flex items-center gap-2", children: [
262
- /* @__PURE__ */ s(ge, { className: "h-4 w-4" }),
229
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
230
+ /* @__PURE__ */ s(n, { htmlFor: "phone", className: "flex items-center gap-2", children: [
231
+ /* @__PURE__ */ l(de, { className: "h-4 w-4" }),
263
232
  " ",
264
233
  r("phone_number")
265
234
  ] }),
266
- /* @__PURE__ */ s(d, { id: "phone", ...h("phone") })
235
+ /* @__PURE__ */ l(d, { id: "phone", ...m("phone") })
267
236
  ] })
268
237
  ] }),
269
- /* @__PURE__ */ l("div", { className: "grid gap-4 md:grid-cols-2", children: [
270
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
271
- /* @__PURE__ */ l(i, { htmlFor: "website", className: "flex items-center gap-2", children: [
272
- /* @__PURE__ */ s(fe, { className: "h-4 w-4" }),
273
- " ",
274
- r("website")
275
- ] }),
276
- /* @__PURE__ */ s(d, { id: "website", ...h("website"), placeholder: "https://example.com" })
238
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
239
+ /* @__PURE__ */ s(n, { htmlFor: "website", className: "flex items-center gap-2", children: [
240
+ /* @__PURE__ */ l(ie, { className: "h-4 w-4" }),
241
+ " ",
242
+ r("website")
277
243
  ] }),
278
- /* @__PURE__ */ l("div", { className: "space-y-2", children: [
279
- /* @__PURE__ */ l(i, { htmlFor: "github_username", className: "flex items-center gap-2", children: [
280
- /* @__PURE__ */ s(U, { className: "h-4 w-4" }),
281
- " ",
282
- r("github_username")
283
- ] }),
284
- R ? /* @__PURE__ */ l("div", { className: "space-y-2", children: [
285
- /* @__PURE__ */ s(d, { id: "github_username", ...h("github_username"), disabled: !0, className: "bg-muted" }),
286
- k && /* @__PURE__ */ l("p", { className: "text-xs text-muted-foreground flex items-center gap-1", children: [
287
- /* @__PURE__ */ s(be, { className: "h-3 w-3" }),
288
- " ",
289
- r("linked_to") || "Linked to",
290
- " ",
291
- k
292
- ] })
293
- ] }) : /* @__PURE__ */ l(B, { type: "button", variant: "outline", className: "w-full", onClick: Y, children: [
294
- /* @__PURE__ */ s(U, { className: "mr-2 h-4 w-4" }),
295
- r("connect_github")
296
- ] })
297
- ] })
244
+ /* @__PURE__ */ l(d, { id: "website", ...m("website"), placeholder: "https://example.com" })
298
245
  ] }),
299
- /* @__PURE__ */ s(ue, { className: "my-2" }),
300
- /* @__PURE__ */ s(M, { prefix: "billing_address", title: r("billing_address"), register: h }),
301
- /* @__PURE__ */ l("div", { className: "flex items-center space-x-3 rounded-lg border p-4", children: [
302
- /* @__PURE__ */ s(
303
- ne,
246
+ /* @__PURE__ */ l(se, { className: "my-2" }),
247
+ /* @__PURE__ */ l(P, { prefix: "billing_address", title: r("billing_address"), register: m }),
248
+ /* @__PURE__ */ s("div", { className: "flex items-center space-x-3 rounded-lg border p-4", children: [
249
+ /* @__PURE__ */ l(
250
+ Y,
304
251
  {
305
252
  id: "use_billing_for_shipping",
306
- checked: !!L,
307
- onCheckedChange: (t) => m("use_billing_for_shipping", !!t, { shouldDirty: !0 })
253
+ checked: !!U,
254
+ onCheckedChange: (a) => _("use_billing_for_shipping", !!a, { shouldDirty: !0 })
308
255
  }
309
256
  ),
310
- /* @__PURE__ */ l("div", { className: "space-y-1", children: [
311
- /* @__PURE__ */ s(i, { htmlFor: "use_billing_for_shipping", className: "cursor-pointer", children: r("use_billing_for_shipping") }),
312
- /* @__PURE__ */ s("p", { className: "text-sm text-muted-foreground", children: r("profile_use_billing_for_shipping_help") })
257
+ /* @__PURE__ */ s("div", { className: "space-y-1", children: [
258
+ /* @__PURE__ */ l(n, { htmlFor: "use_billing_for_shipping", className: "cursor-pointer", children: r("use_billing_for_shipping") }),
259
+ /* @__PURE__ */ l("p", { className: "text-sm text-muted-foreground", children: r("profile_use_billing_for_shipping_help") })
313
260
  ] })
314
261
  ] }),
315
- !L && /* @__PURE__ */ s(
316
- M,
262
+ !U && /* @__PURE__ */ l(
263
+ P,
317
264
  {
318
265
  prefix: "shipping_address",
319
266
  title: r("shipping_address"),
320
- register: h
267
+ register: m
321
268
  }
322
269
  ),
323
- C && /* @__PURE__ */ s(
270
+ v && /* @__PURE__ */ l(
324
271
  "div",
325
272
  {
326
- className: `mt-4 rounded-xl border p-4 text-sm ${C.type === "success" ? "border-emerald-200 bg-emerald-50 text-emerald-700" : "border-red-200 bg-red-50 text-red-700"}`,
327
- children: C.text
273
+ className: `mt-4 rounded-xl border p-4 text-sm ${v.type === "success" ? "border-emerald-200 bg-emerald-50 text-emerald-700" : "border-red-200 bg-red-50 text-red-700"}`,
274
+ children: v.text
328
275
  }
329
276
  ),
330
- c && /* @__PURE__ */ l("div", { className: "border-t pt-4 mt-4", children: [
331
- /* @__PURE__ */ s("h3", { className: "text-sm font-medium mb-3", children: "Admin Settings" }),
332
- /* @__PURE__ */ l("div", { className: "grid gap-2", children: [
333
- /* @__PURE__ */ s(i, { htmlFor: "role", children: "Role" }),
334
- /* @__PURE__ */ l(
335
- de,
277
+ i && /* @__PURE__ */ s("div", { className: "border-t pt-4 mt-4", children: [
278
+ /* @__PURE__ */ l("h3", { className: "text-sm font-medium mb-3", children: "Admin Settings" }),
279
+ /* @__PURE__ */ s("div", { className: "grid gap-2", children: [
280
+ /* @__PURE__ */ l(n, { htmlFor: "role", children: "Role" }),
281
+ /* @__PURE__ */ s(
282
+ Z,
336
283
  {
337
- value: y("role") || "USER",
338
- onValueChange: (t) => m("role", t),
284
+ value: g("role") || "USER",
285
+ onValueChange: (a) => _("role", a),
339
286
  children: [
340
- /* @__PURE__ */ s(ce, { children: /* @__PURE__ */ s(oe, { placeholder: "Select role" }) }),
341
- /* @__PURE__ */ l(me, { children: [
342
- /* @__PURE__ */ s(F, { value: "USER", children: "User" }),
343
- /* @__PURE__ */ s(F, { value: "WRITER", children: "Writer" }),
344
- /* @__PURE__ */ s(F, { value: "ADMIN", children: "Admin" })
287
+ /* @__PURE__ */ l(D, { children: /* @__PURE__ */ l(ee, { placeholder: "Select role" }) }),
288
+ /* @__PURE__ */ s(le, { children: [
289
+ /* @__PURE__ */ l($, { value: "USER", children: "User" }),
290
+ /* @__PURE__ */ l($, { value: "WRITER", children: "Writer" }),
291
+ /* @__PURE__ */ l($, { value: "ADMIN", children: "Admin" })
345
292
  ] })
346
293
  ]
347
294
  }
@@ -349,10 +296,10 @@ function Xe({
349
296
  ] })
350
297
  ] })
351
298
  ] }),
352
- /* @__PURE__ */ s(ie, { className: "flex justify-end", children: /* @__PURE__ */ s(B, { type: "submit", disabled: A, size: "lg", children: r(A ? "saving" : "save_changes") }) })
299
+ /* @__PURE__ */ l(Q, { className: "flex justify-end", children: /* @__PURE__ */ l(M, { type: "submit", disabled: w, size: "lg", children: r(w ? "saving" : "save_changes") }) })
353
300
  ] }) })
354
301
  ] });
355
302
  }
356
303
  export {
357
- Xe as CustomerProfileForm
304
+ Se as CustomerProfileForm
358
305
  };