first commit

This commit is contained in:
Nermin Karic
2026-11-22 21:49:17 +01:00
commit f5e2fcbf98
693 changed files with 82975 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
"use client"
import { useActionState } from "react"
import Input from "@modules/common/components/input"
import { LOGIN_VIEW } from "@modules/account/templates/login-template"
import ErrorMessage from "@modules/checkout/components/error-message"
import { SubmitButton } from "@modules/checkout/components/submit-button"
import LocalizedClientLink from "@modules/common/components/localized-client-link"
import { signup } from "@lib/data/customer"
type Props = {
setCurrentView: (view: LOGIN_VIEW) => void
}
const Register = ({ setCurrentView }: Props) => {
const [message, formAction] = useActionState(signup, null)
return (
<div
className="max-w-sm flex flex-col items-center"
data-testid="register-page"
>
<h1 className="text-large-semi uppercase mb-6">
Become a Medusa Store Member
</h1>
<p className="text-center text-base-regular text-ui-fg-base mb-4">
Create your Medusa Store Member profile, and get access to an enhanced
shopping experience.
</p>
{message?.state === "verification_required" && (
<div
className="w-full mb-4 text-center text-base-regular text-ui-fg-base bg-ui-bg-subtle border border-ui-border-base rounded-rounded p-4"
data-testid="register-verification-message"
>
We sent a verification link to <strong>{message.email}</strong>.
Please check your inbox to verify your email, then sign in.
</div>
)}
<form className="w-full flex flex-col" action={formAction}>
<div className="flex flex-col w-full gap-y-2">
<Input
label="First name"
name="first_name"
required
autoComplete="given-name"
data-testid="first-name-input"
/>
<Input
label="Last name"
name="last_name"
required
autoComplete="family-name"
data-testid="last-name-input"
/>
<Input
label="Email"
name="email"
required
type="email"
autoComplete="email"
data-testid="email-input"
/>
<Input
label="Phone"
name="phone"
type="tel"
autoComplete="tel"
data-testid="phone-input"
/>
<Input
label="Password"
name="password"
required
type="password"
autoComplete="new-password"
data-testid="password-input"
/>
</div>
<ErrorMessage
error={message?.state === "error" ? message.error : null}
data-testid="register-error"
/>
<span className="text-center text-ui-fg-base text-small-regular mt-6">
By creating an account, you agree to Medusa Store&apos;s{" "}
<LocalizedClientLink
href="/content/privacy-policy"
className="underline"
>
Privacy Policy
</LocalizedClientLink>{" "}
and{" "}
<LocalizedClientLink
href="/content/terms-of-use"
className="underline"
>
Terms of Use
</LocalizedClientLink>
.
</span>
<SubmitButton className="w-full mt-6" data-testid="register-button">
Join
</SubmitButton>
</form>
<span className="text-center text-ui-fg-base text-small-regular mt-6">
Already a member?{" "}
<button
onClick={() => setCurrentView(LOGIN_VIEW.SIGN_IN)}
className="underline"
>
Sign in
</button>
.
</span>
</div>
)
}
export default Register