mirror of
https://github.com/documenso/documenso.git
synced 2025-11-18 18:51:37 +10:00
## Description Refactor the current date formatting system to utilize Lingui. ## Changes Made - Remove redundant `LocaleData` component with Lingui dates ## Important notes For the internal pages for certificates, default to en-US to format any dates. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced internationalization support across various components by utilizing the `i18n` object for date formatting. - Streamlined locale management by removing cookie-based language handling and adopting a more centralized approach. - **Bug Fixes** - Improved date formatting consistency by replacing the `LocaleDate` component with direct calls to `i18n.date()` in multiple components. - **Documentation** - Updated localization strings in the `web.po` files to reflect recent changes in the source code structure. - **Chores** - Minor formatting adjustments and code organization improvements across various files to enhance readability and maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: github-actions <github-actions@documenso.com>
95 lines
3.1 KiB
TypeScript
95 lines
3.1 KiB
TypeScript
import { Trans } from '@lingui/macro';
|
|
import { DateTime } from 'luxon';
|
|
|
|
import { setupI18nSSR } from '@documenso/lib/client-only/providers/i18n.server';
|
|
import { getRequiredServerComponentSession } from '@documenso/lib/next-auth/get-server-component-session';
|
|
import { getUserTokens } from '@documenso/lib/server-only/public-api/get-all-user-tokens';
|
|
import { Button } from '@documenso/ui/primitives/button';
|
|
|
|
import DeleteTokenDialog from '~/components/(dashboard)/settings/token/delete-token-dialog';
|
|
import { ApiTokenForm } from '~/components/forms/token';
|
|
|
|
export default async function ApiTokensPage() {
|
|
const { i18n } = setupI18nSSR();
|
|
|
|
const { user } = await getRequiredServerComponentSession();
|
|
|
|
const tokens = await getUserTokens({ userId: user.id });
|
|
|
|
return (
|
|
<div>
|
|
<h3 className="text-2xl font-semibold">
|
|
<Trans>API Tokens</Trans>
|
|
</h3>
|
|
|
|
<p className="text-muted-foreground mt-2 text-sm">
|
|
<Trans>
|
|
On this page, you can create new API tokens and manage the existing ones. <br />
|
|
Also see our{' '}
|
|
<a
|
|
className="text-primary underline"
|
|
href={'https://docs.documenso.com/developers/public-api'}
|
|
target="_blank"
|
|
>
|
|
Documentation
|
|
</a>
|
|
.
|
|
</Trans>
|
|
</p>
|
|
|
|
<hr className="my-4" />
|
|
|
|
<ApiTokenForm className="max-w-xl" tokens={tokens} />
|
|
|
|
<hr className="mb-4 mt-8" />
|
|
|
|
<h4 className="text-xl font-medium">
|
|
<Trans>Your existing tokens</Trans>
|
|
</h4>
|
|
|
|
{tokens.length === 0 && (
|
|
<div className="mb-4">
|
|
<p className="text-muted-foreground mt-2 text-sm italic">
|
|
<Trans>Your tokens will be shown here once you create them.</Trans>
|
|
</p>
|
|
</div>
|
|
)}
|
|
|
|
{tokens.length > 0 && (
|
|
<div className="mt-4 flex max-w-xl flex-col gap-y-4">
|
|
{tokens.map((token) => (
|
|
<div key={token.id} className="border-border rounded-lg border p-4">
|
|
<div className="flex items-center justify-between gap-x-4">
|
|
<div>
|
|
<h5 className="text-base">{token.name}</h5>
|
|
|
|
<p className="text-muted-foreground mt-2 text-xs">
|
|
<Trans>Created on {i18n.date(token.createdAt, DateTime.DATETIME_FULL)}</Trans>
|
|
</p>
|
|
{token.expires ? (
|
|
<p className="text-muted-foreground mt-1 text-xs">
|
|
<Trans>Expires on {i18n.date(token.expires, DateTime.DATETIME_FULL)}</Trans>
|
|
</p>
|
|
) : (
|
|
<p className="text-muted-foreground mt-1 text-xs">
|
|
<Trans>Token doesn't have an expiration date</Trans>
|
|
</p>
|
|
)}
|
|
</div>
|
|
|
|
<div>
|
|
<DeleteTokenDialog token={token}>
|
|
<Button variant="destructive">
|
|
<Trans>Delete</Trans>
|
|
</Button>
|
|
</DeleteTokenDialog>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|