Skip to content

Commit 6b3eb5a

Browse files
authored
feat: add toast on mint event and revalidate path (#403)
Signed-off-by: Jeroen Branje <info@jeroenbranje.nl>
1 parent 93f7c15 commit 6b3eb5a

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

apps/envited.ascs.digital/modules/AddAssets/AddAssets.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ import { useState } from 'react'
66
import { Controller, SubmitHandler, useForm } from 'react-hook-form'
77

88
import { useTranslation } from '../../common/i18n'
9+
import { useNotification } from '../../common/notifications'
910
import { allTrue } from '../../common/utils/utils'
1011
import { addAssetsForm } from './AddAssets.actions'
1112
import { addFiles, removeFile } from './AddAssets.utils'
1213
import { UploadAssetsField } from './UploadAssetsField'
1314

1415
export const AddAssets = () => {
1516
const { t } = useTranslation('AddAssets')
17+
const { error, success } = useNotification()
1618

1719
const {
1820
control,
@@ -46,8 +48,10 @@ export const AddAssets = () => {
4648

4749
await addAssetsForm(formData)
4850

51+
success(t('[Notification] asset are uploaded'))
4952
reset()
5053
} catch (e) {
54+
error(t('[Notification] invalid asset found'))
5155
console.log(e)
5256
}
5357
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"[Heading] add assets": "Add assets",
3-
"[Label] select assets": "Select assets",
3+
"[Label] select assets": "Select and validate assets before uploading",
44
"[Button] upload assets": "Upload assets",
55
"[Error] invalid asset found": "Invalid asset(s) found.",
6-
"[Success] assets are uploaded": "All assets are uploaded."
6+
"[Success] assets are uploaded": "All assets are uploaded.",
7+
"[Notification] assets are uploaded": "All asset(s) are uploaded.",
8+
"[Notification] invalid asset found": "Asset(s) are not uploaded"
79
}

apps/envited.ascs.digital/modules/AddAssets/locales/en_GB.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
"[Label] select assets": "Select and validate assets before uploading",
44
"[Button] upload assets": "Upload assets",
55
"[Error] invalid asset found": "Invalid asset(s) found.",
6-
"[Success] assets are uploaded": "All assets are uploaded."
6+
"[Success] assets are uploaded": "All assets are uploaded.",
7+
"[Notification] assets are uploaded": "All asset(s) are uploaded.",
8+
"[Notification] invalid asset found": "Asset(s) are not uploaded"
79
}

apps/envited.ascs.digital/modules/UploadedAssets/UploadedAssets.actions.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use server'
22

3+
import { revalidatePath } from 'next/cache'
4+
35
import { log } from '../../common/logger'
46
import { getMintParams, updateAssetStatus, uploadTokenMetadata } from '../../common/serverActions'
57
import { AssetStatus } from '../../common/types'
@@ -28,6 +30,7 @@ export async function getAssetMintParams(id: string) {
2830
export async function updateStatus(assetId: string, hash: string) {
2931
try {
3032
await updateAssetStatus({ id: assetId, hash, status: AssetStatus.minted })
33+
revalidatePath('/add-assets')
3134
} catch (e) {
3235
log.error(e)
3336
throw internalServerErrorError()

0 commit comments

Comments
 (0)