mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 00:32:43 +10:00
fix: use ts-pattern
This commit is contained in:
@ -1,41 +1,40 @@
|
|||||||
import { ArrowRight, CheckCircle2 } from 'lucide-react';
|
import { ArrowRight, CheckCircle2 } from 'lucide-react';
|
||||||
|
import { match } from 'ts-pattern';
|
||||||
|
|
||||||
import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-document-status';
|
import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-document-status';
|
||||||
|
|
||||||
export type EmptyDocumentProps = { status: ExtendedDocumentStatus };
|
export type EmptyDocumentProps = { status: ExtendedDocumentStatus };
|
||||||
|
|
||||||
export default function EmptyDocumentState({ status }: EmptyDocumentProps) {
|
export default function EmptyDocumentState({ status }: EmptyDocumentProps) {
|
||||||
let headerText = 'All done';
|
const { headerText, bodyText, extraText, showArrow } = match(status)
|
||||||
let bodyText = 'All documents signed for now.';
|
.with(ExtendedDocumentStatus.COMPLETED, () => ({
|
||||||
let extraText = '';
|
headerText: 'Nothing here',
|
||||||
let showArrow = false;
|
bodyText: 'There are no signed documents yet.',
|
||||||
|
extraText: 'Start by adding a document',
|
||||||
switch (status) {
|
showArrow: true,
|
||||||
case 'COMPLETED':
|
}))
|
||||||
headerText = 'Nothing here';
|
.with(ExtendedDocumentStatus.DRAFT, () => ({
|
||||||
bodyText = 'There are no signed documents yet.';
|
headerText: 'Nothing here',
|
||||||
extraText = 'Start by adding a document';
|
bodyText: 'There are no drafts yet.',
|
||||||
showArrow = true;
|
extraText: 'Start by adding a document',
|
||||||
break;
|
showArrow: true,
|
||||||
case 'DRAFT':
|
}))
|
||||||
headerText = 'Nothing here';
|
.with(ExtendedDocumentStatus.ALL, () => ({
|
||||||
bodyText = 'There are no drafts yet.';
|
headerText: 'Nothing here',
|
||||||
extraText = 'Start by adding a document';
|
bodyText: 'There are no documents yet.',
|
||||||
showArrow = true;
|
extraText: 'Start by adding a document',
|
||||||
break;
|
showArrow: true,
|
||||||
case 'ALL':
|
}))
|
||||||
headerText = 'Nothing here';
|
.otherwise(() => ({
|
||||||
bodyText = 'There are no documents yet.';
|
headerText: 'All done',
|
||||||
extraText = 'Start by adding a document';
|
bodyText: 'All documents signed for now.',
|
||||||
showArrow = true;
|
extraText: '',
|
||||||
break;
|
showArrow: false,
|
||||||
default:
|
}));
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="text-muted-foreground/50 flex h-96 flex-col items-center justify-center space-y-3">
|
<div className="text-muted-foreground/50 flex h-96 flex-col items-center justify-center space-y-3">
|
||||||
<CheckCircle2 className="text-muted-foreground/50 h-14 w-14" />
|
<CheckCircle2 className="text-muted-foreground/50 h-12 w-12" strokeWidth={1.5} />
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<h3 className="text-lg font-semibold">{headerText}</h3>
|
<h3 className="text-lg font-semibold">{headerText}</h3>
|
||||||
<p>{bodyText}</p>
|
<p>{bodyText}</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user