-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: added downloadable invoice button #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -297,15 +297,16 @@ const Billing: React.FC = () => { | |
| <th className="pb-3 font-medium">Date</th> | ||
| <th className="pb-3 font-medium">Amount</th> | ||
| <th className="pb-3 font-medium">Status</th> | ||
| <th className="pb-3 font-medium text-right">Invoice</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody className="divide-y divide-neutral-800"> | ||
| {billingHistory.map(payment => ( | ||
| <tr key={payment.id} className="text-sm"> | ||
| <td className="py-4 text-white"> | ||
| <td className="py-4 font-medium text-white"> | ||
| {new Date(payment.date).toLocaleDateString()} | ||
| </td> | ||
| <td className="py-4 text-white"> | ||
| <td className="py-4"> | ||
| {(payment.amount / 100).toLocaleString( | ||
| 'en-US', | ||
| { | ||
|
|
@@ -327,6 +328,22 @@ const Billing: React.FC = () => { | |
| payment.status.slice(1)} | ||
| </span> | ||
| </td> | ||
| <td className="py-4 text-right"> | ||
| {payment.invoiceUrl ? ( | ||
| <a | ||
| href={payment.invoiceUrl} | ||
| target="_blank" | ||
|
Comment on lines
+332
to
+335
|
||
| rel="noopener noreferrer" | ||
| className="text-primary-400 hover:text-primary-300 transition-colors inline-flex items-center gap-1 text-sm" | ||
| > | ||
| Download | ||
| </a> | ||
| ) : ( | ||
| <span className="text-neutral-600 cursor-not-allowed inline-flex items-center gap-1 text-sm" title="Invoice not available"> | ||
| Unavailable | ||
|
Comment on lines
+342
to
+343
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI is currently blocked by formatting issues. Pipeline already reports Prettier failure; please run Prettier on this file before merge (the JSX wrapping around these changed lines is a likely contributor). Also applies to: 379-380 🤖 Prompt for AI Agents |
||
| </span> | ||
| )} | ||
|
Comment on lines
+332
to
+345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate On Line 334, 🔒 Suggested fix+ const getSafeInvoiceUrl = (rawUrl?: string) => {
+ if (!rawUrl) return null;
+ try {
+ const parsed = new URL(rawUrl);
+ return parsed.protocol === 'https:' ? parsed.toString() : null;
+ } catch {
+ return null;
+ }
+ };
...
- {payment.invoiceUrl ? (
+ {getSafeInvoiceUrl(payment.invoiceUrl) ? (
<a
- href={payment.invoiceUrl}
+ href={getSafeInvoiceUrl(payment.invoiceUrl)!}
target="_blank"
rel="noopener noreferrer"
className="text-primary-400 hover:text-primary-300 transition-colors inline-flex items-center gap-1 text-sm"
>
Download
</a>
) : (🤖 Prompt for AI Agents |
||
| </td> | ||
| </tr> | ||
| ))} | ||
| </tbody> | ||
|
|
@@ -359,8 +376,8 @@ const Billing: React.FC = () => { | |
| ? 'border-white bg-neutral-800/60 ring-1 ring-white shadow-[0_0_30px_rgba(255,255,255,0.05)]' | ||
| : 'border-white/10 hover:border-white/20 hover:bg-white/5', | ||
| plan.highlight && | ||
| selectedPlan !== plan.id && | ||
| 'border-amber-500/30' | ||
| selectedPlan !== plan.id && | ||
| 'border-amber-500/30' | ||
|
Comment on lines
378
to
+380
|
||
| )} | ||
| > | ||
| {plan.highlight && ( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new
invoiceUrlfield, thebillingHistoryitems are implicitly expected to have a specific shape, but the state is typed asany[]. This makes it easy to ship runtime errors (e.g., missingcurrency,status,invoiceUrl). Define aBillingHistoryItemtype/interface (withinvoiceUrl?: string) and use it forbillingHistoryand the map callback.