Skip to content

Commit

Permalink
feat: add toast on mint event and revalidate path (#403)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeroen Branje <[email protected]>
  • Loading branch information
jeroenbranje authored Dec 19, 2024
1 parent 93f7c15 commit 6b3eb5a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions apps/envited.ascs.digital/modules/AddAssets/AddAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ 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'
import { UploadAssetsField } from './UploadAssetsField'

export const AddAssets = () => {
const { t } = useTranslation('AddAssets')
const { error, success } = useNotification()

const {
control,
Expand Down Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 6b3eb5a

Please sign in to comment.