Skip to content

Commit

Permalink
refactor: only show referral code if not sub
Browse files Browse the repository at this point in the history
  • Loading branch information
secondl1ght committed Aug 26, 2024
1 parent 5d528a6 commit 7330207
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
25 changes: 14 additions & 11 deletions src/components/form/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function SignUpForm() {
const [view, setView] = useState<'waitlist' | 'sign-up'>(
referralParam ? 'sign-up' : 'waitlist'
);
const [subscriber, setSubscriber] = useState(false);
const [step, setStep] = useState(0);
const [loading, setLoading] = useState(true);
const [showPassword, setShowPassword] = useState(false);
Expand Down Expand Up @@ -157,7 +158,7 @@ export function SignUpForm() {
}, [client, toast]);

return view === 'waitlist' ? (
<WaitlistForm setView={setView} />
<WaitlistForm setView={setView} setSubscriber={setSubscriber} />
) : (
<form onSubmit={onSubmit} className="relative mx-auto my-10 max-w-96 px-4">
{step > 0 ? (
Expand Down Expand Up @@ -199,18 +200,20 @@ export function SignUpForm() {
/>
</div>

<div className="space-y-2">
<Label htmlFor="referralCode">{s('referral')}</Label>
{!subscriber ? (
<div className="space-y-2">
<Label htmlFor="referralCode">{s('referral')}</Label>

<Input
id="referralCode"
value={referralCode}
onChange={e => setReferralCode(e.target.value)}
placeholder="36b8f84d"
/>
<Input
id="referralCode"
value={referralCode}
onChange={e => setReferralCode(e.target.value)}
placeholder="36b8f84d"
/>

<p className="text-sm text-neutral-400">{s('invite')}</p>
</div>
<p className="text-sm text-neutral-400">{s('invite')}</p>
</div>
) : null}

<Button
type="button"
Expand Down
8 changes: 6 additions & 2 deletions src/components/form/WaitlistForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const FormSchema = z.object({

export const WaitlistForm: FC<{
setView: Dispatch<SetStateAction<'waitlist' | 'sign-up'>>;
}> = ({ setView }) => {
setSubscriber: Dispatch<SetStateAction<boolean>>;
}> = ({ setView, setSubscriber }) => {
const w = useTranslations('Public.Waitlist');
const c = useTranslations('Common');

Expand Down Expand Up @@ -150,7 +151,10 @@ export const WaitlistForm: FC<{

<button
type="button"
onClick={() => setView('sign-up')}
onClick={() => {
setSubscriber(true);
setView('sign-up');
}}
disabled={loading}
className="w-full text-center font-medium text-primary-v2 transition-colors hover:text-primary-v2-hover"
>
Expand Down

0 comments on commit 7330207

Please sign in to comment.