mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
chore: implemented feedback
This commit is contained in:
@ -63,17 +63,29 @@ export const ApiTokenForm = ({ className }: ApiTokenFormProps) => {
|
|||||||
*/
|
*/
|
||||||
const onDelete = (tokenId: number) => {
|
const onDelete = (tokenId: number) => {
|
||||||
if (tokenId === newlyCreatedToken.id) {
|
if (tokenId === newlyCreatedToken.id) {
|
||||||
setShowNewToken((prev) => !prev);
|
setShowNewToken(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const copyToken = (token: string) => {
|
const copyToken = async (token: string) => {
|
||||||
void copy(token).then(() => {
|
try {
|
||||||
|
const copied = await copy(token);
|
||||||
|
|
||||||
|
if (!copied) {
|
||||||
|
throw new Error('Unable to copy the token');
|
||||||
|
}
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: 'Token copied to clipboard',
|
title: 'Token copied to clipboard',
|
||||||
description: 'The token was copied to your clipboard.',
|
description: 'The token was copied to your clipboard.',
|
||||||
});
|
});
|
||||||
});
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: 'Unable to copy token',
|
||||||
|
description: 'We were unable to copy the token to your clipboard. Please try again.',
|
||||||
|
variant: 'destructive',
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async ({ tokenName }: TCreateTokenMutationSchema) => {
|
const onSubmit = async ({ tokenName }: TCreateTokenMutationSchema) => {
|
||||||
@ -146,7 +158,7 @@ export const ApiTokenForm = ({ className }: ApiTokenFormProps) => {
|
|||||||
<p className="mb-4 text-sm">
|
<p className="mb-4 text-sm">
|
||||||
Expires:{' '}
|
Expires:{' '}
|
||||||
{token.expires
|
{token.expires
|
||||||
? DateTime.fromJSDate(token.createdAt).toLocaleString(DateTime.DATETIME_FULL)
|
? DateTime.fromJSDate(token.expires).toLocaleString(DateTime.DATETIME_FULL)
|
||||||
: 'N/A'}
|
: 'N/A'}
|
||||||
</p>
|
</p>
|
||||||
<DeleteTokenDialog
|
<DeleteTokenDialog
|
||||||
@ -169,7 +181,7 @@ export const ApiTokenForm = ({ className }: ApiTokenFormProps) => {
|
|||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
className="mt-4"
|
className="mt-4"
|
||||||
onClick={() => copyToken(newlyCreatedToken.token)}
|
onClick={() => void copyToken(newlyCreatedToken.token)}
|
||||||
>
|
>
|
||||||
Copy token
|
Copy token
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -15,13 +15,13 @@ export const checkUserFromToken = async ({ token }: { token: string }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
throw new Error('Token not found');
|
throw new Error('Invalid token');
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokenObject = user.ApiToken.find((apiToken) => apiToken.token === token);
|
const tokenObject = user.ApiToken.find((apiToken) => apiToken.token === token);
|
||||||
|
|
||||||
if (!tokenObject || new Date(tokenObject.expires) < new Date()) {
|
if (!tokenObject || new Date(tokenObject.expires) < new Date()) {
|
||||||
throw new Error('The API token has expired');
|
throw new Error('Expired token');
|
||||||
}
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
|
|||||||
@ -18,6 +18,8 @@ export const fieldRouter = router({
|
|||||||
try {
|
try {
|
||||||
const { documentId, fields } = input;
|
const { documentId, fields } = input;
|
||||||
|
|
||||||
|
console.log('fields', fields);
|
||||||
|
|
||||||
return await setFieldsForDocument({
|
return await setFieldsForDocument({
|
||||||
documentId,
|
documentId,
|
||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user