feat(backoffice): add Toast

This commit is contained in:
Hafid Nur
2025-04-05 08:40:19 +07:00
parent 07f1fb0208
commit 5bdf8f5a4d
5 changed files with 36 additions and 17 deletions
@@ -4,6 +4,7 @@ import {
gachaRollItemSchema,
TGachaRollItem
} from '@imphnen-frontend-service/service';
import { toast } from 'sonner';
export const useItem = (
nextStep: () => void,
@@ -29,12 +30,23 @@ export const useItem = (
export const useConfirmItem = (
onClose: () => void,
resetStep: () => void,
actionFunction?: () => void,
actionFunction?: () => Promise<boolean>,
messages?: {
success?: string;
error?: string;
}
) => {
const onConfirm = () => {
actionFunction?.();
onClose();
resetStep();
const onConfirm = async () => {
try {
// const result = await actionFunction?.();
// result ? toast.success(messages?.success) : toast.error(messages?.error);
toast.success(messages?.success);
onClose();
resetStep();
} catch (error) {
console.log(error);
toast.error(messages?.error);
}
};
const onCancel = () => {