🚧 (wip) testing signup submission
This commit is contained in:
@ -4,6 +4,7 @@ import { apiErrorHandler } from "@/shared/lib/ky/errorHandler";
|
|||||||
import { RegisterInputs } from "../ui/components/ProvisionInput";
|
import { RegisterInputs } from "../ui/components/ProvisionInput";
|
||||||
import { ServerRequestCallback } from "@/shared/types/ServerRequestCallback";
|
import { ServerRequestCallback } from "@/shared/types/ServerRequestCallback";
|
||||||
import { generateRandomString } from "@/shared/helper/generateRandomString";
|
import { generateRandomString } from "@/shared/helper/generateRandomString";
|
||||||
|
import { api } from "@/shared/lib/ky/connector";
|
||||||
|
|
||||||
export const submitRegisterForm = async (
|
export const submitRegisterForm = async (
|
||||||
data: RegisterInputs
|
data: RegisterInputs
|
||||||
@ -16,8 +17,7 @@ export const submitRegisterForm = async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log({
|
const payload = {
|
||||||
...data,
|
|
||||||
username:
|
username:
|
||||||
data.fullname
|
data.fullname
|
||||||
.trim()
|
.trim()
|
||||||
@ -26,12 +26,17 @@ export const submitRegisterForm = async (
|
|||||||
.substring(0, 5) +
|
.substring(0, 5) +
|
||||||
"_" +
|
"_" +
|
||||||
generateRandomString(10),
|
generateRandomString(10),
|
||||||
});
|
name: data.fullname,
|
||||||
await new Promise((resolve) => setTimeout(resolve, 3000));
|
email: data.email,
|
||||||
|
password: data.password,
|
||||||
|
};
|
||||||
|
const callback = await api.post("users", { json: payload }).json();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
status: 200,
|
status: 200,
|
||||||
text: { message: "Registration successful" },
|
text: { message: "Registration successful" },
|
||||||
|
data: callback,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return apiErrorHandler(error);
|
return apiErrorHandler(error);
|
||||||
|
|||||||
@ -43,6 +43,7 @@ const ProvisionInput = ({ fullname }: Props) => {
|
|||||||
description: returnData.text.message,
|
description: returnData.text.message,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
console.log(returnData);
|
||||||
setSubmitStatus(false);
|
setSubmitStatus(false);
|
||||||
addToast({
|
addToast({
|
||||||
color: "success",
|
color: "success",
|
||||||
|
|||||||
Reference in New Issue
Block a user