@clerk/clerk-js
Version:
Clerk JS library
1 lines • 7.2 kB
JavaScript
;(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["711"],{8317:function(e,t,r){r.r(t),r.d(t,{OrganizationPaymentAttemptPage:()=>i});var a=r(79109),o=r(11576),n=r(12264);let i=()=>(0,a.tZ)(o.SubscriberTypeContext.Provider,{value:"organization",children:(0,a.tZ)(n.PaymentAttemptPage,{})})},12264:function(e,t,r){r.r(t),r.d(t,{PaymentAttemptPage:()=>S,PaymentAttemptsList:()=>d});var a=r(79109),o=r(16600),n=r(39082),i=r(55913),l=r(11576),c=r(64204),s=r(24676);let d=()=>{let{data:e,isLoading:t,count:r}=(0,l.usePaymentAttempts)(),n=(0,l.useSubscriberTypeLocalizationRoot)();return(0,a.tZ)(o.wQ,{page:1,onPageChange:e=>{},itemCount:r,pageCount:1,itemsPerPage:10,isLoading:t,emptyStateLocalizationKey:(0,c.localizationKeys)("".concat(n,".billingPage.paymentHistorySection.empty")),headers:[(0,c.localizationKeys)("".concat(n,".billingPage.paymentHistorySection.tableHeader__date")),(0,c.localizationKeys)("".concat(n,".billingPage.paymentHistorySection.tableHeader__amount")),(0,c.localizationKeys)("".concat(n,".billingPage.paymentHistorySection.tableHeader__status"))],rows:e.map(e=>(0,a.tZ)(p,{paymentAttempt:e},e.id))})},p=e=>{let{paymentAttempt:t}=e,{id:r,amount:l,failedAt:d,paidAt:p,updatedAt:m,status:y}=t,{navigate:u}=(0,s.useRouter)();return(0,a.BX)(o.Uk,{onClick:()=>{u("payment-attempt/".concat(r))},children:[(0,a.BX)(c.Td,{sx:{cursor:"pointer"},children:[(0,a.tZ)(c.Text,{variant:"subtitle",children:(0,n.p)(p||d||m,"long")}),(0,a.tZ)(c.Text,{colorScheme:"secondary",variant:"caption",truncate:!0,sx:e=>({marginTop:e.space.$0x5}),children:(0,i.L)(r)})]}),(0,a.tZ)(c.Td,{sx:{cursor:"pointer"},children:(0,a.BX)(c.Text,{children:[l.currencySymbol,l.amountFormatted]})}),(0,a.tZ)(c.Td,{children:(0,a.tZ)(c.Badge,{colorScheme:"paid"===y?"success":"failed"===y?"danger":"primary",sx:{textTransform:"capitalize"},children:y})})]})};r(45261),r(70957),r(24551),r(22349),r(65223);var m=r(83799),y=r(7901),u=r(9117),h=r(92654),g=r(28e3),b=r(18018),x=r(12464),B=r(96519);let S=()=>{var e,t;let{params:r,navigate:o}=(0,s.useRouter)(),l=(0,b.sC)(),{organization:d}=(0,m.o8)(),p=(0,b.xr)(),{t:x,translateError:B}=(0,c.useLocalizations)(),S=(0,m.cL)(),{data:Z,isLoading:v,error:f}=(0,y.default)(r.paymentAttemptId?{type:"payment-attempt",id:r.paymentAttemptId,orgId:"organization"===l?null==d?void 0:d.id:void 0}:null,()=>S.billing.getPaymentAttempt({id:r.paymentAttemptId,orgId:"organization"===l?null==d?void 0:d.id:void 0})),k=null==Z?void 0:Z.subscriptionItem;return v?(0,a.tZ)(c.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,a.tZ)(c.Spinner,{colorScheme:"primary",sx:{margin:"auto",display:"block"},elementDescriptor:c.descriptors.spinner})}):(0,a.BX)(a.HY,{children:[(0,a.tZ)(h.h.Root,{sx:e=>({borderBlockEndWidth:e.borderWidths.$normal,borderBlockEndStyle:e.borderStyles.$solid,borderBlockEndColor:e.colors.$borderAlpha100,marginBlockEnd:e.space.$4,paddingBlockEnd:e.space.$4}),children:(0,a.tZ)(h.h.BackLink,{onClick:()=>void o("../../",{searchParams:new URLSearchParams("tab=payments")}),children:(0,a.tZ)(h.h.Title,{localizationKey:(0,c.localizationKeys)("".concat(p,".billingPage.start.headerTitle__payments")),textVariant:"h2"})})}),Z?(0,a.BX)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptRoot,as:"article",sx:e=>({borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,borderRadius:e.radii.$lg,overflow:"clip"}),children:[(0,a.BX)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptHeader,as:"header",sx:e=>({padding:e.space.$4,background:e.colors.$neutralAlpha25,display:"flex",justifyContent:"space-between",alignItems:"flex-start"}),children:[(0,a.BX)(c.Span,{elementDescriptor:c.descriptors.paymentAttemptHeaderTitleContainer,children:[(0,a.tZ)(c.Heading,{elementDescriptor:c.descriptors.paymentAttemptHeaderTitle,textVariant:"h2",localizationKey:(0,n.p)(Z.paidAt||Z.failedAt||Z.updatedAt,"long")}),(0,a.BX)(c.Span,{sx:e=>({display:"flex",alignItems:"center",gap:e.space.$0x25,color:e.colors.$colorMutedForeground}),children:[(0,a.tZ)(A,{copyLabel:"Copy payment attempt ID",text:Z.id}),(0,a.tZ)(c.Text,{colorScheme:"secondary",variant:"subtitle",children:(0,i.L)(Z.id)})]})]}),(0,a.tZ)(c.Badge,{elementDescriptor:c.descriptors.paymentAttemptHeaderBadge,colorScheme:"paid"===Z.status?"success":"failed"===Z.status?"danger":"primary",sx:{textTransform:"capitalize"},children:Z.status})]}),(0,a.tZ)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptBody,sx:e=>({padding:e.space.$4}),children:k&&(0,a.BX)(g.a.Root,{children:[(0,a.BX)(g.a.Group,{children:[(0,a.tZ)(g.a.Title,{title:k.plan.name}),(0,a.tZ)(g.a.Description,{prefix:"annual"===k.planPeriod?"x12":void 0,text:"".concat(k.plan.currencySymbol).concat("month"===k.planPeriod?k.plan.amountFormatted:k.plan.annualMonthlyAmountFormatted)})]}),(0,a.BX)(g.a.Group,{borderTop:!0,variant:"tertiary",children:[(0,a.tZ)(g.a.Title,{title:(0,c.localizationKeys)("commerce.subtotal")}),(0,a.tZ)(g.a.Description,{text:"".concat(null==(e=k.amount)?void 0:e.currencySymbol).concat(null==(t=k.amount)?void 0:t.amountFormatted)})]}),k.credit&&k.credit.amount.amount>0&&(0,a.BX)(g.a.Group,{variant:"tertiary",children:[(0,a.tZ)(g.a.Title,{title:(0,c.localizationKeys)("commerce.credit")}),(0,a.tZ)(g.a.Description,{text:"- ".concat(k.credit.amount.currencySymbol).concat(k.credit.amount.amountFormatted)})]})]})}),(0,a.BX)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptFooter,as:"footer",sx:e=>({paddingInline:e.space.$4,paddingBlock:e.space.$3,background:e.colors.$neutralAlpha25,borderBlockStartWidth:e.borderWidths.$normal,borderBlockStartStyle:e.borderStyles.$solid,borderBlockStartColor:e.colors.$borderAlpha100,display:"flex",justifyContent:"space-between"}),children:[(0,a.tZ)(c.Text,{variant:"h3",localizationKey:(0,c.localizationKeys)("commerce.totalDue"),elementDescriptor:c.descriptors.paymentAttemptFooterLabel}),(0,a.BX)(c.Span,{elementDescriptor:c.descriptors.paymentAttemptFooterValueContainer,sx:e=>({display:"flex",alignItems:"center",gap:e.space.$2x5}),children:[(0,a.tZ)(c.Text,{variant:"caption",colorScheme:"secondary",elementDescriptor:c.descriptors.paymentAttemptFooterCurrency,sx:{textTransform:"uppercase"},children:Z.amount.currency}),(0,a.BX)(c.Text,{variant:"h3",elementDescriptor:c.descriptors.paymentAttemptFooterValue,children:[Z.amount.currencySymbol,Z.amount.amountFormatted]})]})]})]}):(0,a.tZ)(c.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,a.tZ)(u.b,{variant:"danger",colorScheme:"danger",children:f?B(f.errors[0]):x((0,c.localizationKeys)("".concat(p,".billingPage.paymentHistorySection.notFound")))})})]})};function A(e){let{text:t,copyLabel:r="Copy"}=e,{onCopy:o,hasCopied:n}=(0,x.VP)(t);return(0,a.tZ)(c.Button,{elementDescriptor:c.descriptors.paymentAttemptCopyButton,variant:"unstyled",onClick:o,sx:e=>({color:"inherit",width:e.sizes.$4,height:e.sizes.$4,padding:0,borderRadius:e.radii.$sm,"&:focus-visible":{outline:"2px solid",outlineColor:e.colors.$colorRing}}),focusRing:!1,"aria-label":n?"Copied":r,children:(0,a.tZ)(c.Icon,{size:"sm",icon:n?B.Jr:B.CK,"aria-hidden":!0})})}}}]);