feat: refactor subscription handling in registration form and header component
This commit is contained in:
parent
4aa6c8d0d4
commit
9980cb90df
@ -31,6 +31,7 @@ export const FormRegister = () => {
|
|||||||
const [disabled, setDisabled] = useState(false)
|
const [disabled, setDisabled] = useState(false)
|
||||||
const fetcher = useFetcher()
|
const fetcher = useFetcher()
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_layout')
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_layout')
|
||||||
|
const subscriptions = loaderData?.subscriptionsData
|
||||||
|
|
||||||
const formMethods = useRemixForm<TRegisterSchema>({
|
const formMethods = useRemixForm<TRegisterSchema>({
|
||||||
mode: 'onSubmit',
|
mode: 'onSubmit',
|
||||||
@ -98,7 +99,7 @@ export const FormRegister = () => {
|
|||||||
name="subscribe_plan"
|
name="subscribe_plan"
|
||||||
label="Subscription"
|
label="Subscription"
|
||||||
placeholder="Pilih Subscription"
|
placeholder="Pilih Subscription"
|
||||||
options={loaderData?.subscriptionsData}
|
options={subscriptions}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
|
|||||||
@ -3,11 +3,12 @@ import { Link, useFetcher, useRouteLoaderData } from 'react-router'
|
|||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
import { APP } from '~/configs/meta'
|
import { APP } from '~/configs/meta'
|
||||||
import { useNewsContext } from '~/contexts/news'
|
import { useNewsContext } from '~/contexts/news'
|
||||||
import type { loader } from '~/routes/_layout'
|
import { loader } from '~/routes/_layout'
|
||||||
|
|
||||||
export const HeaderTop = () => {
|
export const HeaderTop = () => {
|
||||||
const { setIsLoginOpen } = useNewsContext()
|
const { setIsLoginOpen } = useNewsContext()
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_layout')
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_layout')
|
||||||
|
const userToken = loaderData?.userToken
|
||||||
const fetcher = useFetcher()
|
const fetcher = useFetcher()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -29,7 +30,7 @@ export const HeaderTop = () => {
|
|||||||
<Button className="h-8 w-auto rounded-none px-3 text-xs sm:h-[50px] sm:w-[150px] sm:text-lg">
|
<Button className="h-8 w-auto rounded-none px-3 text-xs sm:h-[50px] sm:w-[150px] sm:text-lg">
|
||||||
About Us
|
About Us
|
||||||
</Button>
|
</Button>
|
||||||
{loaderData?.userToken ? (
|
{userToken ? (
|
||||||
<fetcher.Form
|
<fetcher.Form
|
||||||
method="POST"
|
method="POST"
|
||||||
action="/actions/logout"
|
action="/actions/logout"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user