From 6b3eb5a3ca6ead2d8cef51b020e0f6bbbbfb59fe Mon Sep 17 00:00:00 2001 From: Jeroen Branje Date: Thu, 19 Dec 2024 09:49:08 +0100 Subject: [PATCH] feat: add toast on mint event and revalidate path (#403) Signed-off-by: Jeroen Branje --- apps/envited.ascs.digital/modules/AddAssets/AddAssets.tsx | 4 ++++ .../modules/AddAssets/locales/de_DE.json | 6 ++++-- .../modules/AddAssets/locales/en_GB.json | 4 +++- .../modules/UploadedAssets/UploadedAssets.actions.ts | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/envited.ascs.digital/modules/AddAssets/AddAssets.tsx b/apps/envited.ascs.digital/modules/AddAssets/AddAssets.tsx index 7f3ebbad..53cdb31e 100644 --- a/apps/envited.ascs.digital/modules/AddAssets/AddAssets.tsx +++ b/apps/envited.ascs.digital/modules/AddAssets/AddAssets.tsx @@ -6,6 +6,7 @@ import { useState } from 'react' import { Controller, SubmitHandler, useForm } from 'react-hook-form' import { useTranslation } from '../../common/i18n' +import { useNotification } from '../../common/notifications' import { allTrue } from '../../common/utils/utils' import { addAssetsForm } from './AddAssets.actions' import { addFiles, removeFile } from './AddAssets.utils' @@ -13,6 +14,7 @@ import { UploadAssetsField } from './UploadAssetsField' export const AddAssets = () => { const { t } = useTranslation('AddAssets') + const { error, success } = useNotification() const { control, @@ -46,8 +48,10 @@ export const AddAssets = () => { await addAssetsForm(formData) + success(t('[Notification] asset are uploaded')) reset() } catch (e) { + error(t('[Notification] invalid asset found')) console.log(e) } } diff --git a/apps/envited.ascs.digital/modules/AddAssets/locales/de_DE.json b/apps/envited.ascs.digital/modules/AddAssets/locales/de_DE.json index e9452576..e7edee1d 100644 --- a/apps/envited.ascs.digital/modules/AddAssets/locales/de_DE.json +++ b/apps/envited.ascs.digital/modules/AddAssets/locales/de_DE.json @@ -1,7 +1,9 @@ { "[Heading] add assets": "Add assets", - "[Label] select assets": "Select assets", + "[Label] select assets": "Select and validate assets before uploading", "[Button] upload assets": "Upload assets", "[Error] invalid asset found": "Invalid asset(s) found.", - "[Success] assets are uploaded": "All assets are uploaded." + "[Success] assets are uploaded": "All assets are uploaded.", + "[Notification] assets are uploaded": "All asset(s) are uploaded.", + "[Notification] invalid asset found": "Asset(s) are not uploaded" } diff --git a/apps/envited.ascs.digital/modules/AddAssets/locales/en_GB.json b/apps/envited.ascs.digital/modules/AddAssets/locales/en_GB.json index 5987cf17..e7edee1d 100644 --- a/apps/envited.ascs.digital/modules/AddAssets/locales/en_GB.json +++ b/apps/envited.ascs.digital/modules/AddAssets/locales/en_GB.json @@ -3,5 +3,7 @@ "[Label] select assets": "Select and validate assets before uploading", "[Button] upload assets": "Upload assets", "[Error] invalid asset found": "Invalid asset(s) found.", - "[Success] assets are uploaded": "All assets are uploaded." + "[Success] assets are uploaded": "All assets are uploaded.", + "[Notification] assets are uploaded": "All asset(s) are uploaded.", + "[Notification] invalid asset found": "Asset(s) are not uploaded" } diff --git a/apps/envited.ascs.digital/modules/UploadedAssets/UploadedAssets.actions.ts b/apps/envited.ascs.digital/modules/UploadedAssets/UploadedAssets.actions.ts index 53766e27..b07411ff 100644 --- a/apps/envited.ascs.digital/modules/UploadedAssets/UploadedAssets.actions.ts +++ b/apps/envited.ascs.digital/modules/UploadedAssets/UploadedAssets.actions.ts @@ -1,5 +1,7 @@ 'use server' +import { revalidatePath } from 'next/cache' + import { log } from '../../common/logger' import { getMintParams, updateAssetStatus, uploadTokenMetadata } from '../../common/serverActions' import { AssetStatus } from '../../common/types' @@ -28,6 +30,7 @@ export async function getAssetMintParams(id: string) { export async function updateStatus(assetId: string, hash: string) { try { await updateAssetStatus({ id: assetId, hash, status: AssetStatus.minted }) + revalidatePath('/add-assets') } catch (e) { log.error(e) throw internalServerErrorError()