Compare commits
No commits in common. "6ec8e5f2a23ef13e36827c7d92a1a14cf8aae012" and "dbeec8acf371ea38edf46615ccca7260c9661d90" have entirely different histories.
6ec8e5f2a2
...
dbeec8acf3
@ -1,11 +1,10 @@
|
|||||||
import { Input } from '@headlessui/react'
|
import { Button, Input } from '@headlessui/react'
|
||||||
import { zodResolver } from '@hookform/resolvers/zod'
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
import { useEffect, useState, type ChangeEvent } from 'react'
|
import { useEffect, useState, type ChangeEvent } from 'react'
|
||||||
import { useFetcher } from 'react-router'
|
import { useFetcher } from 'react-router'
|
||||||
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
|
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { Button } from '~/components/ui/button'
|
|
||||||
import { uploadCategorySchema, useAdminContext } from '~/contexts/admin'
|
import { uploadCategorySchema, useAdminContext } from '~/contexts/admin'
|
||||||
|
|
||||||
export const uploadSchema = z.object({
|
export const uploadSchema = z.object({
|
||||||
@ -18,6 +17,7 @@ export type TUploadSchema = z.infer<typeof uploadSchema>
|
|||||||
export const FormUpload = () => {
|
export const FormUpload = () => {
|
||||||
const { isUploadOpen, setUploadedFile } = useAdminContext()
|
const { isUploadOpen, setUploadedFile } = useAdminContext()
|
||||||
const fetcher = useFetcher()
|
const fetcher = useFetcher()
|
||||||
|
const [disabled, setDisabled] = useState(false)
|
||||||
const [error, setError] = useState<string>()
|
const [error, setError] = useState<string>()
|
||||||
const maxFileSize = 10 * 1024 // 10MB
|
const maxFileSize = 10 * 1024 // 10MB
|
||||||
|
|
||||||
@ -32,11 +32,13 @@ export const FormUpload = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success) {
|
||||||
setError(fetcher.data?.message)
|
setError(fetcher.data?.message)
|
||||||
|
setDisabled(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setUploadedFile(fetcher.data.uploadData.data.file_url)
|
setUploadedFile(fetcher.data.uploadData.data.file_url)
|
||||||
|
|
||||||
|
setDisabled(true)
|
||||||
setError(undefined)
|
setError(undefined)
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher])
|
||||||
@ -108,10 +110,9 @@ export const FormUpload = () => {
|
|||||||
{...register('category')}
|
{...register('category')}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
disabled={fetcher.state !== 'idle'}
|
disabled={disabled}
|
||||||
isLoading={fetcher.state !== 'idle'}
|
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-full rounded-md py-2"
|
className="w-full rounded-md bg-[#2E2F7C] py-2 text-white transition hover:bg-blue-800"
|
||||||
>
|
>
|
||||||
Upload
|
Upload
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/react'
|
import { Button, Popover, PopoverButton, PopoverPanel } from '@headlessui/react'
|
||||||
import { Link, useFetcher, useRouteLoaderData } from 'react-router'
|
import { Link, useFetcher, useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
import { ChevronIcon } from '~/components/icons/chevron'
|
import { ChevronIcon } from '~/components/icons/chevron'
|
||||||
import { ProfileIcon } from '~/components/icons/profile'
|
import { ProfileIcon } from '~/components/icons/profile'
|
||||||
import { Button } from '~/components/ui/button'
|
|
||||||
import { APP } from '~/configs/meta'
|
import { APP } from '~/configs/meta'
|
||||||
import type { loader } from '~/routes/_admin.lg-admin'
|
import type { loader } from '~/routes/_admin.lg-admin'
|
||||||
|
|
||||||
@ -53,10 +52,8 @@ export const Navbar = () => {
|
|||||||
className="grid"
|
className="grid"
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
disabled={fetcher.state !== 'idle'}
|
|
||||||
isLoading={fetcher.state !== 'idle'}
|
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-full rounded p-1"
|
className="cursor-pointer rounded p-1 hover:bg-[#707FDD]/10 hover:text-[#5363AB]"
|
||||||
>
|
>
|
||||||
Logout
|
Logout
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -39,6 +39,7 @@ export const FormCategoryPage = (properties: TProperties) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
const [error, setError] = useState<string>()
|
const [error, setError] = useState<string>()
|
||||||
|
const [disabled, setDisabled] = useState(false)
|
||||||
|
|
||||||
const { handleSubmit, watch, setValue } = formMethods
|
const { handleSubmit, watch, setValue } = formMethods
|
||||||
const watchName = watch('name')
|
const watchName = watch('name')
|
||||||
@ -46,9 +47,11 @@ export const FormCategoryPage = (properties: TProperties) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success) {
|
||||||
setError(fetcher.data?.message)
|
setError(fetcher.data?.message)
|
||||||
|
setDisabled(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
navigate('/lg-admin/categories')
|
navigate('/lg-admin/categories')
|
||||||
|
setDisabled(true)
|
||||||
setError(undefined)
|
setError(undefined)
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher])
|
||||||
@ -93,8 +96,7 @@ export const FormCategoryPage = (properties: TProperties) => {
|
|||||||
containerClassName="flex-1"
|
containerClassName="flex-1"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
isLoading={fetcher.state !== 'idle'}
|
disabled={disabled}
|
||||||
disabled={fetcher.state !== 'idle'}
|
|
||||||
type="submit"
|
type="submit"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] rounded-md"
|
className="text-md h-[42px] rounded-md"
|
||||||
|
|||||||
@ -73,6 +73,7 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
const { categoriesData: categories } = loaderData || {}
|
const { categoriesData: categories } = loaderData || {}
|
||||||
const { tagsData: tags } = loaderData || {}
|
const { tagsData: tags } = loaderData || {}
|
||||||
const [error, setError] = useState<string>()
|
const [error, setError] = useState<string>()
|
||||||
|
const [disabled, setDisabled] = useState(false)
|
||||||
|
|
||||||
const formMethods = useRemixForm<TContentSchema>({
|
const formMethods = useRemixForm<TContentSchema>({
|
||||||
mode: 'onSubmit',
|
mode: 'onSubmit',
|
||||||
@ -99,10 +100,12 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success) {
|
||||||
setError(fetcher.data?.message)
|
setError(fetcher.data?.message)
|
||||||
|
setDisabled(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate('/lg-admin/contents')
|
navigate('/lg-admin/contents')
|
||||||
|
setDisabled(true)
|
||||||
setError(undefined)
|
setError(undefined)
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher])
|
||||||
@ -141,8 +144,7 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
containerClassName="flex-1"
|
containerClassName="flex-1"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
isLoading={fetcher.state !== 'idle'}
|
disabled={disabled}
|
||||||
disabled={fetcher.state !== 'idle'}
|
|
||||||
type="submit"
|
type="submit"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] rounded-md"
|
className="text-md h-[42px] rounded-md"
|
||||||
|
|||||||
@ -34,6 +34,7 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
const [error, setError] = useState<string>()
|
const [error, setError] = useState<string>()
|
||||||
|
const [disabled, setDisabled] = useState(false)
|
||||||
|
|
||||||
const { handleSubmit, watch, setValue } = formMethods
|
const { handleSubmit, watch, setValue } = formMethods
|
||||||
const watchName = watch('name')
|
const watchName = watch('name')
|
||||||
@ -41,9 +42,11 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success) {
|
||||||
setError(fetcher.data?.message)
|
setError(fetcher.data?.message)
|
||||||
|
setDisabled(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
navigate('/lg-admin/subscribe-plan')
|
navigate('/lg-admin/subscribe-plan')
|
||||||
|
setDisabled(true)
|
||||||
setError(undefined)
|
setError(undefined)
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher])
|
||||||
@ -90,8 +93,7 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
|
|||||||
containerClassName="flex-1"
|
containerClassName="flex-1"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
disabled={fetcher.state !== 'idle'}
|
disabled={disabled}
|
||||||
isLoading={fetcher.state !== 'idle'}
|
|
||||||
type="submit"
|
type="submit"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] rounded-md"
|
className="text-md h-[42px] rounded-md"
|
||||||
|
|||||||
@ -35,6 +35,7 @@ export const FormTagPage = (properties: TProperties) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
const [error, setError] = useState<string>()
|
const [error, setError] = useState<string>()
|
||||||
|
const [disabled, setDisabled] = useState(false)
|
||||||
|
|
||||||
const { handleSubmit, watch, setValue } = formMethods
|
const { handleSubmit, watch, setValue } = formMethods
|
||||||
const watchName = watch('name')
|
const watchName = watch('name')
|
||||||
@ -42,9 +43,11 @@ export const FormTagPage = (properties: TProperties) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success) {
|
||||||
setError(fetcher.data?.message)
|
setError(fetcher.data?.message)
|
||||||
|
setDisabled(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
navigate('/lg-admin/tags')
|
navigate('/lg-admin/tags')
|
||||||
|
setDisabled(true)
|
||||||
setError(undefined)
|
setError(undefined)
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher])
|
||||||
@ -89,8 +92,7 @@ export const FormTagPage = (properties: TProperties) => {
|
|||||||
containerClassName="flex-1"
|
containerClassName="flex-1"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
isLoading={fetcher.state !== 'idle'}
|
disabled={disabled}
|
||||||
disabled={fetcher.state !== 'idle'}
|
|
||||||
type="submit"
|
type="submit"
|
||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] rounded-md"
|
className="text-md h-[42px] rounded-md"
|
||||||
|
|||||||
@ -23,12 +23,14 @@ export const AdminLoginPage = () => {
|
|||||||
resolver: zodResolver(loginSchema),
|
resolver: zodResolver(loginSchema),
|
||||||
})
|
})
|
||||||
const [error, setError] = useState<string>()
|
const [error, setError] = useState<string>()
|
||||||
|
const [disabled, setDisabled] = useState(false)
|
||||||
|
|
||||||
const { handleSubmit } = formMethods
|
const { handleSubmit } = formMethods
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success) {
|
||||||
setError(fetcher.data?.message)
|
setError(fetcher.data?.message)
|
||||||
|
setDisabled(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@ -79,21 +81,18 @@ export const AdminLoginPage = () => {
|
|||||||
{/* Lupa Kata Sandi */}
|
{/* Lupa Kata Sandi */}
|
||||||
<div className="mb-4 flex justify-between">
|
<div className="mb-4 flex justify-between">
|
||||||
<span className="text-gray-600">Lupa Kata Sandi?</span>
|
<span className="text-gray-600">Lupa Kata Sandi?</span>
|
||||||
<Button
|
<Link
|
||||||
as={Link}
|
|
||||||
variant={'link'}
|
|
||||||
size="fit"
|
|
||||||
to="/lg-admin/auth/reset-password"
|
to="/lg-admin/auth/reset-password"
|
||||||
|
className="font-semibold text-[#2E2F7C]"
|
||||||
>
|
>
|
||||||
Reset Kata Sandi
|
Reset Kata Sandi
|
||||||
</Button>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
isLoading={fetcher.state !== 'idle'}
|
disabled={disabled}
|
||||||
disabled={fetcher.state !== 'idle'}
|
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-full rounded-md py-2"
|
className="w-full rounded-md bg-[#2E2F7C] py-2 text-white transition hover:bg-blue-800"
|
||||||
>
|
>
|
||||||
Masuk
|
Masuk
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user