@nextblock-cms/ecom 0.10.2 → 0.10.4

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