🩹 (simple-fix) fix handler error request

This commit is contained in:
2025-10-07 11:59:22 +07:00
parent 171862aa3a
commit f13f1ccaf1
5 changed files with 51 additions and 17 deletions

View File

@ -1,8 +1,27 @@
"use server";
import { apiErrorHandler } from "@/shared/lib/ky/errorHandler";
import { RegisterInputs } from "../ui/components/ProvisionInput";
import { ServerRequestCallback } from "@/shared/types/serverRequestCallback";
export const submitRegisterForm = async (data: RegisterInputs) => {
await new Promise((resolve) => setTimeout(resolve, 3000));
return data;
export const submitRegisterForm = async (
data: RegisterInputs
): Promise<ServerRequestCallback> => {
if (data.password !== data.confirmPassword)
return apiErrorHandler([], {
success: false,
status: 400,
text: { message: "Password and Confirm Password do not match" },
});
try {
await new Promise((resolve) => setTimeout(resolve, 3000));
return {
success: true,
status: 200,
text: { message: "Registration successful" },
};
} catch (error) {
return apiErrorHandler(error);
}
};