Skip to content

📨 The ultimate agentic social media scheduling tool 🤖

feat: invoice history icon in top bar, visible under the billing paywall

Gilad Resisi8613f4ffce2d
diff --git a/apps/backend/src/api/routes/billing.controller.ts b/apps/backend/src/api/routes/billing.controller.ts
index 2c206e74f..8125c1604 100644
--- a/apps/backend/src/api/routes/billing.controller.ts
+++ b/apps/backend/src/api/routes/billing.controller.ts
@@ -153,6 +153,11 @@ export class BillingController {
return this._stripeService.prorate(org.id, body);
}
+ @Get('/invoices')
+ async getInvoices(@GetOrgFromRequest() org: Organization) {
+ return this._stripeService.getCharges(org.id);
+ }
+
@Get('/charges')
async getCharges(
@GetUserFromRequest() user: User,
diff --git a/apps/frontend/src/components/billing/first.billing.component.tsx b/apps/frontend/src/components/billing/first.billing.component.tsx
index ee8d8b165..ad13ffaad 100644
--- a/apps/frontend/src/components/billing/first.billing.component.tsx
+++ b/apps/frontend/src/components/billing/first.billing.component.tsx
@@ -28,6 +28,7 @@ import { useModals } from '@gitroom/frontend/components/layout/new-modal';
import useCookie from 'react-use-cookie';
import { LogoutComponent } from '@gitroom/frontend/components/layout/logout.component';
import { DeveloperIconComponent } from '@gitroom/frontend/components/developer/developer.icon.component';
+import { InvoicesComponent } from '@gitroom/frontend/components/layout/invoices.component';
const ModeComponent = dynamic(
() => import('@gitroom/frontend/components/layout/mode.component'),
@@ -183,6 +184,7 @@ export const FirstBillingComponent = () => {
<div className="flex items-center">
<div className="flex gap-[20px] text-textItemBlur">
<OrganizationSelector />
+ <InvoicesComponent />
<div className="hover:text-newTextColor">
<ModeComponent />
</div>
diff --git a/apps/frontend/src/components/layout/invoices.component.tsx b/apps/frontend/src/components/layout/invoices.component.tsx
new file mode 100644
index 000000000..8210aaa7f
--- /dev/null
+++ b/apps/frontend/src/components/layout/invoices.component.tsx
@@ -0,0 +1,157 @@
+'use client';
+
+import { FC, useCallback } from 'react';
+import useSWR from 'swr';
+import { useFetch } from '@gitroom/helpers/utils/custom.fetch';
+import { useVariables } from '@gitroom/react/helpers/variable.context';
+import { useT } from '@gitroom/react/translation/get.transation.service.client';
+import { useModals } from '@gitroom/frontend/components/layout/new-modal';
+
+interface Charge {
+ id: string;
+ amount: number;
+ currency: string;
+ created: number;
+ status: string;
+ refunded: boolean;
+ amount_refunded: number;
+ description: string | null;
+ receipt_url: string | null;
+ invoice_pdf: string | null;
+}
+
+const useInvoices = () => {
+ const fetch = useFetch();
+ return useSWR<Charge[]>('/billing/invoices', async () => {
+ return (await fetch('/billing/invoices')).json();
+ }, {
+ revalidateOnFocus: false,
+ revalidateOnReconnect: false,
+ revalidateIfStale: false,
+ });
+};
+
+const InvoicesModal: FC<{ close: () => void }> = ({ close }) => {
+ const t = useT();
+ const { data: charges } = useInvoices();
+
+ return (
+ <div className="flex flex-col gap-[16px] min-w-[500px]">
+ <div className="max-h-[400px] overflow-y-auto">
+ {!charges?.length ? (
+ <div className="text-center py-[20px] text-newTextColor/60">
+ {t('no_charges', 'No charges found')}
+ </div>
+ ) : (
+ <table className="w-full">
+ <thead>
+ <tr className="text-left border-b border-newTableBorder">
+ <th className="p-[8px]">{t('date', 'Date')}</th>
+ <th className="p-[8px]">{t('amount', 'Amount')}</th>
+ <th className="p-[8px]">{t('status', 'Status')}</th>
+ <th className="p-[8px] w-[50px]" />
+ </tr>
+ </thead>
+ <tbody>
+ {charges.map((charge) => (
+ <tr
+ key={charge.id}
+ className="border-b border-newTableBorder hover:bg-tableBorder"
+ >
+ <td className="p-[8px]">
+ {new Date(charge.created * 1000).toLocaleDateString()}
+ </td>
+ <td className="p-[8px]">
+ ${(charge.amount / 100).toFixed(2)}{' '}
+ {charge.currency.toUpperCase()}
+ </td>
+ <td className="p-[8px]">
+ {charge.refunded ? (
+ <span className="text-red-400">
+ {t('refunded', 'Refunded')}
+ </span>
+ ) : (
+ <span className="text-green-400">
+ {t('paid', 'Paid')}
+ </span>
+ )}
+ </td>
+ <td className="p-[8px]">
+ {(charge.invoice_pdf || charge.receipt_url) && (
+ <a
+ href={charge.invoice_pdf || charge.receipt_url!}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex items-center justify-center w-[28px] h-[28px] rounded-[4px] hover:bg-tableBorder transition-colors"
+ title={charge.invoice_pdf ? t('download_invoice', 'Download Invoice') : t('view_receipt', 'View Receipt')}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ width="16"
+ height="16"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
+ <polyline points="7 10 12 15 17 10" />
+ <line x1="12" y1="15" x2="12" y2="3" />
+ </svg>
+ </a>
+ )}
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ )}
+ </div>
+ </div>
+ );
+};
+
+export const InvoicesComponent: FC = () => {
+ const { billingEnabled, isGeneral } = useVariables();
+ const { openModal } = useModals();
+ const t = useT();
+
+ const handleClick = useCallback(() => {
+ openModal({
+ title: t('invoices', 'Invoices'),
+ children: (close) => <InvoicesModal close={close} />,
+ });
+ }, []);
+
+ if (!billingEnabled || !isGeneral) {
+ return null;
+ }
+
+ return (
+ <div
+ className="hover:text-newTextColor cursor-pointer"
+ data-tooltip-id="tooltip"
+ data-tooltip-content={t('invoices', 'Invoices')}
+ onClick={handleClick}
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="22"
+ height="22"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="1.5"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
+ <polyline points="14 2 14 8 20 8" />
+ <line x1="8" y1="13" x2="16" y2="13" />
+ <line x1="8" y1="17" x2="16" y2="17" />
+ </svg>
+ </div>
+ );
+};
diff --git a/apps/frontend/src/components/new-layout/layout.component.tsx b/apps/frontend/src/components/new-layout/layout.component.tsx
index 18b7e651f..53716fbc1 100644
--- a/apps/frontend/src/components/new-layout/layout.component.tsx
+++ b/apps/frontend/src/components/new-layout/layout.component.tsx
@@ -37,6 +37,7 @@ import { LanguageComponent } from '@gitroom/frontend/components/layout/language.
import { ChromeExtensionComponent } from '@gitroom/frontend/components/layout/chrome.extension.component';
import NotificationComponent from '@gitroom/frontend/components/notifications/notification.component';
import { OrganizationSelector } from '@gitroom/frontend/components/layout/organization.selector';
+import { InvoicesComponent } from '@gitroom/frontend/components/layout/invoices.component';
import { StreakComponent } from '@gitroom/frontend/components/layout/streak.component';
import { PreConditionComponent } from '@gitroom/frontend/components/layout/pre-condition.component';
import { AttachToFeedbackIcon } from '@gitroom/frontend/components/new-layout/sentry.feedback.component';
@@ -132,6 +133,7 @@ export const LayoutComponent = ({ children }: { children: ReactNode }) => {
<StreakComponent />
<div className="w-[1px] h-[20px] bg-blockSeparator" />
<OrganizationSelector />
+ <InvoicesComponent />
<div className="hover:text-newTextColor">
<ModeComponent />
</div>
diff --git a/i18n.lock b/i18n.lock
index e0aa6b38b..bb853fe0b 100644
--- a/i18n.lock
+++ b/i18n.lock
@@ -735,3 +735,4 @@ checksums:
cancel_coupon_title: 6a02a23e494728ddb694f591be65900d
cancel_coupon_failed: 7bbb5c2646ba919b7df0879225eba918
cancel_coupon_success: ded654a3b6c5fdfe7bdd23e9b5ad711c
+ invoices: 2a9cab536b243f033848ec5dfd92b0a7
diff --git a/libraries/react-shared-libraries/src/translation/locales/ar/translation.json b/libraries/react-shared-libraries/src/translation/locales/ar/translation.json
index 7af68fa08..32ce8c711 100644
--- a/libraries/react-shared-libraries/src/translation/locales/ar/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/ar/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "نعم، إلغاء القسيمة",
"cancel_coupon_title": "إلغاء القسيمة؟",
"cancel_coupon_failed": "تعذّر إلغاء القسيمة",
- "cancel_coupon_success": "تم إلغاء القسيمة"
+ "cancel_coupon_success": "تم إلغاء القسيمة",
+ "invoices": "فواتير"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/bn/translation.json b/libraries/react-shared-libraries/src/translation/locales/bn/translation.json
index 28888f9e3..794639172 100644
--- a/libraries/react-shared-libraries/src/translation/locales/bn/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/bn/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "হ্যাঁ, কুপন বাতিল করুন",
"cancel_coupon_title": "কুপন বাতিল করবেন?",
"cancel_coupon_failed": "কুপন বাতিল করা যায়নি",
- "cancel_coupon_success": "কুপন বাতিল হয়েছে"
+ "cancel_coupon_success": "কুপন বাতিল হয়েছে",
+ "invoices": "চালানসমূহ"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/de/translation.json b/libraries/react-shared-libraries/src/translation/locales/de/translation.json
index 8f6711ff5..f0064f77e 100644
--- a/libraries/react-shared-libraries/src/translation/locales/de/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/de/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "Ja, Gutschein stornieren",
"cancel_coupon_title": "Gutschein stornieren?",
"cancel_coupon_failed": "Der Gutschein konnte nicht storniert werden",
- "cancel_coupon_success": "Gutschein storniert"
+ "cancel_coupon_success": "Gutschein storniert",
+ "invoices": "Rechnungen"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/en/translation.json b/libraries/react-shared-libraries/src/translation/locales/en/translation.json
index 6699a7f29..0c6fd77d3 100644
--- a/libraries/react-shared-libraries/src/translation/locales/en/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/en/translation.json
@@ -732,5 +732,6 @@
"yes_cancel_coupon": "Yes, cancel coupon",
"cancel_coupon_title": "Cancel Coupon?",
"cancel_coupon_failed": "Could not cancel the coupon",
- "cancel_coupon_success": "Coupon cancelled"
+ "cancel_coupon_success": "Coupon cancelled",
+ "invoices": "Invoices"
}
\ No newline at end of file
diff --git a/libraries/react-shared-libraries/src/translation/locales/es/translation.json b/libraries/react-shared-libraries/src/translation/locales/es/translation.json
index 061a03a7c..7b4b7c873 100644
--- a/libraries/react-shared-libraries/src/translation/locales/es/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/es/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "Sí, cancelar cupón",
"cancel_coupon_title": "¿Cancelar cupón?",
"cancel_coupon_failed": "No se pudo cancelar el cupón",
- "cancel_coupon_success": "Cupón cancelado"
+ "cancel_coupon_success": "Cupón cancelado",
+ "invoices": "Facturas"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/fr/translation.json b/libraries/react-shared-libraries/src/translation/locales/fr/translation.json
index cb1e046c8..5a2262e93 100644
--- a/libraries/react-shared-libraries/src/translation/locales/fr/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/fr/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "Oui, annuler le coupon",
"cancel_coupon_title": "Annuler le coupon ?",
"cancel_coupon_failed": "Impossible d'annuler le coupon",
- "cancel_coupon_success": "Coupon annulé"
+ "cancel_coupon_success": "Coupon annulé",
+ "invoices": "Factures"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/he/translation.json b/libraries/react-shared-libraries/src/translation/locales/he/translation.json
index 360c0d2a8..39309d3ef 100644
--- a/libraries/react-shared-libraries/src/translation/locales/he/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/he/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "כן, בטל קופון",
"cancel_coupon_title": "לבטל קופון?",
"cancel_coupon_failed": "לא ניתן היה לבטל את הקופון",
- "cancel_coupon_success": "הקופון בוטל"
+ "cancel_coupon_success": "הקופון בוטל",
+ "invoices": "חשבוניות"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/it/translation.json b/libraries/react-shared-libraries/src/translation/locales/it/translation.json
index 334ebf020..f41f3b8db 100644
--- a/libraries/react-shared-libraries/src/translation/locales/it/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/it/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "Sì, annulla il coupon",
"cancel_coupon_title": "Annulla coupon?",
"cancel_coupon_failed": "Impossibile annullare il coupon",
- "cancel_coupon_success": "Coupon annullato"
+ "cancel_coupon_success": "Coupon annullato",
+ "invoices": "Fatture"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/ja/translation.json b/libraries/react-shared-libraries/src/translation/locales/ja/translation.json
index 7ea293046..350a57b03 100644
--- a/libraries/react-shared-libraries/src/translation/locales/ja/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/ja/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "はい、クーポンをキャンセルします",
"cancel_coupon_title": "クーポンをキャンセルしますか?",
"cancel_coupon_failed": "クーポンをキャンセルできませんでした",
- "cancel_coupon_success": "クーポンがキャンセルされました"
+ "cancel_coupon_success": "クーポンがキャンセルされました",
+ "invoices": "請求書"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/ko/translation.json b/libraries/react-shared-libraries/src/translation/locales/ko/translation.json
index 83501c1b8..b7d8451f4 100644
--- a/libraries/react-shared-libraries/src/translation/locales/ko/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/ko/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "네, 쿠폰을 취소합니다.",
"cancel_coupon_title": "쿠폰을 취소하시겠습니까?",
"cancel_coupon_failed": "쿠폰을 취소할 수 없습니다.",
- "cancel_coupon_success": "쿠폰이 취소되었습니다."
+ "cancel_coupon_success": "쿠폰이 취소되었습니다.",
+ "invoices": "송장"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/pt/translation.json b/libraries/react-shared-libraries/src/translation/locales/pt/translation.json
index ac6ad3a7e..7a8c13c34 100644
--- a/libraries/react-shared-libraries/src/translation/locales/pt/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/pt/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "Sim, cancelar cupom",
"cancel_coupon_title": "Cancelar cupom?",
"cancel_coupon_failed": "Não foi possível cancelar o cupom",
- "cancel_coupon_success": "Cupom cancelado"
+ "cancel_coupon_success": "Cupom cancelado",
+ "invoices": "Faturas"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/ru/translation.json b/libraries/react-shared-libraries/src/translation/locales/ru/translation.json
index 076e47fc9..7da187d05 100644
--- a/libraries/react-shared-libraries/src/translation/locales/ru/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/ru/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "Да, отменить купон",
"cancel_coupon_title": "Отменить купон?",
"cancel_coupon_failed": "Не удалось отменить купон",
- "cancel_coupon_success": "Купон отменён"
+ "cancel_coupon_success": "Купон отменён",
+ "invoices": "Счета-фактуры"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/tr/translation.json b/libraries/react-shared-libraries/src/translation/locales/tr/translation.json
index 9931117cb..a08e60fbb 100644
--- a/libraries/react-shared-libraries/src/translation/locales/tr/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/tr/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "Evet, kuponu iptal et",
"cancel_coupon_title": "Kupon İptal Edilsin mi?",
"cancel_coupon_failed": "Kupon iptal edilemedi",
- "cancel_coupon_success": "Kupon iptal edildi"
+ "cancel_coupon_success": "Kupon iptal edildi",
+ "invoices": "Faturalar"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/vi/translation.json b/libraries/react-shared-libraries/src/translation/locales/vi/translation.json
index 3be38fafe..9ee26c9d1 100644
--- a/libraries/react-shared-libraries/src/translation/locales/vi/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/vi/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "Đúng, hủy mã giảm giá",
"cancel_coupon_title": "Hủy mã giảm giá?",
"cancel_coupon_failed": "Không thể hủy mã giảm giá",
- "cancel_coupon_success": "Đã hủy mã giảm giá"
+ "cancel_coupon_success": "Đã hủy mã giảm giá",
+ "invoices": "Hóa đơn"
}
diff --git a/libraries/react-shared-libraries/src/translation/locales/zh/translation.json b/libraries/react-shared-libraries/src/translation/locales/zh/translation.json
index 5fb1f954d..656287998 100644
--- a/libraries/react-shared-libraries/src/translation/locales/zh/translation.json
+++ b/libraries/react-shared-libraries/src/translation/locales/zh/translation.json
@@ -730,5 +730,6 @@
"yes_cancel_coupon": "是的,取消优惠券",
"cancel_coupon_title": "取消优惠券?",
"cancel_coupon_failed": "无法取消该优惠券",
- "cancel_coupon_success": "优惠券已取消"
+ "cancel_coupon_success": "优惠券已取消",
+ "invoices": "发票"
}