π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
feat(billing): open main's Billing History from the header and paywall icon
Gilad Resisibe0c0ae57cb9
diff --git a/apps/frontend/src/components/billing/billing.history.component.tsx b/apps/frontend/src/components/billing/billing.history.component.tsxindex 7dbb8c4d7..8eba295dc 100644--- a/apps/frontend/src/components/billing/billing.history.component.tsx+++ b/apps/frontend/src/components/billing/billing.history.component.tsx@@ -77,7 +77,7 @@ const ActionLink: FC<{</a>);-export const BillingHistory: FC = () => {+export const BillingHistory: FC<{ modal?: boolean }> = ({ modal }) => {const t = useT();const { data, isLoading, error } = useInvoices();const [search, setSearch] = useState('');@@ -187,15 +187,29 @@ export const BillingHistory: FC = () => {const columns ='grid grid-cols-[minmax(0,2fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_88px] gap-x-[16px] items-center px-[16px]';+ if (modal && !isLoading && !rows.length) {+ return (+ <div className="text-center py-[20px] text-textItemBlur">+ {t('billing_no_invoices', 'No invoices yet')}+ </div>+ );+ }+if (isLoading || error || !rows.length) {return null;}return (- <div className="flex flex-col gap-[20px] rounded-[12px] border border-newTableBorder bg-newBgColorInner shadow-previewShadow p-[24px] mobile:p-[16px]">+ <div+ className={clsx(+ 'flex flex-col gap-[20px]',+ !modal &&+ 'rounded-[12px] border border-newTableBorder bg-newBgColorInner shadow-previewShadow p-[24px] mobile:p-[16px]'+ )}+ ><div className="flex items-center gap-[12px] mobile:flex-col mobile:items-stretch"><div className="flex-1 text-[20px] font-[600]">- {t('billing_history', 'Billing History')}+ {!modal && t('billing_history', 'Billing History')}</div><div className="flex items-center gap-[8px] mobile:flex-wrap"><div className="relative w-[240px] mobile:w-full">diff --git a/apps/frontend/src/components/layout/invoices.component.tsx b/apps/frontend/src/components/layout/invoices.component.tsxindex 8210aaa7f..1e49571e1 100644--- a/apps/frontend/src/components/layout/invoices.component.tsx+++ b/apps/frontend/src/components/layout/invoices.component.tsx@@ -1,131 +1,27 @@'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>- );-};+import { useUser } from '@gitroom/frontend/components/layout/user.context';+import { BillingHistory } from '@gitroom/frontend/components/billing/billing.history.component';export const InvoicesComponent: FC = () => {const { billingEnabled, isGeneral } = useVariables();const { openModal } = useModals();+ const user = useUser();const t = useT();const handleClick = useCallback(() => {openModal({- title: t('invoices', 'Invoices'),- children: (close) => <InvoicesModal close={close} />,+ title: t('billing_history', 'Billing History'),+ size: '1000px',+ children: <BillingHistory modal={true} />,});}, []);- if (!billingEnabled || !isGeneral) {+ if (!billingEnabled || !isGeneral || user?.role === 'USER') {return null;}@@ -133,7 +29,7 @@ export const InvoicesComponent: FC = () => {<divclassName="hover:text-newTextColor cursor-pointer"data-tooltip-id="tooltip"- data-tooltip-content={t('invoices', 'Invoices')}+ data-tooltip-content={t('billing_history', 'Billing History')}onClick={handleClick}><svgdiff --git a/libraries/react-shared-libraries/src/translation/locales/en/translation.json b/libraries/react-shared-libraries/src/translation/locales/en/translation.jsonindex 787e9e73a..2c614da12 100644--- a/libraries/react-shared-libraries/src/translation/locales/en/translation.json+++ b/libraries/react-shared-libraries/src/translation/locales/en/translation.json@@ -605,6 +605,7 @@"billing_download_invoice": "Download invoice","billing_view_invoice": "View invoice","billing_no_matching_invoices": "No invoices match your search",+ "billing_no_invoices": "No invoices yet","select_channels": "Select Channels","start_a_new_chat": "Start a new chat","your_assistant": "Your Assistant",