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