feat: create AuthLayout component and refactor modal usage in forms
This commit is contained in:
parent
0d6f2e300f
commit
d9c36c5ff0
@ -1,44 +0,0 @@
|
|||||||
import type { ReactNode } from 'react'
|
|
||||||
import { Link } from 'react-router'
|
|
||||||
|
|
||||||
import { LeftArrow } from '~/components/icons/left-arrow'
|
|
||||||
import { APP } from '~/data/meta'
|
|
||||||
|
|
||||||
type THeaderModal = {
|
|
||||||
typeForm?: string
|
|
||||||
titleForm?: string
|
|
||||||
children: ReactNode
|
|
||||||
}
|
|
||||||
export default function HeaderModal({ typeForm, children }: THeaderModal) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div className="absolute top-0 left-0 lg:hidden">
|
|
||||||
<Link
|
|
||||||
to="/#"
|
|
||||||
className="mt-2 h-full py-2"
|
|
||||||
>
|
|
||||||
<LeftArrow
|
|
||||||
width={'50px'}
|
|
||||||
height={'50px'}
|
|
||||||
/>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
<div className="w-full max-w-md">
|
|
||||||
<div className="mb-6 flex justify-center">
|
|
||||||
<Link to="/news">
|
|
||||||
<img
|
|
||||||
src={APP.logo}
|
|
||||||
alt={APP.title}
|
|
||||||
className="h-[80px]"
|
|
||||||
/>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4 p-4 text-center text-[#565658]">
|
|
||||||
{children}
|
|
||||||
<p>{typeForm}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@ -1,17 +1,27 @@
|
|||||||
import { Dialog, DialogBackdrop, DialogPanel } from '@headlessui/react'
|
import {
|
||||||
|
Description,
|
||||||
|
Dialog,
|
||||||
|
DialogBackdrop,
|
||||||
|
DialogPanel,
|
||||||
|
DialogTitle,
|
||||||
|
} from '@headlessui/react'
|
||||||
import type { ReactNode } from 'react'
|
import type { ReactNode } from 'react'
|
||||||
|
|
||||||
|
import { APP } from '~/data/meta'
|
||||||
|
|
||||||
type ModalProperties = {
|
type ModalProperties = {
|
||||||
isOpen: boolean
|
isOpen: boolean
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
|
description?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PopupModal({
|
export const PopupModal = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
onClose,
|
onClose,
|
||||||
children,
|
children,
|
||||||
}: ModalProperties) {
|
description,
|
||||||
|
}: ModalProperties) => {
|
||||||
if (!isOpen) return
|
if (!isOpen) return
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
@ -25,7 +35,19 @@ export default function PopupModal({
|
|||||||
transition
|
transition
|
||||||
/>
|
/>
|
||||||
<div className="fixed inset-0 flex w-screen items-center justify-center p-4">
|
<div className="fixed inset-0 flex w-screen items-center justify-center p-4">
|
||||||
<DialogPanel className="max-w-lg space-y-4 rounded-lg bg-white p-8 shadow-lg duration-300 ease-out data-[closed]:scale-95 data-[closed]:opacity-0">
|
<DialogPanel className="max-w-lg space-y-6 rounded-lg bg-white p-8 shadow-lg duration-300 ease-out data-[closed]:scale-95 data-[closed]:opacity-0">
|
||||||
|
<DialogTitle className="flex justify-center">
|
||||||
|
<img
|
||||||
|
src={APP.logo}
|
||||||
|
alt={APP.title}
|
||||||
|
className="h-[80px]"
|
||||||
|
/>
|
||||||
|
</DialogTitle>
|
||||||
|
{description && (
|
||||||
|
<Description className="text-center text-[#565658]">
|
||||||
|
{description}
|
||||||
|
</Description>
|
||||||
|
)}
|
||||||
<div className="relative">{children}</div>
|
<div className="relative">{children}</div>
|
||||||
</DialogPanel>
|
</DialogPanel>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,16 +1,11 @@
|
|||||||
import { Button } from '@headlessui/react'
|
import { Button } from '@headlessui/react'
|
||||||
|
|
||||||
import HeaderModal from '~/components/popup/header-modal'
|
|
||||||
import { APP } from '~/data/meta'
|
import { APP } from '~/data/meta'
|
||||||
|
|
||||||
export default function PopupSuccessPayment() {
|
export default function PopupSuccessPayment() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="relative flex flex-col items-center justify-center">
|
<div className="relative flex flex-col items-center justify-center">
|
||||||
<HeaderModal>
|
|
||||||
<p>Selamat! Pembayaran anda berhasil!</p>
|
|
||||||
</HeaderModal>
|
|
||||||
|
|
||||||
<div className="mb-4 p-4 text-center">
|
<div className="mb-4 p-4 text-center">
|
||||||
<div className="flex justify-center">
|
<div className="flex justify-center">
|
||||||
<img
|
<img
|
||||||
|
|||||||
@ -11,6 +11,7 @@ const buttonVariants = cva(
|
|||||||
newsPrimaryOutline: 'border-[3px] border-white text-white text-lg',
|
newsPrimaryOutline: 'border-[3px] border-white text-white text-lg',
|
||||||
newsSecondary: 'border-[3px] border-[#2E2F7C] text-[#2E2F7C] text-lg',
|
newsSecondary: 'border-[3px] border-[#2E2F7C] text-[#2E2F7C] text-lg',
|
||||||
icon: '',
|
icon: '',
|
||||||
|
link: '',
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
default: 'h-[50px] w-[150px]',
|
default: 'h-[50px] w-[150px]',
|
||||||
@ -18,6 +19,7 @@ const buttonVariants = cva(
|
|||||||
icon: 'h-9 w-9',
|
icon: 'h-9 w-9',
|
||||||
sm: 'h-8 rounded-md px-3 text-xs',
|
sm: 'h-8 rounded-md px-3 text-xs',
|
||||||
lg: 'h-10 rounded-md px-8',
|
lg: 'h-10 rounded-md px-8',
|
||||||
|
fit: 'w-fit',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
defaultVariants: {
|
defaultVariants: {
|
||||||
|
|||||||
@ -1,13 +1,8 @@
|
|||||||
import HeaderModal from '~/components/popup/header-modal'
|
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
|
|
||||||
export default function FormForgotPassword() {
|
export default function FormForgotPassword() {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center">
|
<div className="flex flex-col items-center justify-center">
|
||||||
<HeaderModal>
|
|
||||||
<p>Selamat Datang, silakan masukkan akun Anda untuk melanjutkan!</p>
|
|
||||||
</HeaderModal>
|
|
||||||
|
|
||||||
<div className="w-full max-w-md">
|
<div className="w-full max-w-md">
|
||||||
<form>
|
<form>
|
||||||
{/* Input Email / No Telepon */}
|
{/* Input Email / No Telepon */}
|
||||||
|
|||||||
@ -1,33 +1,23 @@
|
|||||||
// import { EyeIcon, EyeOffIcon } from 'lucide-react'
|
// import { EyeIcon, EyeOffIcon } from 'lucide-react'
|
||||||
import { Button } from '@headlessui/react'
|
import { useState, type Dispatch, type SetStateAction } from 'react'
|
||||||
import { useState } from 'react'
|
|
||||||
import { Link } from 'react-router'
|
import { Link } from 'react-router'
|
||||||
|
|
||||||
import { EyeIcon } from '~/components/icons/eye'
|
import { EyeIcon } from '~/components/icons/eye'
|
||||||
import { APP } from '~/data/meta'
|
|
||||||
|
|
||||||
const FormLogin = () => {
|
import { Button } from './button'
|
||||||
|
|
||||||
|
type TProperties = {
|
||||||
|
setIsRegisterOpen: Dispatch<SetStateAction<boolean>>
|
||||||
|
setIsLoginOpen: Dispatch<SetStateAction<boolean>>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FormLogin = (properties: TProperties) => {
|
||||||
|
const { setIsRegisterOpen, setIsLoginOpen } = properties
|
||||||
const [showPassword, setShowPassword] = useState(false)
|
const [showPassword, setShowPassword] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center">
|
<div className="flex items-center justify-center">
|
||||||
<div className="w-full max-w-md">
|
<div className="w-full max-w-md">
|
||||||
<div className="mb-6 flex justify-center">
|
|
||||||
<Link to="/news">
|
|
||||||
<img
|
|
||||||
src={APP.logo}
|
|
||||||
alt={APP.title}
|
|
||||||
className="h-[80px]"
|
|
||||||
/>
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-4 p-4 text-center">
|
|
||||||
<p className="text-[#565658]">
|
|
||||||
Selamat Datang, silakan daftarkan akun Anda untuk melanjutkan!
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form>
|
<form>
|
||||||
{/* Input Email / No Telepon */}
|
{/* Input Email / No Telepon */}
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
@ -96,16 +86,19 @@ const FormLogin = () => {
|
|||||||
{/* Link Daftar */}
|
{/* Link Daftar */}
|
||||||
<div className="mt-4 text-center text-sm">
|
<div className="mt-4 text-center text-sm">
|
||||||
Belum punya akun?{' '}
|
Belum punya akun?{' '}
|
||||||
<Link
|
<Button
|
||||||
to="/register"
|
onClick={() => {
|
||||||
|
setIsLoginOpen(false)
|
||||||
|
setIsRegisterOpen(true)
|
||||||
|
}}
|
||||||
className="font-semibold text-[#2E2F7C]"
|
className="font-semibold text-[#2E2F7C]"
|
||||||
|
variant="link"
|
||||||
|
size="fit"
|
||||||
>
|
>
|
||||||
Daftar Disini
|
Daftar Disini
|
||||||
</Link>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FormLogin
|
|
||||||
|
|||||||
@ -1,16 +1,11 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
|
||||||
import HeaderModal from '~/components/popup/header-modal'
|
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
|
|
||||||
export default function FormRegister() {
|
export const FormRegister = () => {
|
||||||
const [showPassword, setShowPassword] = useState(false)
|
const [showPassword, setShowPassword] = useState(false)
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center">
|
<div className="flex flex-col items-center justify-center">
|
||||||
<HeaderModal>
|
|
||||||
<p>Selamat Datang, silakan masukkan data Anda untuk melanjutkan!</p>
|
|
||||||
</HeaderModal>
|
|
||||||
|
|
||||||
<div className="w-full max-w-md">
|
<div className="w-full max-w-md">
|
||||||
<form>
|
<form>
|
||||||
{/* Input Email / No Telepon */}
|
{/* Input Email / No Telepon */}
|
||||||
@ -1,16 +1,8 @@
|
|||||||
import { Button } from '@headlessui/react'
|
import { Button } from '@headlessui/react'
|
||||||
|
|
||||||
import HeaderModal from '~/components/popup/header-modal'
|
|
||||||
|
|
||||||
export default function FormSubscription() {
|
export default function FormSubscription() {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center justify-center">
|
<div className="flex flex-col items-center justify-center">
|
||||||
<HeaderModal>
|
|
||||||
<p>
|
|
||||||
Selamat Datang, silakan Pilih Subscription Anda untuk melanjutkan!
|
|
||||||
</p>
|
|
||||||
</HeaderModal>
|
|
||||||
|
|
||||||
<div className="w-full max-w-md">
|
<div className="w-full max-w-md">
|
||||||
<form>
|
<form>
|
||||||
{/* Subscribe*/}
|
{/* Subscribe*/}
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Link } from 'react-router'
|
import { Link } from 'react-router'
|
||||||
|
|
||||||
import PopupModal from '~/components/popup/modal'
|
import { PopupModal } from '~/components/popup/modal'
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
import FormLogin from '~/components/ui/form-login'
|
import { FormLogin } from '~/components/ui/form-login'
|
||||||
|
import { FormRegister } from '~/components/ui/form-register'
|
||||||
import { APP } from '~/data/meta'
|
import { APP } from '~/data/meta'
|
||||||
|
|
||||||
export const HeaderTop = () => {
|
export const HeaderTop = () => {
|
||||||
const [isModalOpen, setModalOpen] = useState(false)
|
const [isLoginOpen, setIsLoginOpen] = useState(false)
|
||||||
|
const [isRegisterOpen, setIsRegisterOpen] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex h-[60px] items-center justify-between bg-white px-5 align-middle sm:h-[100px] sm:gap-[15px] sm:px-[50px] sm:py-[20px]">
|
<div className="flex h-[60px] items-center justify-between bg-white px-5 align-middle sm:h-[100px] sm:gap-[15px] sm:px-[50px] sm:py-[20px]">
|
||||||
@ -31,14 +34,11 @@ export const HeaderTop = () => {
|
|||||||
<Button
|
<Button
|
||||||
variant="newsSecondary"
|
variant="newsSecondary"
|
||||||
className="hidden sm:block"
|
className="hidden sm:block"
|
||||||
onClick={() => setModalOpen(true)}
|
onClick={() => setIsLoginOpen(true)}
|
||||||
>
|
>
|
||||||
Akun
|
Akun
|
||||||
</Button>
|
</Button>
|
||||||
<div
|
<div className="w-[50px] sm:w-[60px]">
|
||||||
className="w-[50px] sm:w-[60px]"
|
|
||||||
onClick={() => setModalOpen(true)}
|
|
||||||
>
|
|
||||||
<img
|
<img
|
||||||
alt="language"
|
alt="language"
|
||||||
src="/flags/id.svg"
|
src="/flags/id.svg"
|
||||||
@ -49,10 +49,22 @@ export const HeaderTop = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PopupModal
|
<PopupModal
|
||||||
isOpen={isModalOpen}
|
isOpen={isLoginOpen}
|
||||||
onClose={() => setModalOpen(false)}
|
onClose={() => setIsLoginOpen(false)}
|
||||||
|
description="Selamat Datang, silakan daftarkan akun Anda untuk melanjutkan!"
|
||||||
>
|
>
|
||||||
<FormLogin />
|
<FormLogin
|
||||||
|
setIsRegisterOpen={setIsRegisterOpen}
|
||||||
|
setIsLoginOpen={setIsLoginOpen}
|
||||||
|
/>
|
||||||
|
</PopupModal>
|
||||||
|
|
||||||
|
<PopupModal
|
||||||
|
isOpen={isRegisterOpen}
|
||||||
|
onClose={() => setIsRegisterOpen(false)}
|
||||||
|
description="Selamat Datang, silakan daftarkan akun Anda untuk melanjutkan!"
|
||||||
|
>
|
||||||
|
<FormRegister />
|
||||||
</PopupModal>
|
</PopupModal>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
import { useState } from 'react'
|
|
||||||
|
|
||||||
import PopupModal from '~/components/popup/modal'
|
|
||||||
import FormLogin from '~/components/ui/form-login'
|
|
||||||
|
|
||||||
const AuthLayout = () => {
|
|
||||||
const [isModalOpen, setModalOpen] = useState(true)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="relative">
|
|
||||||
<div className="flex min-h-screen items-center justify-center bg-gray-100">
|
|
||||||
{/* Modal */}
|
|
||||||
<PopupModal
|
|
||||||
isOpen={isModalOpen}
|
|
||||||
onClose={() => setModalOpen(true)}
|
|
||||||
>
|
|
||||||
<FormLogin />
|
|
||||||
</PopupModal>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
export default AuthLayout
|
|
||||||
10
app/routes/_layout.dashboard.auth.tsx
Normal file
10
app/routes/_layout.dashboard.auth.tsx
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const AuthLayout = () => {
|
||||||
|
return (
|
||||||
|
<div className="relative">
|
||||||
|
<div className="flex min-h-screen items-center justify-center bg-gray-100">
|
||||||
|
Login
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default AuthLayout
|
||||||
Loading…
x
Reference in New Issue
Block a user