Merge branch 'main' of https://github.com/plxity/documenso into fix/undo-button-in-canvas

This commit is contained in:
apoorv taneja
2024-02-02 14:49:06 +05:30
40 changed files with 283 additions and 54 deletions

View File

@ -9,6 +9,8 @@ import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-documen
import type { FindResultSet } from '../../types/find-result-set';
import { maskRecipientTokensForDocument } from '../../utils/mask-recipient-tokens-for-document';
export type PeriodSelectorValue = '' | '7d' | '14d' | '30d';
export type FindDocumentsOptions = {
userId: number;
term?: string;
@ -19,7 +21,7 @@ export type FindDocumentsOptions = {
column: keyof Omit<Document, 'document'>;
direction: 'asc' | 'desc';
};
period?: '' | '7d' | '14d' | '30d';
period?: PeriodSelectorValue;
};
export const findDocuments = async ({

View File

@ -1,14 +1,31 @@
import { DateTime } from 'luxon';
import { prisma } from '@documenso/prisma';
import type { User } from '@documenso/prisma/client';
import type { Prisma, User } from '@documenso/prisma/client';
import { SigningStatus } from '@documenso/prisma/client';
import { isExtendedDocumentStatus } from '@documenso/prisma/guards/is-extended-document-status';
import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-document-status';
import type { PeriodSelectorValue } from './find-documents';
export type GetStatsInput = {
user: User;
period?: PeriodSelectorValue;
};
export const getStats = async ({ user }: GetStatsInput) => {
export const getStats = async ({ user, period }: GetStatsInput) => {
let createdAt: Prisma.DocumentWhereInput['createdAt'];
if (period) {
const daysAgo = parseInt(period.replace(/d$/, ''), 10);
const startOfPeriod = DateTime.now().minus({ days: daysAgo }).startOf('day');
createdAt = {
gte: startOfPeriod.toJSDate(),
};
}
const [ownerCounts, notSignedCounts, hasSignedCounts] = await Promise.all([
prisma.document.groupBy({
by: ['status'],
@ -17,6 +34,7 @@ export const getStats = async ({ user }: GetStatsInput) => {
},
where: {
userId: user.id,
createdAt,
deletedAt: null,
},
}),
@ -33,6 +51,7 @@ export const getStats = async ({ user }: GetStatsInput) => {
signingStatus: SigningStatus.NOT_SIGNED,
},
},
createdAt,
deletedAt: null,
},
}),
@ -42,6 +61,7 @@ export const getStats = async ({ user }: GetStatsInput) => {
_all: true,
},
where: {
createdAt,
User: {
email: {
not: user.email,

View File

@ -1,9 +1,25 @@
import { z } from 'zod';
export const ZCurrentPasswordSchema = z
.string()
.min(6, { message: 'Must be at least 6 characters in length' })
.max(72);
export const ZPasswordSchema = z
.string()
.regex(new RegExp('.*[A-Z].*'), { message: 'One uppercase character' })
.regex(new RegExp('.*[a-z].*'), { message: 'One lowercase character' })
.regex(new RegExp('.*\\d.*'), { message: 'One number' })
.regex(new RegExp('.*[`~<>?,./!@#$%^&*()\\-_+="\'|{}\\[\\];:\\\\].*'), {
message: 'One special character is required',
})
.min(8, { message: 'Must be at least 8 characters in length' })
.max(72, { message: 'Cannot be more than 72 characters in length' });
export const ZSignUpMutationSchema = z.object({
name: z.string().min(1),
email: z.string().email(),
password: z.string().min(6),
password: ZPasswordSchema,
signature: z.string().min(1, { message: 'A signature is required.' }),
});

View File

@ -1,5 +1,7 @@
import { z } from 'zod';
import { ZCurrentPasswordSchema, ZPasswordSchema } from '../auth-router/schema';
export const ZRetrieveUserByIdQuerySchema = z.object({
id: z.number().min(1),
});
@ -10,8 +12,8 @@ export const ZUpdateProfileMutationSchema = z.object({
});
export const ZUpdatePasswordMutationSchema = z.object({
currentPassword: z.string().min(6),
password: z.string().min(6),
currentPassword: ZCurrentPasswordSchema,
password: ZPasswordSchema,
});
export const ZForgotPasswordFormSchema = z.object({
@ -19,7 +21,7 @@ export const ZForgotPasswordFormSchema = z.object({
});
export const ZResetPasswordFormSchema = z.object({
password: z.string().min(6),
password: ZPasswordSchema,
token: z.string().min(1),
});

View File

@ -1,4 +1,4 @@
import { Table } from '@tanstack/react-table';
import type { Table } from '@tanstack/react-table';
import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react';
import { match } from 'ts-pattern';