feat: modal for update gacha roll item

- Sesuaikan modal untuk update gacha roll item
- Refactor custom hook untuk tambah dan update gacha roll item
This commit is contained in:
Hafid Nur
2025-04-05 08:02:13 +07:00
parent 3958ae1098
commit 07f1fb0208
3 changed files with 109 additions and 90 deletions
@@ -5,10 +5,14 @@ import {
TGachaRollItem
} from '@imphnen-frontend-service/service';
export const useAddItem = (nextStep: () => void) => {
export const useItem = (
nextStep: () => void,
initialValues?: TGachaRollItem
) => {
const form = useForm<TGachaRollItem>({
resolver: zodResolver(gachaRollItemSchema),
mode: 'all',
defaultValues: initialValues,
});
const onSubmit = form.handleSubmit((data) => {
@@ -22,13 +26,13 @@ export const useAddItem = (nextStep: () => void) => {
};
};
export const useConfirmAddItem = (
export const useConfirmItem = (
onClose: () => void,
resetStep: () => void,
handleAddItem?: () => void,
actionFunction?: () => void,
) => {
const onConfirm = () => {
handleAddItem?.();
actionFunction?.();
onClose();
resetStep();
};