import { o as __toESM } from "../_runtime.mjs"; import { h as require_react, m as require_jsx_runtime } from "../_libs/react+tanstack__react-query.mjs"; import { a as MyText, i as MyButton, o as MyTextInput } from "./src-u_N1opJl.mjs"; import { n as trpc } from "./trpc-client-CQOIB5UU.mjs"; import { l as useNavigate } from "../_libs/@tanstack/react-router+[...].mjs"; import { n as useAuth } from "./auth-context-DzjwonUC.mjs"; //#region node_modules/.nitro/vite/services/ssr/assets/register-dcmJe--5.js var import_react = /* @__PURE__ */ __toESM(require_react()); var import_jsx_runtime = require_jsx_runtime(); function RegisterPage() { const { register: authRegister } = useAuth(); const navigate = useNavigate(); const [name, setName] = (0, import_react.useState)(""); const [email, setEmail] = (0, import_react.useState)(""); const [mobile, setMobile] = (0, import_react.useState)(""); const [password, setPassword] = (0, import_react.useState)(""); const registerMutation = trpc.user.auth.register.useMutation({ onSuccess: (data) => { if (data.token && data.user) { authRegister(data.token, data.user); navigate({ to: "/home" }); } } }); const handleSubmit = (e) => { e.preventDefault(); registerMutation.mutate({ name, email, mobile, password }); }; return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex min-h-screen items-center justify-center bg-gradient-to-b from-brand-400 to-brand-700 p-4", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-full max-w-md", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MyText, { weight: "bold", className: "mb-2 text-center text-4xl text-white", children: "Create Account" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MyText, { className: "mb-8 text-center text-lg text-blue-100", children: "Join Freshyo today" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rounded-2xl bg-white p-8 shadow-xl", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { onSubmit: handleSubmit, className: "flex flex-col gap-4", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MyTextInput, { placeholder: "Full Name", value: name, onChange: (e) => setName(e.target.value), required: true }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MyTextInput, { placeholder: "Email", type: "email", value: email, onChange: (e) => setEmail(e.target.value) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MyTextInput, { placeholder: "Mobile Number", value: mobile, onChange: (e) => { const clean = e.target.value.replace(/\D/g, ""); if (clean.length <= 10) setMobile(clean); }, required: true }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MyTextInput, { placeholder: "Password", type: "password", value: password, onChange: (e) => setPassword(e.target.value), required: true }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MyButton, { type: "submit", fullWidth: true, className: "mt-2 h-12 rounded-xl bg-brand-600 text-white shadow-lg", disabled: registerMutation.isPending, textContent: registerMutation.isPending ? "Creating..." : "Register" }) ] }) }) ] }) }); } //#endregion export { RegisterPage as component };