Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add toast on mint event and revalidate path #403

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading