Compare commits
68
Commits
fc23f45854
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b4ea17a16 | ||
|
|
eedb155880 | ||
|
|
84451f1fd4 | ||
|
|
dce745f53d | ||
|
|
57e23adf3c | ||
|
|
35c02d1643 | ||
|
|
1f2f15d204 | ||
|
|
39b7720186 | ||
|
|
de1802c597 | ||
|
|
724a14d741 | ||
|
|
fa5f7fbe92 | ||
|
|
4ff1e23d25 | ||
|
|
9ab67c615a | ||
|
|
65f7bbe0aa | ||
|
|
1c33eba834 | ||
|
|
1885eab4c3 | ||
|
|
f2f49de86b | ||
|
|
e81dad4ec5 | ||
|
|
63bbf70bd6 | ||
|
|
33096ab7c1 | ||
|
|
ab5b545625 | ||
|
|
06672714b7 | ||
|
|
2f8b5dbe0f | ||
|
|
09f8669553 | ||
|
|
731b36ef70 | ||
|
|
305c2cf140 | ||
|
|
6edca07fa6 | ||
|
|
d65aed6828 | ||
|
|
ab3f748195 | ||
|
|
3847fd1896 | ||
|
|
2dc84c582d | ||
|
|
b8378d37ad | ||
|
|
bb3e1bb139 | ||
|
|
66de3dcf04 | ||
|
|
9c9d127dfb | ||
|
|
9745fff853 | ||
|
|
deeefda8bc | ||
|
|
abf7e829ba | ||
|
|
ba4e380023 | ||
|
|
4ca2d8cf84 | ||
|
|
1585830184 | ||
|
|
22918b8bdb | ||
|
|
d32eb2e7ed | ||
|
|
87616ef6bd | ||
|
|
0f332fde79 | ||
|
|
c633397d7b | ||
|
|
680a0a88a2 | ||
|
|
d91dffb013 | ||
|
|
00bb1a46dc | ||
|
|
fe38a63f1c | ||
|
|
978d74d226 | ||
|
|
d767055bdb | ||
|
|
7b840ce5cd | ||
|
|
e7ef7177ca | ||
|
|
4c3a143338 | ||
|
|
cc5331284b | ||
|
|
c7195b7428 | ||
|
|
6d99a37f20 | ||
|
|
405e57b92d | ||
|
|
cbfb8e72cc | ||
|
|
3ddc657cfb | ||
|
|
52085ea25e | ||
|
|
84d10ac983 | ||
|
|
19a5e6ab88 | ||
|
|
d538c56d26 | ||
|
|
deb2004039 | ||
|
|
5c20cc48ab | ||
|
|
bfa46cdca4 |
@@ -2,6 +2,7 @@ import { z } from 'zod'
|
|||||||
|
|
||||||
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
import type { TAdsSchema } from '~/pages/form-advertisements'
|
import type { TAdsSchema } from '~/pages/form-advertisements'
|
||||||
|
import { datePayload } from '~/utils/formatter'
|
||||||
|
|
||||||
const advertisementsResponseSchema = z.object({
|
const advertisementsResponseSchema = z.object({
|
||||||
data: z.object({
|
data: z.object({
|
||||||
@@ -17,8 +18,8 @@ export const createAdsRequest = async (parameters: TParameters) => {
|
|||||||
const { payload, ...restParameters } = parameters
|
const { payload, ...restParameters } = parameters
|
||||||
const transformedPayload = {
|
const transformedPayload = {
|
||||||
...payload,
|
...payload,
|
||||||
start_date: new Date(payload.start_date).toISOString(),
|
start_date: datePayload(payload.start_date),
|
||||||
end_date: new Date(payload.end_date).toISOString(),
|
end_date: datePayload(payload.end_date),
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { data } = await HttpServer(restParameters).post(
|
const { data } = await HttpServer(restParameters).post(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { z } from 'zod'
|
|||||||
|
|
||||||
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
import type { TContentSchema } from '~/pages/form-contents'
|
import type { TContentSchema } from '~/pages/form-contents'
|
||||||
|
import { datePayload } from '~/utils/formatter'
|
||||||
|
|
||||||
const newsResponseSchema = z.object({
|
const newsResponseSchema = z.object({
|
||||||
data: z.object({
|
data: z.object({
|
||||||
@@ -20,7 +21,7 @@ export const createNewsRequest = async (parameters: TParameter) => {
|
|||||||
...restPayload,
|
...restPayload,
|
||||||
categories: categories.map((category) => category?.id),
|
categories: categories.map((category) => category?.id),
|
||||||
tags: tags?.map((tag) => tag?.id) || [],
|
tags: tags?.map((tag) => tag?.id) || [],
|
||||||
live_at: new Date(live_at).toISOString(),
|
live_at: datePayload(live_at),
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { data } = await HttpServer(restParameters).post(
|
const { data } = await HttpServer(restParameters).post(
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
|
import type { TStaffSchema } from '~/pages/form-staff'
|
||||||
|
|
||||||
|
const createStaffResponseSchema = z.object({
|
||||||
|
data: z.object({
|
||||||
|
Message: z.string(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
type TParameter = {
|
||||||
|
payload: TStaffSchema
|
||||||
|
} & THttpServer
|
||||||
|
|
||||||
|
export const createStaffsRequest = async (parameters: TParameter) => {
|
||||||
|
const { payload, ...restParameters } = parameters
|
||||||
|
try {
|
||||||
|
const { data } = await HttpServer(restParameters).post(
|
||||||
|
'/api/staff/register',
|
||||||
|
payload,
|
||||||
|
)
|
||||||
|
return createStaffResponseSchema.parse(data)
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
|
import type { TContentSchema } from '~/pages/form-contents'
|
||||||
|
|
||||||
|
const deleteContentsResponseSchema = z.object({
|
||||||
|
data: z.object({
|
||||||
|
Message: z.string(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
type TParameters = {
|
||||||
|
id: TContentSchema['id']
|
||||||
|
} & THttpServer
|
||||||
|
|
||||||
|
export const deleteContentsRequest = async (parameters: TParameters) => {
|
||||||
|
const { id, ...restParameters } = parameters
|
||||||
|
try {
|
||||||
|
const { data } = await HttpServer(restParameters).delete(
|
||||||
|
`/api/news/${id}/delete`,
|
||||||
|
)
|
||||||
|
|
||||||
|
return deleteContentsResponseSchema.parse(data)
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { newsResponseSchema } from '~/apis/common/get-news'
|
||||||
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
|
|
||||||
|
const dataResponseSchema = z.object({
|
||||||
|
data: z.object(newsResponseSchema.shape),
|
||||||
|
})
|
||||||
|
|
||||||
|
type TParameters = {
|
||||||
|
id: string
|
||||||
|
} & THttpServer
|
||||||
|
|
||||||
|
export const getNewsById = async (parameters: TParameters) => {
|
||||||
|
const { id, ...restParameters } = parameters
|
||||||
|
try {
|
||||||
|
const { data } = await HttpServer(restParameters).get(
|
||||||
|
`/api/staff/news/${encodeURIComponent(id)}`,
|
||||||
|
)
|
||||||
|
return dataResponseSchema.parse(data)
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ const staffResponseSchema = z.object({
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const getStaff = async (parameters: THttpServer) => {
|
export const getProfile = async (parameters: THttpServer) => {
|
||||||
try {
|
try {
|
||||||
const { data } = await HttpServer(parameters).get(`/api/staff/profile`)
|
const { data } = await HttpServer(parameters).get(`/api/staff/profile`)
|
||||||
return staffResponseSchema.parse(data)
|
return staffResponseSchema.parse(data)
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
|
|
||||||
|
const staffResponseSchema = z.object({
|
||||||
|
id: z.string(),
|
||||||
|
email: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
profile_picture: z.string(),
|
||||||
|
})
|
||||||
|
const staffsResponseSchema = z.object({
|
||||||
|
data: z.array(staffResponseSchema),
|
||||||
|
})
|
||||||
|
|
||||||
|
export type TStaffResponse = z.infer<typeof staffResponseSchema>
|
||||||
|
|
||||||
|
export const getStaffs = async (parameters: THttpServer) => {
|
||||||
|
try {
|
||||||
|
const { data } = await HttpServer(parameters).get(`/api/staff/get-all`)
|
||||||
|
return staffsResponseSchema.parse(data)
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ const userResponseSchema = z.object({
|
|||||||
email: z.string().email(),
|
email: z.string().email(),
|
||||||
phone: z.string(),
|
phone: z.string(),
|
||||||
subscribe: subscribeResponseSchema,
|
subscribe: subscribeResponseSchema,
|
||||||
|
created_at: z.string(),
|
||||||
})
|
})
|
||||||
const usersResponseSchema = z.object({
|
const usersResponseSchema = z.object({
|
||||||
data: z.array(userResponseSchema),
|
data: z.array(userResponseSchema),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { z } from 'zod'
|
|||||||
|
|
||||||
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
import type { TAdsSchema } from '~/pages/form-advertisements'
|
import type { TAdsSchema } from '~/pages/form-advertisements'
|
||||||
|
import { datePayload } from '~/utils/formatter'
|
||||||
|
|
||||||
const advertisementsResponseSchema = z.object({
|
const advertisementsResponseSchema = z.object({
|
||||||
data: z.object({
|
data: z.object({
|
||||||
@@ -18,8 +19,8 @@ export const updateAdsRequest = async (parameters: TParameters) => {
|
|||||||
const { id, ...restPayload } = payload
|
const { id, ...restPayload } = payload
|
||||||
const transformedPayload = {
|
const transformedPayload = {
|
||||||
...restPayload,
|
...restPayload,
|
||||||
start_date: new Date(payload.start_date).toISOString(),
|
start_date: datePayload(payload.start_date),
|
||||||
end_date: new Date(payload.end_date).toISOString(),
|
end_date: datePayload(payload.end_date),
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { data } = await HttpServer(restParameters).put(
|
const { data } = await HttpServer(restParameters).put(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { z } from 'zod'
|
|||||||
|
|
||||||
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
import type { TContentSchema } from '~/pages/form-contents'
|
import type { TContentSchema } from '~/pages/form-contents'
|
||||||
|
import { datePayload } from '~/utils/formatter'
|
||||||
|
|
||||||
const newsResponseSchema = z.object({
|
const newsResponseSchema = z.object({
|
||||||
data: z.object({
|
data: z.object({
|
||||||
@@ -20,7 +21,7 @@ export const updateNewsRequest = async (parameters: TParameter) => {
|
|||||||
...restPayload,
|
...restPayload,
|
||||||
categories: categories.map((category) => category?.id),
|
categories: categories.map((category) => category?.id),
|
||||||
tags: tags?.map((tag) => tag?.id) || [],
|
tags: tags?.map((tag) => tag?.id) || [],
|
||||||
live_at: new Date(live_at).toISOString(),
|
live_at: datePayload(live_at),
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { data } = await HttpServer(restParameters).put(
|
const { data } = await HttpServer(restParameters).put(
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import type { TProfileSchema } from '~/layouts/admin/dialog-profile'
|
||||||
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
|
|
||||||
|
const updateProfileResponseSchema = z.object({
|
||||||
|
data: z.object({
|
||||||
|
Message: z.string(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
type TParameter = {
|
||||||
|
payload: TProfileSchema
|
||||||
|
} & THttpServer
|
||||||
|
|
||||||
|
export const updateProfileRequest = async (parameters: TParameter) => {
|
||||||
|
const { payload, ...restParameters } = parameters
|
||||||
|
try {
|
||||||
|
const { data } = await HttpServer(restParameters).put(
|
||||||
|
'/api/staff/update',
|
||||||
|
payload,
|
||||||
|
)
|
||||||
|
return updateProfileResponseSchema.parse(data)
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
|
import type { TSubscribePlanSchema } from '~/pages/form-subscribe-plan'
|
||||||
|
|
||||||
|
const subscribePlanResponseSchema = z.object({
|
||||||
|
data: z.object({
|
||||||
|
Message: z.string(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
type TSubscribeSchema = Pick<TSubscribePlanSchema, 'id'>
|
||||||
|
type TParameters = {
|
||||||
|
payload: { subscribe_plan: TSubscribeSchema }
|
||||||
|
} & THttpServer
|
||||||
|
|
||||||
|
export const updateSubscribeRequest = async (parameters: TParameters) => {
|
||||||
|
const { payload, ...restParameters } = parameters
|
||||||
|
const { id } = payload.subscribe_plan
|
||||||
|
try {
|
||||||
|
const transformedPayload = {
|
||||||
|
status: 1,
|
||||||
|
subscribe_plan_id: id,
|
||||||
|
}
|
||||||
|
const { data } = await HttpServer(restParameters).patch(
|
||||||
|
`/api/subscribe/update`,
|
||||||
|
transformedPayload,
|
||||||
|
)
|
||||||
|
console.log(data) // eslint-disable-line no-console
|
||||||
|
|
||||||
|
return subscribePlanResponseSchema.parse(data)
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,9 +8,10 @@ const adResponseSchema = z.object({
|
|||||||
url: z.string(),
|
url: z.string(),
|
||||||
start_date: z.string(),
|
start_date: z.string(),
|
||||||
end_date: z.string(),
|
end_date: z.string(),
|
||||||
|
clicked: z.number(),
|
||||||
})
|
})
|
||||||
const adsResponseSchema = z.object({
|
const adsResponseSchema = z.object({
|
||||||
data: z.array(adResponseSchema),
|
data: z.array(adResponseSchema).nullable(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type TAdResponse = z.infer<typeof adResponseSchema>
|
export type TAdResponse = z.infer<typeof adResponseSchema>
|
||||||
|
|||||||
@@ -25,23 +25,37 @@ export const newsResponseSchema = z.object({
|
|||||||
author: authorSchema,
|
author: authorSchema,
|
||||||
})
|
})
|
||||||
const dataResponseSchema = z.object({
|
const dataResponseSchema = z.object({
|
||||||
data: z.array(newsResponseSchema),
|
data: z.array(
|
||||||
|
newsResponseSchema.extend({
|
||||||
|
views: z.number(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type TNewsResponse = z.infer<typeof newsResponseSchema>
|
export type TNewsResponse = z.infer<typeof newsResponseSchema>
|
||||||
|
export type TNewsResponseData = z.infer<typeof dataResponseSchema>
|
||||||
export type TAuthorResponse = z.infer<typeof authorSchema>
|
export type TAuthorResponse = z.infer<typeof authorSchema>
|
||||||
type TParameters = {
|
type TParameters = {
|
||||||
categories?: string[]
|
categories?: string[]
|
||||||
tags?: string[]
|
tags?: string[]
|
||||||
|
active?: boolean
|
||||||
|
limit?: number
|
||||||
|
page?: number
|
||||||
|
query?: string
|
||||||
} & THttpServer
|
} & THttpServer
|
||||||
|
|
||||||
export const getNews = async (parameters?: TParameters) => {
|
export const getNews = async (parameters?: TParameters) => {
|
||||||
const { categories, tags, ...restParameters } = parameters || {}
|
const { categories, tags, active, limit, page, query, ...restParameters } =
|
||||||
|
parameters || {}
|
||||||
try {
|
try {
|
||||||
const { data } = await HttpServer(restParameters).get(`/api/news`, {
|
const { data } = await HttpServer(restParameters).get(`/api/news`, {
|
||||||
params: {
|
params: {
|
||||||
...(categories && { categories: categories.join('+') }),
|
...(categories && { categories: categories.join('+') }),
|
||||||
...(tags && { tags: tags.join('+') }),
|
...(tags && { tags: tags.join('+') }),
|
||||||
|
...(active && { active }),
|
||||||
|
...(limit && { limit }),
|
||||||
|
...(page && { page }),
|
||||||
|
...(query && { q: query }),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
return dataResponseSchema.parse(data)
|
return dataResponseSchema.parse(data)
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||||
|
import type { TAdsSchema } from '~/pages/form-advertisements'
|
||||||
|
|
||||||
|
const logAdsResponseSchema = z.object({
|
||||||
|
data: z.object({
|
||||||
|
Message: z.string(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
type TParameters = {
|
||||||
|
id: TAdsSchema['id']
|
||||||
|
} & THttpServer
|
||||||
|
|
||||||
|
export const createLogAdsRequest = async (parameters: TParameters) => {
|
||||||
|
const { id, ...restParameters } = parameters
|
||||||
|
const payload = {
|
||||||
|
ads_id: id,
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const { data } = await HttpServer(restParameters).post(
|
||||||
|
'/api/logs/ads',
|
||||||
|
payload,
|
||||||
|
)
|
||||||
|
return logAdsResponseSchema.parse(data)
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|
||||||
import { type TLoginSchema } from '~/layouts/news/form-login'
|
import { type TLoginSchema } from '~/layouts/news/dialog-login'
|
||||||
import { HttpServer } from '~/libs/http-server'
|
import { HttpServer } from '~/libs/http-server'
|
||||||
|
|
||||||
export const loginResponseSchema = z.object({
|
export const loginResponseSchema = z.object({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { TRegisterSchema } from '~/layouts/news/form-register'
|
import type { TRegisterSchema } from '~/layouts/news/dialog-register'
|
||||||
import { HttpServer } from '~/libs/http-server'
|
import { HttpServer } from '~/libs/http-server'
|
||||||
|
|
||||||
import { loginResponseSchema } from './login-user'
|
import { loginResponseSchema } from './login-user'
|
||||||
|
|||||||
@@ -23,15 +23,13 @@ export const DialogDelete = (properties: TProperties) => {
|
|||||||
const fetcher = useFetcher()
|
const fetcher = useFetcher()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fetcher.data?.success === false) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
toast.error(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fetcher.data?.success === true) {
|
if (fetcher.data?.success) {
|
||||||
close()
|
close()
|
||||||
toast.success(`${title} berhasil dihapus!`)
|
toast.success(`${title} berhasil dihapus!`)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher.data])
|
}, [fetcher.data])
|
||||||
@@ -71,7 +69,7 @@ export const DialogDelete = (properties: TProperties) => {
|
|||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
variant="newsDanger"
|
variant="danger"
|
||||||
className="text-md h-[42px] rounded-md"
|
className="text-md h-[42px] rounded-md"
|
||||||
disabled={fetcher.state !== 'idle'}
|
disabled={fetcher.state !== 'idle'}
|
||||||
isLoading={fetcher.state !== 'idle'}
|
isLoading={fetcher.state !== 'idle'}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export const DialogSuccess = ({ isOpen, onClose }: ModalProperties) => {
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className="mt-5 w-full rounded-md"
|
className="mt-5 w-full rounded-md"
|
||||||
variant="newsPrimary"
|
variant="primary"
|
||||||
as={Link}
|
as={Link}
|
||||||
to="/"
|
to="/"
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
@@ -111,18 +111,18 @@ export const DialogSuccess = ({ isOpen, onClose }: ModalProperties) => {
|
|||||||
{userData ? (
|
{userData ? (
|
||||||
<Button
|
<Button
|
||||||
className="mt-5 w-full rounded-md"
|
className="mt-5 w-full rounded-md"
|
||||||
variant="newsSecondary"
|
variant="outline"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onClose()
|
onClose()
|
||||||
setIsSubscribeOpen(true)
|
setIsSubscribeOpen(true)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Select Subscribe Plan
|
Pilih Paken Berlangganan
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
className="mt-5 w-full rounded-md"
|
className="mt-5 w-full rounded-md"
|
||||||
variant="newsPrimary"
|
variant="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onClose()
|
onClose()
|
||||||
setIsLoginOpen(true)
|
setIsLoginOpen(true)
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { useAsyncError } from 'react-router'
|
||||||
|
|
||||||
|
export const ErrorAwait = () => {
|
||||||
|
const error = useAsyncError()
|
||||||
|
return (
|
||||||
|
<p>
|
||||||
|
{error instanceof Error ? error.message : 'An unexpected error occurred.'}
|
||||||
|
</p>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import type { JSX, SVGProps } from 'react'
|
|
||||||
/**
|
|
||||||
* Note: `ChevronIcon` default mengarah ke bawah.
|
|
||||||
* Gunakan class `rotate-xx` untuk mengubah arah ikon.
|
|
||||||
*/
|
|
||||||
export const ChevronIcon = (
|
|
||||||
properties: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
|
|
||||||
) => {
|
|
||||||
return (
|
|
||||||
<svg
|
|
||||||
width={21}
|
|
||||||
height={21}
|
|
||||||
viewBox="0 0 21 21"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
className={properties.className}
|
|
||||||
{...properties}
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M10.197 13.623l5.008-5.008-1.177-1.18-3.83 3.834-3.831-3.833-1.178 1.178 5.008 5.009z"
|
|
||||||
fill="currentColor"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import type { JSX, SVGProps } from 'react'
|
|
||||||
|
|
||||||
export const DoctorIcon = (
|
|
||||||
properties: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
|
|
||||||
) => {
|
|
||||||
return (
|
|
||||||
<svg
|
|
||||||
width={25}
|
|
||||||
height={28}
|
|
||||||
viewBox="0 0 25 28"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
{...properties}
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M12.714 14.364a6.821 6.821 0 006.822-6.822A6.821 6.821 0 0012.714.72a6.822 6.822 0 00-6.822 6.822 6.822 6.822 0 006.822 6.822zM6.32 23.318c0 .708.57 1.279 1.279 1.279s1.279-.57 1.279-1.28c0-.708-.57-1.278-1.28-1.278-.708 0-1.278.57-1.278 1.279zM17.83 16.1v2.612a4.27 4.27 0 013.41 4.178v2.223a.855.855 0 01-.687.837l-1.716.34a.424.424 0 01-.501-.335l-.165-.837a.422.422 0 01.336-.5l1.028-.209v-1.519c0-3.347-5.116-3.47-5.116.102v1.423l1.028.207c.23.048.379.272.336.502l-.165.836a.432.432 0 01-.501.336l-1.663-.224a.852.852 0 01-.736-.847V22.89a4.274 4.274 0 013.412-4.178v-2.41c-.118.038-.235.06-.352.102a9.244 9.244 0 01-3.06.522c-1.07 0-2.1-.186-3.059-.522a5.889 5.889 0 00-1.204-.277v4.349a2.974 2.974 0 012.132 2.846 2.987 2.987 0 01-2.985 2.985 2.987 2.987 0 01-2.985-2.985c0-1.348.901-2.478 2.132-2.846v-4.285c-3.39.57-5.974 3.49-5.974 7.04v2.388a2.39 2.39 0 002.387 2.388h19.102a2.39 2.39 0 002.388-2.388v-2.388c0-3.837-3.028-6.944-6.822-7.13z"
|
|
||||||
fill="currentColor"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import type { JSX, SVGProps } from 'react'
|
|
||||||
|
|
||||||
export const GraphIcon = (
|
|
||||||
properties: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
|
|
||||||
) => {
|
|
||||||
return (
|
|
||||||
<svg
|
|
||||||
width={29}
|
|
||||||
height={28}
|
|
||||||
viewBox="0 0 29 28"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
{...properties}
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
d="M19.383 2.499H9.471c-4.306 0-6.872 2.496-6.872 6.682v9.625c0 4.197 2.566 6.693 6.872 6.693h9.9c4.306 0 6.873-2.495 6.873-6.681V9.18c.012-4.186-2.555-6.682-6.86-6.682zM9.258 21.071c0 .472-.402.863-.887.863s-.887-.391-.887-.863v-2.38c0-.471.402-.863.887-.863s.887.392.887.863v2.38zm6.056 0c0 .472-.402.863-.887.863s-.887-.391-.887-.863V16.3c0-.471.402-.862.887-.862s.887.39.887.862v4.773zm6.057 0c0 .472-.403.863-.888.863s-.887-.391-.887-.863v-7.153c0-.471.402-.862.887-.862s.888.391.888.863v7.152zm0-10.787c0 .472-.403.863-.888.863s-.887-.391-.887-.863V9.17a23.266 23.266 0 01-11.012 6.164c-.071.023-.142.023-.213.023a.891.891 0 01-.864-.655.859.859 0 01.651-1.047 21.515 21.515 0 0010.35-5.876H17.03c-.485 0-.887-.391-.887-.863 0-.471.402-.862.887-.862h3.466c.048 0 .083.023.13.023.06.011.119.011.178.034.059.023.106.058.165.092.036.023.071.035.107.058.012.011.012.023.024.023.047.046.082.092.118.138.035.046.07.08.083.126.023.046.023.092.035.15.012.057.036.115.036.184 0 .011.011.023.011.034v3.37h-.011z"
|
|
||||||
fill="currentColor"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import type { JSX, SVGProps } from 'react'
|
||||||
|
|
||||||
|
export const ImageSkeletonIcon = (
|
||||||
|
properties: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
|
||||||
|
) => {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
width={40}
|
||||||
|
height={40}
|
||||||
|
aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="currentColor"
|
||||||
|
viewBox="0 0 20 18"
|
||||||
|
{...properties}
|
||||||
|
>
|
||||||
|
<path d="M18 0H2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm4.376 10.481A1 1 0 0 1 16 15H4a1 1 0 0 1-.895-1.447l3.5-7A1 1 0 0 1 7.468 6a.965.965 0 0 1 .9.5l2.775 4.757 1.546-1.887a1 1 0 0 1 1.618.1l2.541 4a1 1 0 0 1 .028 1.011Z" />
|
||||||
|
</svg>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import type { JSX, SVGProps } from 'react'
|
|
||||||
|
|
||||||
export const ProfileIcon = (
|
|
||||||
properties: JSX.IntrinsicAttributes & SVGProps<SVGSVGElement>,
|
|
||||||
) => {
|
|
||||||
return (
|
|
||||||
<svg
|
|
||||||
width={18}
|
|
||||||
height={19}
|
|
||||||
viewBox="0 0 18 19"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
{...properties}
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
fillRule="evenodd"
|
|
||||||
clipRule="evenodd"
|
|
||||||
d="M12.97 5.82A3.956 3.956 0 019 9.789a3.956 3.956 0 01-3.97-3.97A3.955 3.955 0 019 1.853a3.955 3.955 0 013.97 3.968zM9 16.852c-3.253 0-6-.53-6-2.57s2.764-2.55 6-2.55c3.254 0 6 .529 6 2.569s-2.764 2.55-6 2.55z"
|
|
||||||
fill="currentColor"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
Bars3BottomLeftIcon,
|
Bars3BottomLeftIcon,
|
||||||
Bars3BottomRightIcon,
|
Bars3BottomRightIcon,
|
||||||
Bars3Icon,
|
Bars3Icon,
|
||||||
Bars4Icon,
|
|
||||||
BoldIcon,
|
BoldIcon,
|
||||||
CloudArrowUpIcon,
|
CloudArrowUpIcon,
|
||||||
CodeBracketIcon,
|
CodeBracketIcon,
|
||||||
@@ -21,7 +20,12 @@ import {
|
|||||||
PhotoIcon,
|
PhotoIcon,
|
||||||
StrikethroughIcon,
|
StrikethroughIcon,
|
||||||
SwatchIcon,
|
SwatchIcon,
|
||||||
} from '@heroicons/react/20/solid'
|
XCircleIcon,
|
||||||
|
} from '@heroicons/react/24/solid'
|
||||||
|
import {
|
||||||
|
Bars3BottomCenterIcon,
|
||||||
|
QuotationMarkIcon,
|
||||||
|
} from '@sidekickicons/react/24/solid'
|
||||||
import type { Editor } from '@tiptap/react'
|
import type { Editor } from '@tiptap/react'
|
||||||
import {
|
import {
|
||||||
type SetStateAction,
|
type SetStateAction,
|
||||||
@@ -202,7 +206,7 @@ export const EditorMenuBar = (properties: TProperties) => {
|
|||||||
isActive={editor.isActive({ textAlign: 'center' })}
|
isActive={editor.isActive({ textAlign: 'center' })}
|
||||||
title="Align Center"
|
title="Align Center"
|
||||||
>
|
>
|
||||||
<Bars3Icon className="size-4" />
|
<Bars3BottomCenterIcon className="size-4" />
|
||||||
</EditorButton>
|
</EditorButton>
|
||||||
<EditorButton
|
<EditorButton
|
||||||
onClick={() => editor.chain().focus().setTextAlign('right').run()}
|
onClick={() => editor.chain().focus().setTextAlign('right').run()}
|
||||||
@@ -224,7 +228,7 @@ export const EditorMenuBar = (properties: TProperties) => {
|
|||||||
isActive={editor.isActive({ textAlign: 'justify' })}
|
isActive={editor.isActive({ textAlign: 'justify' })}
|
||||||
title="Align Justify"
|
title="Align Justify"
|
||||||
>
|
>
|
||||||
<Bars4Icon className="size-4" />
|
<Bars3Icon className="size-4" />
|
||||||
</EditorButton>
|
</EditorButton>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex max-w-[150px] flex-wrap items-start gap-1 px-1">
|
<div className="flex max-w-[150px] flex-wrap items-start gap-1 px-1">
|
||||||
@@ -258,14 +262,14 @@ export const EditorMenuBar = (properties: TProperties) => {
|
|||||||
>
|
>
|
||||||
<H3Icon className="size-4" />
|
<H3Icon className="size-4" />
|
||||||
</EditorButton>
|
</EditorButton>
|
||||||
{/* <EditorButton
|
<EditorButton
|
||||||
onClick={() => editor.chain().focus().setParagraph().run()}
|
onClick={() => editor.chain().focus().toggleCodeBlock().run()}
|
||||||
isActive={editor.isActive('paragraph')}
|
isActive={editor.isActive('codeBlock')}
|
||||||
title="Paragraph"
|
title="Code Block"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
<RiParagraph />
|
<CodeBracketIcon className="size-4" />
|
||||||
</EditorButton> */}
|
</EditorButton>
|
||||||
<EditorButton
|
<EditorButton
|
||||||
onClick={() => editor.chain().focus().toggleBulletList().run()}
|
onClick={() => editor.chain().focus().toggleBulletList().run()}
|
||||||
isActive={editor.isActive('bulletList')}
|
isActive={editor.isActive('bulletList')}
|
||||||
@@ -282,39 +286,21 @@ export const EditorMenuBar = (properties: TProperties) => {
|
|||||||
>
|
>
|
||||||
<NumberedListIcon className="size-4" />
|
<NumberedListIcon className="size-4" />
|
||||||
</EditorButton>
|
</EditorButton>
|
||||||
<EditorButton
|
{/* <EditorButton
|
||||||
onClick={() => editor.chain().focus().toggleCodeBlock().run()}
|
onClick={() => editor.chain().focus().setParagraph().run()}
|
||||||
isActive={editor.isActive('codeBlock')}
|
isActive={editor.isActive('paragraph')}
|
||||||
title="Code Block"
|
title="Paragraph"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
<CodeBracketIcon className="size-4" />
|
<PilcrowIcon className="size-4" />
|
||||||
</EditorButton>
|
</EditorButton> */}
|
||||||
</div>
|
|
||||||
{/* <div className="flex items-start gap-1 px-1">
|
|
||||||
<EditorButton
|
<EditorButton
|
||||||
onClick={() => editor.chain().focus().toggleBlockquote().run()}
|
onClick={() => editor.chain().focus().toggleBlockquote().run()}
|
||||||
isActive={editor.isActive('blockquote')}
|
isActive={editor.isActive('blockquote')}
|
||||||
title="Blockquote"
|
title="Blockquote"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
<RiDoubleQuotesL />
|
<QuotationMarkIcon className="size-4" />
|
||||||
</EditorButton>
|
|
||||||
<EditorButton
|
|
||||||
onClick={() => editor.chain().focus().setHorizontalRule().run()}
|
|
||||||
title="Horizontal Rule"
|
|
||||||
disabled={disabled}
|
|
||||||
>
|
|
||||||
<RiSeparator />
|
|
||||||
</EditorButton>
|
|
||||||
</div> */}
|
|
||||||
{/* <div className="flex items-start gap-1 px-1">
|
|
||||||
<EditorButton
|
|
||||||
onClick={() => editor.chain().focus().setHardBreak().run()}
|
|
||||||
title="Hard Break"
|
|
||||||
disabled={disabled}
|
|
||||||
>
|
|
||||||
<RiTextWrap />
|
|
||||||
</EditorButton>
|
</EditorButton>
|
||||||
<EditorButton
|
<EditorButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -324,7 +310,23 @@ export const EditorMenuBar = (properties: TProperties) => {
|
|||||||
title="Clear Format"
|
title="Clear Format"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
<RiFormatClear />
|
<XCircleIcon className="size-4" />
|
||||||
|
</EditorButton>
|
||||||
|
{/* <EditorButton
|
||||||
|
onClick={() => editor.chain().focus().setHorizontalRule().run()}
|
||||||
|
title="Horizontal Rule"
|
||||||
|
disabled={disabled}
|
||||||
|
>
|
||||||
|
<RiSeparator />
|
||||||
|
</EditorButton> */}
|
||||||
|
</div>
|
||||||
|
{/* <div className="flex items-start gap-1 px-1">
|
||||||
|
<EditorButton
|
||||||
|
onClick={() => editor.chain().focus().setHardBreak().run()}
|
||||||
|
title="Hard Break"
|
||||||
|
disabled={disabled}
|
||||||
|
>
|
||||||
|
<RiTextWrap />
|
||||||
</EditorButton>
|
</EditorButton>
|
||||||
</div> */}
|
</div> */}
|
||||||
<div className="flex items-start gap-1 px-1">
|
<div className="flex items-start gap-1 px-1">
|
||||||
@@ -359,7 +361,7 @@ export const EditorMenuBar = (properties: TProperties) => {
|
|||||||
setIsUploadOpen('content')
|
setIsUploadOpen('content')
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CloudArrowUpIcon className="h-4 w-4 text-gray-500/50" />
|
<CloudArrowUpIcon className="size-4 text-gray-500/50" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { CodeBracketSquareIcon } from '@heroicons/react/20/solid'
|
import { CodeBracketSquareIcon } from '@heroicons/react/24/solid'
|
||||||
import MonacoEditor from '@monaco-editor/react'
|
import MonacoEditor from '@monaco-editor/react'
|
||||||
import type { Dispatch, SetStateAction } from 'react'
|
import type { Dispatch, SetStateAction } from 'react'
|
||||||
import { Controller } from 'react-hook-form'
|
import { Controller } from 'react-hook-form'
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Button as HeadlessButton } from '@headlessui/react'
|
import { Button as HeadlessButton } from '@headlessui/react'
|
||||||
import { ArrowPathIcon } from '@heroicons/react/20/solid'
|
import { ArrowPathIcon } from '@heroicons/react/24/solid'
|
||||||
import { cva, type VariantProps } from 'class-variance-authority'
|
import { cva, type VariantProps } from 'class-variance-authority'
|
||||||
import type { ReactNode, ElementType, ComponentPropsWithoutRef } from 'react'
|
import type { ReactNode, ElementType, ComponentPropsWithoutRef } from 'react'
|
||||||
import { twMerge } from 'tailwind-merge'
|
import { twMerge } from 'tailwind-merge'
|
||||||
@@ -9,28 +9,30 @@ const buttonVariants = cva(
|
|||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
newsPrimary:
|
primary:
|
||||||
'bg-[#2E2F7C] text-white text-lg hover:bg-[#4C5CA0] hover:shadow transition active:bg-[#6970B4]',
|
'bg-[#2E2F7C] text-white text-lg hover:bg-[#4C5CA0] hover:shadow transition active:bg-[#6970B4]',
|
||||||
newsDanger:
|
danger:
|
||||||
'bg-[#EF4444] text-white text-lg hover:shadow transition active:bg-[#FEE2E2] hover:bg-[#FCA5A5]',
|
'bg-[#EF4444] text-white text-lg hover:shadow transition active:bg-[#FEE2E2] hover:bg-[#FCA5A5]',
|
||||||
newsPrimaryOutline:
|
primaryOutline:
|
||||||
'border-[3px] bg-[#2E2F7C] border-white text-white text-lg hover:bg-[#4C5CA0] hover:shadow-lg active:shadow-2xl transition active:bg-[#6970B4]',
|
'border-[3px] bg-[#2E2F7C] border-white text-white text-lg hover:bg-[#4C5CA0] hover:shadow-lg active:shadow-2xl transition active:bg-[#6970B4]',
|
||||||
newsSecondary:
|
outline:
|
||||||
'border-[3px] bg-white hover:shadow-lg active:shadow-2xl border-[#2E2F7C] text-[#2E2F7C] hover:text-[#4C5CA0] active:text-[#6970B4] text-lg hover:border-[#4C5CA0] transition active:border-[#6970B4]',
|
'border-[3px] bg-white hover:shadow-lg active:shadow-2xl border-[#2E2F7C] text-[#2E2F7C] hover:text-[#4C5CA0] active:text-[#6970B4] text-lg hover:border-[#4C5CA0] transition active:border-[#6970B4]',
|
||||||
icon: '',
|
icon: '',
|
||||||
link: 'font-semibold text-[#2E2F7C] hover:text-[#4C5CA0] active:text-[#6970B4] transition',
|
link: 'font-semibold text-[#2E2F7C] hover:text-[#4C5CA0] active:text-[#6970B4] transition',
|
||||||
|
secondary:
|
||||||
|
'hover:bg-[#707FDD]/10 active:bg-[#707FDD]/20 hover:text-[#707FDD] text-[#273240]',
|
||||||
},
|
},
|
||||||
size: {
|
size: {
|
||||||
default: 'h-[50px] w-[150px]',
|
default: 'h-[50px] w-[150px]',
|
||||||
block: 'h-[50px] w-full',
|
block: 'h-[50px] w-full',
|
||||||
icon: 'h-9 w-9 rounded-full',
|
icon: 'size-9 rounded-full',
|
||||||
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',
|
fit: 'w-fit',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
defaultVariants: {
|
defaultVariants: {
|
||||||
variant: 'newsPrimary',
|
variant: 'primary',
|
||||||
size: 'default',
|
size: 'default',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -42,6 +44,7 @@ type ButtonBaseProperties = {
|
|||||||
size?: VariantProps<typeof buttonVariants>['size']
|
size?: VariantProps<typeof buttonVariants>['size']
|
||||||
className?: string
|
className?: string
|
||||||
isLoading?: boolean
|
isLoading?: boolean
|
||||||
|
icon?: ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
type PolymorphicReference<C extends ElementType> =
|
type PolymorphicReference<C extends ElementType> =
|
||||||
@@ -62,6 +65,7 @@ export const Button = <C extends ElementType = 'button'>(
|
|||||||
size,
|
size,
|
||||||
className,
|
className,
|
||||||
isLoading = false,
|
isLoading = false,
|
||||||
|
icon,
|
||||||
...restProperties
|
...restProperties
|
||||||
} = properties
|
} = properties
|
||||||
const Component = as || HeadlessButton
|
const Component = as || HeadlessButton
|
||||||
@@ -72,7 +76,7 @@ export const Button = <C extends ElementType = 'button'>(
|
|||||||
className={classes}
|
className={classes}
|
||||||
{...restProperties}
|
{...restProperties}
|
||||||
>
|
>
|
||||||
{isLoading && <ArrowPathIcon className="animate-spin" />}
|
{isLoading ? <ArrowPathIcon className="size-5 animate-spin" /> : icon}
|
||||||
{children}
|
{children}
|
||||||
</Component>
|
</Component>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { JSX } from 'react'
|
import type { ComponentType, SVGProps } from 'react'
|
||||||
|
|
||||||
import { formatNumberWithPeriods } from '~/utils/formatter'
|
import { formatNumberWithPeriods } from '~/utils/formatter'
|
||||||
|
|
||||||
@@ -6,15 +6,12 @@ type CardReportProperty = {
|
|||||||
title: string
|
title: string
|
||||||
amount: number
|
amount: number
|
||||||
currency?: string
|
currency?: string
|
||||||
icon: (
|
icon: ComponentType<SVGProps<SVGSVGElement>>
|
||||||
properties: React.JSX.IntrinsicAttributes & React.SVGProps<SVGSVGElement>,
|
|
||||||
) => JSX.Element
|
|
||||||
url?: string
|
url?: string
|
||||||
counter?: number[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CardReport = (properties: CardReportProperty) => {
|
export const CardReport = (properties: CardReportProperty) => {
|
||||||
const { title, amount, icon: Icon, counter, currency } = properties
|
const { title, amount, icon: Icon, currency } = properties
|
||||||
return (
|
return (
|
||||||
<div className="rounded-xl bg-white px-4 py-6 shadow-sm">
|
<div className="rounded-xl bg-white px-4 py-6 shadow-sm">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
@@ -32,11 +29,6 @@ export const CardReport = (properties: CardReportProperty) => {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{counter?.length && (
|
|
||||||
<div className="flex items-center pt-2">
|
|
||||||
Pribadi: {counter[0]} | Perusahaan: {counter[1]}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
import useEmblaCarousel from 'embla-carousel-react'
|
import useEmblaCarousel from 'embla-carousel-react'
|
||||||
import { useCallback, useEffect, useState } from 'react'
|
import { Suspense, useCallback, useEffect, useState } from 'react'
|
||||||
import { useRouteLoaderData } from 'react-router'
|
import { Await, useRouteLoaderData } from 'react-router'
|
||||||
import { stripHtml } from 'string-strip-html'
|
import { stripHtml } from 'string-strip-html'
|
||||||
|
|
||||||
import { Button } from '~/components/ui/button'
|
import { ErrorAwait } from '~/components/error/await'
|
||||||
|
import { ImageSkeletonIcon } from '~/components/icons/image-skeleton'
|
||||||
import { CarouselButton } from '~/components/ui/button-slide'
|
import { CarouselButton } from '~/components/ui/button-slide'
|
||||||
import { useNewsContext } from '~/contexts/news'
|
import { useNewsContext } from '~/contexts/news'
|
||||||
import type { loader } from '~/routes/_news'
|
import type { loader } from '~/routes/_news'
|
||||||
import type { TNews } from '~/types/news'
|
import type { TNews } from '~/types/news'
|
||||||
import { getPremiumAttribute } from '~/utils/render'
|
import { getPremiumAttribute } from '~/utils/render'
|
||||||
|
|
||||||
|
import { Button } from './button'
|
||||||
|
|
||||||
export const CarouselHero = (properties: TNews) => {
|
export const CarouselHero = (properties: TNews) => {
|
||||||
const { setIsSuccessOpen } = useNewsContext()
|
const { setIsSuccessOpen } = useNewsContext()
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
||||||
@@ -72,15 +75,51 @@ export const CarouselHero = (properties: TNews) => {
|
|||||||
ref={emblaReference}
|
ref={emblaReference}
|
||||||
>
|
>
|
||||||
<div className="embla__container hero flex sm:gap-x-8">
|
<div className="embla__container hero flex sm:gap-x-8">
|
||||||
{items.map(
|
<Suspense
|
||||||
({ featured_image, title, content, slug, is_premium }, index) => (
|
fallback={
|
||||||
|
<div className="embla__slide hero flex w-full min-w-0 flex-none animate-pulse justify-between gap-3 max-sm:mt-2 sm:flex">
|
||||||
|
<div className="flex aspect-[174/100] h-full items-center justify-center rounded-md bg-gray-300 dark:bg-gray-700">
|
||||||
|
<ImageSkeletonIcon />
|
||||||
|
</div>
|
||||||
|
<div className="flex w-full flex-col gap-7">
|
||||||
|
<div className="flex flex-col gap-4">
|
||||||
|
<div className="h-6 w-full rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-6 w-[20%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col gap-2.5">
|
||||||
|
<div className="h-5 rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 max-w-[90%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 max-w-[90%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 max-w-[90%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 max-w-[90%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 max-w-[50%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
</div>
|
||||||
|
<div className="h-[50px] w-full bg-gray-200 dark:bg-gray-700" />
|
||||||
|
</div>
|
||||||
|
<span className="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Await
|
||||||
|
resolve={items}
|
||||||
|
errorElement={<ErrorAwait />}
|
||||||
|
>
|
||||||
|
{(value) =>
|
||||||
|
value.data.map(
|
||||||
|
(
|
||||||
|
{ featured_image, title, content, slug, is_premium },
|
||||||
|
index,
|
||||||
|
) => (
|
||||||
<div
|
<div
|
||||||
className="embla__slide hero w-full min-w-0 flex-none"
|
className="embla__slide hero w-full min-w-0 flex-none max-sm:mt-2 sm:flex"
|
||||||
key={index}
|
key={index}
|
||||||
>
|
>
|
||||||
<div className="max-sm:mt-2 sm:flex">
|
|
||||||
<img
|
<img
|
||||||
className="col-span-2 aspect-[174/100] object-cover"
|
className="aspect-[174/100] h-full rounded-md object-cover"
|
||||||
src={featured_image}
|
src={featured_image}
|
||||||
alt={title}
|
alt={title}
|
||||||
/>
|
/>
|
||||||
@@ -106,9 +145,11 @@ export const CarouselHero = (properties: TNews) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
|
</Await>
|
||||||
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
import useEmblaCarousel from 'embla-carousel-react'
|
import useEmblaCarousel from 'embla-carousel-react'
|
||||||
import { useCallback, useEffect, useState } from 'react'
|
import { Suspense, useCallback, useEffect, useState } from 'react'
|
||||||
import { useRouteLoaderData } from 'react-router'
|
import { Await, useRouteLoaderData } from 'react-router'
|
||||||
import { stripHtml } from 'string-strip-html'
|
import { stripHtml } from 'string-strip-html'
|
||||||
|
|
||||||
import { Button } from '~/components/ui/button'
|
import { ErrorAwait } from '~/components/error/await'
|
||||||
|
import { ImageSkeletonIcon } from '~/components/icons/image-skeleton'
|
||||||
import { CarouselButton } from '~/components/ui/button-slide'
|
import { CarouselButton } from '~/components/ui/button-slide'
|
||||||
import { useNewsContext } from '~/contexts/news'
|
import { useNewsContext } from '~/contexts/news'
|
||||||
import type { loader } from '~/routes/_news'
|
import type { loader } from '~/routes/_news'
|
||||||
import type { TNews } from '~/types/news'
|
import type { TNews } from '~/types/news'
|
||||||
import { getPremiumAttribute } from '~/utils/render'
|
import { getPremiumAttribute } from '~/utils/render'
|
||||||
|
|
||||||
|
import { Button } from './button'
|
||||||
import { Tags } from './tags'
|
import { Tags } from './tags'
|
||||||
|
|
||||||
export const CarouselSection = (properties: TNews) => {
|
export const CarouselSection = (properties: TNews) => {
|
||||||
@@ -79,35 +81,63 @@ export const CarouselSection = (properties: TNews) => {
|
|||||||
ref={emblaReference}
|
ref={emblaReference}
|
||||||
>
|
>
|
||||||
<div className="embla__container col-span-3 flex max-h-[586px] sm:gap-x-8">
|
<div className="embla__container col-span-3 flex max-h-[586px] sm:gap-x-8">
|
||||||
{items.map(
|
<Suspense
|
||||||
|
fallback={Array.from({ length: 3 }).map((_, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className="embla__slide flex w-full min-w-0 flex-none animate-pulse flex-col justify-between gap-3 sm:w-1/3"
|
||||||
|
>
|
||||||
|
<div className="flex h-[280px] w-full items-center justify-center rounded-md bg-gray-300 dark:bg-gray-700">
|
||||||
|
<ImageSkeletonIcon />
|
||||||
|
</div>
|
||||||
|
<div className="flex w-full flex-col gap-4">
|
||||||
|
<div className="flex flex-col gap-4">
|
||||||
|
<div className="h-6 w-full rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-6 w-[20%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col gap-2.5">
|
||||||
|
<div className="h-5 max-w-[80%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 max-w-[50%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="h-[50px] w-full bg-gray-200 dark:bg-gray-700" />
|
||||||
|
<span className="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
>
|
||||||
|
<Await
|
||||||
|
resolve={items}
|
||||||
|
errorElement={<ErrorAwait />}
|
||||||
|
>
|
||||||
|
{(value) =>
|
||||||
|
value.data.map(
|
||||||
(
|
(
|
||||||
{ featured_image, title, content, tags, slug, is_premium },
|
{ featured_image, title, content, tags, slug, is_premium },
|
||||||
index,
|
index,
|
||||||
) => (
|
) => (
|
||||||
<div
|
<div
|
||||||
className="embla__slide w-full min-w-0 flex-none sm:w-1/3"
|
className="embla__slide flex w-full min-w-0 flex-none flex-col justify-between gap-3 sm:w-1/3"
|
||||||
key={index}
|
key={index}
|
||||||
>
|
>
|
||||||
<div className="flex flex-col justify-between gap-3">
|
|
||||||
<img
|
<img
|
||||||
className="aspect-[174/100] max-h-[280px] w-full rounded-md object-cover sm:aspect-[5/4]"
|
className="aspect-[174/100] max-h-[280px] w-full rounded-md object-cover sm:aspect-[5/4]"
|
||||||
src={featured_image}
|
src={featured_image}
|
||||||
alt={title}
|
alt={title}
|
||||||
/>
|
/>
|
||||||
<div className={'flex flex-col justify-between gap-4'}>
|
<div className={'flex flex-col justify-between gap-4'}>
|
||||||
|
<div className="flex h-28 flex-col items-start justify-center gap-4">
|
||||||
<Tags
|
<Tags
|
||||||
tags={tags || []}
|
tags={tags || []}
|
||||||
is_premium={is_premium}
|
is_premium={is_premium}
|
||||||
/>
|
/>
|
||||||
|
<h3 className="mt-2 line-clamp-2 w-full text-xl font-bold sm:text-2xl lg:mt-0">
|
||||||
<div>
|
|
||||||
<h3 className="mt-2 w-full text-xl font-bold sm:text-2xl lg:mt-0">
|
|
||||||
{title}
|
{title}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-md mt-5 line-clamp-3 text-[#777777] sm:text-xl">
|
</div>
|
||||||
|
<p className="line-clamp-3 text-base text-[#777777] sm:text-xl">
|
||||||
{stripHtml(content).result}
|
{stripHtml(content).result}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
<Button
|
<Button
|
||||||
size="block"
|
size="block"
|
||||||
{...getPremiumAttribute({
|
{...getPremiumAttribute({
|
||||||
@@ -116,15 +146,16 @@ export const CarouselSection = (properties: TNews) => {
|
|||||||
onClick: () => setIsSuccessOpen('warning'),
|
onClick: () => setIsSuccessOpen('warning'),
|
||||||
userData,
|
userData,
|
||||||
})}
|
})}
|
||||||
className="mb-5"
|
|
||||||
>
|
>
|
||||||
View More
|
View More
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
),
|
),
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
|
</Await>
|
||||||
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,23 +1,20 @@
|
|||||||
import { useRouteLoaderData } from 'react-router'
|
import { Suspense } from 'react'
|
||||||
|
import { Await, useRouteLoaderData } from 'react-router'
|
||||||
import { stripHtml } from 'string-strip-html'
|
import { stripHtml } from 'string-strip-html'
|
||||||
import { twMerge } from 'tailwind-merge'
|
import { twMerge } from 'tailwind-merge'
|
||||||
|
|
||||||
import type { TNewsResponse } from '~/apis/common/get-news'
|
import { ErrorAwait } from '~/components/error/await'
|
||||||
import { CarouselNextIcon } from '~/components/icons/carousel-next'
|
import { CarouselNextIcon } from '~/components/icons/carousel-next'
|
||||||
import { CarouselPreviousIcon } from '~/components/icons/carousel-previous'
|
import { CarouselPreviousIcon } from '~/components/icons/carousel-previous'
|
||||||
|
import { ImageSkeletonIcon } from '~/components/icons/image-skeleton'
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
import { useNewsContext } from '~/contexts/news'
|
import { useNewsContext } from '~/contexts/news'
|
||||||
import type { loader } from '~/routes/_news'
|
import type { loader } from '~/routes/_news'
|
||||||
|
import type { TNews } from '~/types/news'
|
||||||
import { getPremiumAttribute } from '~/utils/render'
|
import { getPremiumAttribute } from '~/utils/render'
|
||||||
|
|
||||||
import { Tags } from './tags'
|
import { Tags } from './tags'
|
||||||
|
|
||||||
type TNews = {
|
|
||||||
title: string
|
|
||||||
description: string
|
|
||||||
items: TNewsResponse[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export const CategorySection = (properties: TNews) => {
|
export const CategorySection = (properties: TNews) => {
|
||||||
const { setIsSuccessOpen } = useNewsContext()
|
const { setIsSuccessOpen } = useNewsContext()
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
||||||
@@ -47,23 +44,51 @@ export const CategorySection = (properties: TNews) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid sm:grid-cols-3 sm:gap-x-8">
|
<div className="grid sm:grid-cols-3 sm:gap-x-8">
|
||||||
{items.map(
|
<Suspense
|
||||||
|
fallback={Array.from({ length: 3 }).map((_, index) => (
|
||||||
|
<div
|
||||||
|
key={index}
|
||||||
|
className="grid gap-3 sm:gap-x-8"
|
||||||
|
>
|
||||||
|
<div className="flex h-[280px] w-full items-center justify-center rounded-md bg-gray-300 dark:bg-gray-700">
|
||||||
|
<ImageSkeletonIcon />
|
||||||
|
</div>
|
||||||
|
<div className="flex w-full flex-col gap-4">
|
||||||
|
<div className="flex flex-col gap-4">
|
||||||
|
<div className="h-6 w-full rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-6 w-[20%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col gap-2.5">
|
||||||
|
<div className="h-5 max-w-[80%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
<div className="h-5 max-w-[50%] rounded-full bg-gray-200 dark:bg-gray-700"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="h-[50px] w-full bg-gray-200 dark:bg-gray-700" />
|
||||||
|
<span className="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
>
|
||||||
|
<Await
|
||||||
|
resolve={items}
|
||||||
|
errorElement={<ErrorAwait />}
|
||||||
|
>
|
||||||
|
{(value) =>
|
||||||
|
value.data.map(
|
||||||
(
|
(
|
||||||
{ featured_image, title, content, tags, slug, is_premium },
|
{ featured_image, title, content, tags, slug, is_premium },
|
||||||
index,
|
index,
|
||||||
) => (
|
) => (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
className={twMerge('grid gap-3 sm:gap-x-8')}
|
className="grid gap-3 sm:gap-x-8"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
className={twMerge(
|
className="aspect-[174/100] w-full rounded-md object-cover sm:aspect-[5/4]"
|
||||||
'aspect-[174/100] w-full rounded-md object-cover sm:aspect-[5/4]',
|
|
||||||
)}
|
|
||||||
src={featured_image}
|
src={featured_image}
|
||||||
alt={title}
|
alt={title}
|
||||||
/>
|
/>
|
||||||
<div className={twMerge('flex flex-col justify-between gap-4')}>
|
<div className="flex flex-col justify-between gap-4">
|
||||||
<Tags
|
<Tags
|
||||||
tags={tags}
|
tags={tags}
|
||||||
is_premium={is_premium}
|
is_premium={is_premium}
|
||||||
@@ -96,7 +121,10 @@ export const CategorySection = (properties: TNews) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
)}
|
)
|
||||||
|
}
|
||||||
|
</Await>
|
||||||
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="my-5 mt-5 flex flex-row-reverse">
|
<div className="my-5 mt-5 flex flex-row-reverse">
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
ComboboxOptions,
|
ComboboxOptions,
|
||||||
ComboboxOption,
|
ComboboxOption,
|
||||||
} from '@headlessui/react'
|
} from '@headlessui/react'
|
||||||
import { CheckIcon, ChevronDownIcon } from '@heroicons/react/20/solid'
|
import { CheckIcon, ChevronDownIcon } from '@heroicons/react/24/solid'
|
||||||
import { useState, type ComponentProps, type ReactNode } from 'react'
|
import { useState, type ComponentProps, type ReactNode } from 'react'
|
||||||
import {
|
import {
|
||||||
get,
|
get,
|
||||||
@@ -96,7 +96,7 @@ export const Combobox = <TFormValues extends Record<string, unknown>>(
|
|||||||
displayValue={(option: TComboboxOption) => option?.name}
|
displayValue={(option: TComboboxOption) => option?.name}
|
||||||
onChange={(event) => setQuery(event.target.value)}
|
onChange={(event) => setQuery(event.target.value)}
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
'focus:inheriten h-[42px] w-full rounded-md border border-[#DFDFDF] p-2',
|
'focus:inheriten h-[42px] w-full rounded-md border border-[#DFDFDF] p-2 placeholder:text-inherit',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Field, Label, Input as HeadlessInput } from '@headlessui/react'
|
import { Field, Label, Input as HeadlessInput } from '@headlessui/react'
|
||||||
import { CloudArrowUpIcon } from '@heroicons/react/20/solid'
|
import { CloudArrowUpIcon } from '@heroicons/react/24/solid'
|
||||||
import { useEffect, type ComponentProps, type ReactNode } from 'react'
|
import { useEffect, type ComponentProps, type ReactNode } from 'react'
|
||||||
import { get, type FieldError, type RegisterOptions } from 'react-hook-form'
|
import { get, type FieldError, type RegisterOptions } from 'react-hook-form'
|
||||||
import { useRemixFormContext } from 'remix-hook-form'
|
import { useRemixFormContext } from 'remix-hook-form'
|
||||||
@@ -80,7 +80,7 @@ export const InputFile = (properties: TInputProperties) => {
|
|||||||
setIsUploadOpen(category)
|
setIsUploadOpen(category)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CloudArrowUpIcon className="h-4 w-4 text-gray-500/50" />
|
<CloudArrowUpIcon className="size-4 text-gray-500/50" />
|
||||||
</Button>
|
</Button>
|
||||||
</Field>
|
</Field>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export const Input = <TFormValues extends Record<string, unknown>>(
|
|||||||
>
|
>
|
||||||
<EyeIcon
|
<EyeIcon
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
'h-4 w-4',
|
'size-4',
|
||||||
inputType === 'password' ? 'text-gray-500/50' : 'text-gray-500',
|
inputType === 'password' ? 'text-gray-500/50' : 'text-gray-500',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type { TAuthorResponse } from '~/apis/common/get-news'
|
import type { TAuthorResponse } from '~/apis/common/get-news'
|
||||||
import { ProfileIcon } from '~/components/icons/profile'
|
|
||||||
import { formatDate } from '~/utils/formatter'
|
import { formatDate } from '~/utils/formatter'
|
||||||
|
|
||||||
type TDetailNewsAuthor = {
|
type TDetailNewsAuthor = {
|
||||||
@@ -11,15 +10,14 @@ type TDetailNewsAuthor = {
|
|||||||
export const NewsAuthor = ({ author, live_at, text }: TDetailNewsAuthor) => {
|
export const NewsAuthor = ({ author, live_at, text }: TDetailNewsAuthor) => {
|
||||||
return (
|
return (
|
||||||
<div className="mb-2 flex items-center gap-2 align-middle">
|
<div className="mb-2 flex items-center gap-2 align-middle">
|
||||||
{author?.profile_picture ? (
|
|
||||||
<img
|
<img
|
||||||
src={author?.profile_picture}
|
src={author?.profile_picture || '/images/profile-placeholder.svg'}
|
||||||
|
onError={(event) => {
|
||||||
|
event.currentTarget.src = '/images/profile-placeholder.svg'
|
||||||
|
}}
|
||||||
alt={author?.name}
|
alt={author?.name}
|
||||||
className="h-12 w-12 rounded-full bg-[#C4C4C4] object-cover"
|
className="size-12 rounded-full bg-[#C4C4C4] object-cover"
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
<ProfileIcon className="h-12 w-12 rounded-full bg-[#C4C4C4]" />
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h4 className="text-md">{author?.name}</h4>
|
<h4 className="text-md">{author?.name}</h4>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export const Newsletter = (property: NewsletterProperties) => {
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
variant="newsPrimary"
|
variant="primary"
|
||||||
size="block"
|
size="block"
|
||||||
>
|
>
|
||||||
Subscribe
|
Subscribe
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { LinkIcon } from '@heroicons/react/20/solid'
|
import { LinkIcon } from '@heroicons/react/24/solid'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import {
|
import {
|
||||||
FacebookShareButton,
|
FacebookShareButton,
|
||||||
@@ -39,7 +39,7 @@ export const SocialShareButtons = ({
|
|||||||
onClick={handleCopyLink}
|
onClick={handleCopyLink}
|
||||||
className="relative cursor-pointer"
|
className="relative cursor-pointer"
|
||||||
>
|
>
|
||||||
<LinkIcon className="h-8 w-8 rounded-full bg-[#F4F4F4] p-2 sm:h-10 sm:w-10" />
|
<LinkIcon className="size-8 rounded-full bg-[#F4F4F4] p-2 transition hover:bg-gray-200 hover:shadow active:bg-gray-300 sm:h-10 sm:w-10" />
|
||||||
{showPopup && (
|
{showPopup && (
|
||||||
<div className="absolute top-12 w-48 rounded-lg border-2 border-gray-400 bg-white p-2 shadow-lg">
|
<div className="absolute top-12 w-48 rounded-lg border-2 border-gray-400 bg-white p-2 shadow-lg">
|
||||||
Link berhasil disalin!
|
Link berhasil disalin!
|
||||||
@@ -51,28 +51,28 @@ export const SocialShareButtons = ({
|
|||||||
url={url}
|
url={url}
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
<FacebookIcon className="h-8 w-8 rounded-full bg-[#F4F4F4] p-2 sm:h-10 sm:w-10" />
|
<FacebookIcon className="size-8 rounded-full bg-[#F4F4F4] p-2 transition hover:bg-gray-200 hover:shadow active:bg-gray-300 sm:h-10 sm:w-10" />
|
||||||
</FacebookShareButton>
|
</FacebookShareButton>
|
||||||
|
|
||||||
<LinkedinShareButton
|
<LinkedinShareButton
|
||||||
url={url}
|
url={url}
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
<LinkedinIcon className="h-8 w-8 rounded-full bg-[#F4F4F4] p-2 sm:h-10 sm:w-10" />
|
<LinkedinIcon className="size-8 rounded-full bg-[#F4F4F4] p-2 transition hover:bg-gray-200 hover:shadow active:bg-gray-300 sm:h-10 sm:w-10" />
|
||||||
</LinkedinShareButton>
|
</LinkedinShareButton>
|
||||||
|
|
||||||
<TwitterShareButton
|
<TwitterShareButton
|
||||||
url={url}
|
url={url}
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
<XIcon className="h-8 w-8 rounded-full bg-[#F4F4F4] p-2 sm:h-10 sm:w-10" />
|
<XIcon className="size-8 rounded-full bg-[#F4F4F4] p-2 transition hover:bg-gray-200 hover:shadow active:bg-gray-300 sm:h-10 sm:w-10" />
|
||||||
</TwitterShareButton>
|
</TwitterShareButton>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={handleInstagramShare}
|
onClick={handleInstagramShare}
|
||||||
className="cursor-pointer"
|
className="cursor-pointer"
|
||||||
>
|
>
|
||||||
<InstagramIcon className="h-8 w-8 rounded-full bg-[#F4F4F4] p-2 sm:h-10 sm:w-10" />
|
<InstagramIcon className="size-8 rounded-full bg-[#F4F4F4] p-2 transition hover:bg-gray-200 hover:shadow active:bg-gray-300 sm:h-10 sm:w-10" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Field, Input, Label, Select } from '@headlessui/react'
|
import { Field, Input, Label, Select } from '@headlessui/react'
|
||||||
import { MagnifyingGlassIcon } from '@heroicons/react/20/solid'
|
import { MagnifyingGlassIcon } from '@heroicons/react/24/solid'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
|
||||||
interface SearchFilterProperties {
|
interface SearchFilterProperties {
|
||||||
@@ -42,7 +42,7 @@ export const TableSearchFilter: React.FC<SearchFilterProperties> = ({
|
|||||||
className="w-full rounded-lg bg-white p-2 pr-10 pl-4 shadow focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none"
|
className="w-full rounded-lg bg-white p-2 pr-10 pl-4 shadow focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none"
|
||||||
/>
|
/>
|
||||||
<div className="absolute inset-y-0 right-0 flex items-center pr-3">
|
<div className="absolute inset-y-0 right-0 flex items-center pr-3">
|
||||||
<MagnifyingGlassIcon className="h-5 w-5 text-[#363636]" />
|
<MagnifyingGlassIcon className="size-5 text-[#363636]" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ type AdminContextProperties = {
|
|||||||
setIsUploadOpen: Dispatch<SetStateAction<TUpload>>
|
setIsUploadOpen: Dispatch<SetStateAction<TUpload>>
|
||||||
uploadedFile?: string
|
uploadedFile?: string
|
||||||
setUploadedFile: Dispatch<SetStateAction<string | undefined>>
|
setUploadedFile: Dispatch<SetStateAction<string | undefined>>
|
||||||
|
editProfile: boolean
|
||||||
|
setEditProfile: Dispatch<SetStateAction<boolean>>
|
||||||
}
|
}
|
||||||
|
|
||||||
const AdminContext = createContext<AdminContextProperties | undefined>(
|
const AdminContext = createContext<AdminContextProperties | undefined>(
|
||||||
@@ -28,6 +30,7 @@ const AdminContext = createContext<AdminContextProperties | undefined>(
|
|||||||
export const AdminProvider = ({ children }: PropsWithChildren) => {
|
export const AdminProvider = ({ children }: PropsWithChildren) => {
|
||||||
const [isUploadOpen, setIsUploadOpen] = useState<TUpload>()
|
const [isUploadOpen, setIsUploadOpen] = useState<TUpload>()
|
||||||
const [uploadedFile, setUploadedFile] = useState<string | undefined>()
|
const [uploadedFile, setUploadedFile] = useState<string | undefined>()
|
||||||
|
const [editProfile, setEditProfile] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AdminContext.Provider
|
<AdminContext.Provider
|
||||||
@@ -36,6 +39,8 @@ export const AdminProvider = ({ children }: PropsWithChildren) => {
|
|||||||
setIsUploadOpen,
|
setIsUploadOpen,
|
||||||
uploadedFile,
|
uploadedFile,
|
||||||
setUploadedFile,
|
setUploadedFile,
|
||||||
|
editProfile,
|
||||||
|
setEditProfile,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { PropsWithChildren } from 'react'
|
import type { PropsWithChildren } from 'react'
|
||||||
|
|
||||||
|
import { DialogProfile } from './dialog-profile'
|
||||||
import { DialogUpload } from './dialog-upload'
|
import { DialogUpload } from './dialog-upload'
|
||||||
import { Navbar } from './navbar'
|
import { Navbar } from './navbar'
|
||||||
import { Sidebar } from './sidebar'
|
import { Sidebar } from './sidebar'
|
||||||
@@ -15,6 +16,7 @@ export const AdminDashboardLayout = (properties: PropsWithChildren) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DialogUpload />
|
<DialogUpload />
|
||||||
|
<DialogProfile />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogBackdrop,
|
||||||
|
DialogPanel,
|
||||||
|
DialogTitle,
|
||||||
|
} from '@headlessui/react'
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
|
import { useFetcher, useRouteLoaderData } from 'react-router'
|
||||||
|
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
|
||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { Button } from '~/components/ui/button'
|
||||||
|
import { Input } from '~/components/ui/input'
|
||||||
|
import { InputFile } from '~/components/ui/input-file'
|
||||||
|
import { useAdminContext } from '~/contexts/admin'
|
||||||
|
import type { loader } from '~/routes/_admin.lg-admin'
|
||||||
|
|
||||||
|
export const profileSchema = z.object({
|
||||||
|
name: z.string().min(1, 'Wajib diisi'),
|
||||||
|
email: z.string().email('Email tidak valid'),
|
||||||
|
profile_picture: z.string().url({
|
||||||
|
message: 'URL tidak valid',
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
export type TProfileSchema = z.infer<typeof profileSchema>
|
||||||
|
|
||||||
|
export const DialogProfile = () => {
|
||||||
|
const { editProfile, setEditProfile } = useAdminContext()
|
||||||
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_admin.lg-admin')
|
||||||
|
const { staffData } = loaderData || {}
|
||||||
|
const fetcher = useFetcher()
|
||||||
|
|
||||||
|
const formMethods = useRemixForm<TProfileSchema>({
|
||||||
|
mode: 'onSubmit',
|
||||||
|
fetcher,
|
||||||
|
resolver: zodResolver(profileSchema),
|
||||||
|
values: {
|
||||||
|
name: staffData?.name || '',
|
||||||
|
email: staffData?.email || '',
|
||||||
|
profile_picture: staffData?.profile_picture || '',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const { handleSubmit } = formMethods
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
|
toast.error(fetcher.data.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fetcher.data?.success) {
|
||||||
|
setEditProfile(false)
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [fetcher.data])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={editProfile}
|
||||||
|
onClose={() => {
|
||||||
|
if (fetcher.state === 'idle') {
|
||||||
|
setEditProfile(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="relative z-50"
|
||||||
|
transition
|
||||||
|
>
|
||||||
|
<DialogBackdrop
|
||||||
|
className="fixed inset-0 bg-black/50 duration-300 ease-out data-[closed]:opacity-0"
|
||||||
|
transition
|
||||||
|
/>
|
||||||
|
<div className="fixed inset-0 flex w-screen justify-center overflow-y-auto p-0 max-sm:bg-white sm:items-center sm:p-4">
|
||||||
|
<DialogPanel
|
||||||
|
transition
|
||||||
|
className="w-full max-w-lg space-y-6 rounded-lg bg-white p-8 duration-300 ease-out data-[closed]:scale-95 data-[closed]:opacity-0 sm:shadow-lg"
|
||||||
|
>
|
||||||
|
<DialogTitle
|
||||||
|
as="h3"
|
||||||
|
className="text-xl font-bold"
|
||||||
|
>
|
||||||
|
Update Profile
|
||||||
|
</DialogTitle>
|
||||||
|
<RemixFormProvider {...formMethods}>
|
||||||
|
<fetcher.Form
|
||||||
|
method="post"
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
className="space-y-4"
|
||||||
|
action="/actions/admin/profile"
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
name="name"
|
||||||
|
id="name"
|
||||||
|
label="Nama"
|
||||||
|
placeholder="Enter your name"
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
id="email"
|
||||||
|
label="Email"
|
||||||
|
placeholder="Contoh: legal@legalgo.id"
|
||||||
|
name="email"
|
||||||
|
/>
|
||||||
|
<InputFile
|
||||||
|
name="profile_picture"
|
||||||
|
id="profile_picture"
|
||||||
|
label="Gambar Profil"
|
||||||
|
placeholder="Unggah gambar profil Anda"
|
||||||
|
category="profile_picture"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
disabled={fetcher.state !== 'idle'}
|
||||||
|
isLoading={fetcher.state !== 'idle'}
|
||||||
|
type="submit"
|
||||||
|
className="w-full rounded-md py-2"
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</fetcher.Form>
|
||||||
|
</RemixFormProvider>
|
||||||
|
</DialogPanel>
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Dialog, DialogBackdrop, DialogPanel, Input } from '@headlessui/react'
|
import { Dialog, DialogBackdrop, DialogPanel, 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, type ChangeEvent } from 'react'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
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'
|
||||||
@@ -18,7 +19,6 @@ export type TUploadSchema = z.infer<typeof uploadSchema>
|
|||||||
export const DialogUpload = () => {
|
export const DialogUpload = () => {
|
||||||
const { isUploadOpen, setUploadedFile, setIsUploadOpen } = useAdminContext()
|
const { isUploadOpen, setUploadedFile, setIsUploadOpen } = useAdminContext()
|
||||||
const fetcher = useFetcher()
|
const fetcher = useFetcher()
|
||||||
const [error, setError] = useState<string>()
|
|
||||||
const maxFileSize = 10 * 1024 // 10MB
|
const maxFileSize = 10 * 1024 // 10MB
|
||||||
|
|
||||||
const formMethods = useRemixForm<TUploadSchema>({
|
const formMethods = useRemixForm<TUploadSchema>({
|
||||||
@@ -30,16 +30,15 @@ export const DialogUpload = () => {
|
|||||||
const { handleSubmit, register, setValue } = formMethods
|
const { handleSubmit, register, setValue } = formMethods
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
setError(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fetcher.data?.success) {
|
||||||
setUploadedFile(fetcher.data.uploadData.data.file_url)
|
setUploadedFile(fetcher.data.uploadData.data.file_url)
|
||||||
|
}
|
||||||
setError(undefined)
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher.data])
|
||||||
|
|
||||||
const handleChange = async function (event: ChangeEvent<HTMLInputElement>) {
|
const handleChange = async function (event: ChangeEvent<HTMLInputElement>) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@@ -58,12 +57,12 @@ export const DialogUpload = () => {
|
|||||||
const img = new Image()
|
const img = new Image()
|
||||||
|
|
||||||
if (!file.type.startsWith('image/')) {
|
if (!file.type.startsWith('image/')) {
|
||||||
setError('Please upload an image file.')
|
toast.error('Please upload an image file.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.size > maxFileSize * 1024) {
|
if (file.size > maxFileSize * 1024) {
|
||||||
setError(`File size is too big!`)
|
toast.error(`File size is too big!`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +99,7 @@ export const DialogUpload = () => {
|
|||||||
<div className="fixed inset-0 flex w-screen justify-center overflow-y-auto p-0 max-sm:bg-white sm:items-center sm:p-4">
|
<div className="fixed inset-0 flex w-screen justify-center overflow-y-auto p-0 max-sm:bg-white sm:items-center sm:p-4">
|
||||||
<DialogPanel
|
<DialogPanel
|
||||||
transition
|
transition
|
||||||
className="max-w-lg space-y-6 rounded-lg bg-white p-8 duration-300 ease-out data-[closed]:scale-95 data-[closed]:opacity-0 sm:shadow-lg"
|
className="w-full max-w-lg space-y-6 rounded-lg bg-white p-8 duration-300 ease-out data-[closed]:scale-95 data-[closed]:opacity-0 sm:shadow-lg"
|
||||||
>
|
>
|
||||||
<RemixFormProvider {...formMethods}>
|
<RemixFormProvider {...formMethods}>
|
||||||
<fetcher.Form
|
<fetcher.Form
|
||||||
@@ -110,9 +109,6 @@ export const DialogUpload = () => {
|
|||||||
action="/actions/admin/upload"
|
action="/actions/admin/upload"
|
||||||
encType="multipart/form-data"
|
encType="multipart/form-data"
|
||||||
>
|
>
|
||||||
{error && (
|
|
||||||
<div className="text-sm text-red-500 capitalize">{error}</div>
|
|
||||||
)}
|
|
||||||
<Input
|
<Input
|
||||||
type="file"
|
type="file"
|
||||||
id="input-file-upload"
|
id="input-file-upload"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
BriefcaseIcon,
|
||||||
ChartBarSquareIcon,
|
ChartBarSquareIcon,
|
||||||
ClipboardDocumentCheckIcon,
|
ClipboardDocumentCheckIcon,
|
||||||
DocumentCurrencyDollarIcon,
|
DocumentCurrencyDollarIcon,
|
||||||
@@ -7,15 +8,15 @@ import {
|
|||||||
PresentationChartLineIcon,
|
PresentationChartLineIcon,
|
||||||
TagIcon,
|
TagIcon,
|
||||||
UsersIcon,
|
UsersIcon,
|
||||||
} from '@heroicons/react/20/solid'
|
} from '@heroicons/react/24/solid'
|
||||||
import type { SVGProps } from 'react'
|
import type { ComponentType, SVGProps } from 'react'
|
||||||
|
|
||||||
type TMenu = {
|
type TMenu = {
|
||||||
group: string
|
group: string
|
||||||
items: {
|
items: {
|
||||||
title: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
icon: React.ComponentType<SVGProps<SVGSVGElement>>
|
icon: ComponentType<SVGProps<SVGSVGElement>>
|
||||||
}[]
|
}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,12 +25,12 @@ export const MENU: TMenu[] = [
|
|||||||
group: 'Menu',
|
group: 'Menu',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
title: 'Dashboard',
|
title: 'Dasbor',
|
||||||
url: '/lg-admin',
|
url: '/lg-admin',
|
||||||
icon: ChartBarSquareIcon,
|
icon: ChartBarSquareIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'User',
|
title: 'Pengguna',
|
||||||
url: '/lg-admin/users',
|
url: '/lg-admin/users',
|
||||||
icon: UsersIcon,
|
icon: UsersIcon,
|
||||||
},
|
},
|
||||||
@@ -39,12 +40,12 @@ export const MENU: TMenu[] = [
|
|||||||
icon: NewspaperIcon,
|
icon: NewspaperIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Banner Iklan',
|
title: 'Spanduk Iklan',
|
||||||
url: '/lg-admin/advertisements',
|
url: '/lg-admin/advertisements',
|
||||||
icon: MegaphoneIcon,
|
icon: MegaphoneIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Subscription',
|
title: 'Pelanggan',
|
||||||
url: '/lg-admin/subscriptions',
|
url: '/lg-admin/subscriptions',
|
||||||
icon: PresentationChartLineIcon,
|
icon: PresentationChartLineIcon,
|
||||||
},
|
},
|
||||||
@@ -64,10 +65,15 @@ export const MENU: TMenu[] = [
|
|||||||
icon: TagIcon,
|
icon: TagIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Subscribe Plan',
|
title: 'Paket Berlangganan',
|
||||||
url: '/lg-admin/subscribe-plan',
|
url: '/lg-admin/subscribe-plan',
|
||||||
icon: DocumentCurrencyDollarIcon,
|
icon: DocumentCurrencyDollarIcon,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Staf',
|
||||||
|
url: '/lg-admin/staffs',
|
||||||
|
icon: BriefcaseIcon,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/react'
|
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/react'
|
||||||
|
import {
|
||||||
|
ArrowRightStartOnRectangleIcon,
|
||||||
|
UserIcon,
|
||||||
|
} from '@heroicons/react/24/outline'
|
||||||
|
import { ChevronDownIcon } from '@heroicons/react/24/solid'
|
||||||
import { Link, useFetcher, useRouteLoaderData } from 'react-router'
|
import { Link, useFetcher, useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
import { ChevronIcon } from '~/components/icons/chevron'
|
|
||||||
import { ProfileIcon } from '~/components/icons/profile'
|
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
import { APP } from '~/configs/meta'
|
import { APP } from '~/configs/meta'
|
||||||
|
import { useAdminContext } from '~/contexts/admin'
|
||||||
import type { loader } from '~/routes/_admin.lg-admin'
|
import type { loader } from '~/routes/_admin.lg-admin'
|
||||||
|
|
||||||
export const Navbar = () => {
|
export const Navbar = () => {
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_admin.lg-admin')
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_admin.lg-admin')
|
||||||
const { staffData } = loaderData || {}
|
const { staffData } = loaderData || {}
|
||||||
const fetcher = useFetcher()
|
const fetcher = useFetcher()
|
||||||
|
const { setEditProfile } = useAdminContext()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-20 items-center justify-between border-b border-[#ECECEC] bg-white px-10 py-5">
|
<div className="flex h-20 items-center justify-between border-b border-[#ECECEC] bg-white px-10 py-5">
|
||||||
@@ -28,25 +33,40 @@ export const Navbar = () => {
|
|||||||
<Popover className="relative">
|
<Popover className="relative">
|
||||||
<PopoverButton className="flex w-3xs cursor-pointer items-center justify-between rounded-xl p-2 ring-1 ring-[#707FDD]/10 hover:shadow focus:outline-none">
|
<PopoverButton className="flex w-3xs cursor-pointer items-center justify-between rounded-xl p-2 ring-1 ring-[#707FDD]/10 hover:shadow focus:outline-none">
|
||||||
<div className="flex items-center space-x-3">
|
<div className="flex items-center space-x-3">
|
||||||
{staffData?.profile_picture ? (
|
|
||||||
<img
|
<img
|
||||||
src={staffData?.profile_picture}
|
src={
|
||||||
|
staffData?.profile_picture ||
|
||||||
|
'/images/profile-placeholder.svg'
|
||||||
|
}
|
||||||
|
onError={(event) => {
|
||||||
|
event.currentTarget.src = '/images/profile-placeholder.svg'
|
||||||
|
}}
|
||||||
alt={staffData?.name}
|
alt={staffData?.name}
|
||||||
className="h-8 w-8 rounded-full bg-[#C4C4C4] object-cover"
|
className="size-8 rounded-full bg-[#C4C4C4] object-cover"
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
<ProfileIcon className="h-8 w-8 rounded-full bg-[#C4C4C4]" />
|
|
||||||
)}
|
|
||||||
|
|
||||||
<span className="text-sm">{staffData?.name}</span>
|
<span className="text-sm">{staffData?.name}</span>
|
||||||
</div>
|
</div>
|
||||||
<ChevronIcon className="opacity-50" />
|
<ChevronDownIcon className="size-4 opacity-50" />
|
||||||
</PopoverButton>
|
</PopoverButton>
|
||||||
<PopoverPanel
|
<PopoverPanel
|
||||||
anchor={{ to: 'bottom', gap: '8px' }}
|
anchor={{ to: 'bottom', gap: '8px' }}
|
||||||
transition
|
transition
|
||||||
className="flex w-3xs flex-col rounded-xl border border-[#ECECEC] bg-white p-3 transition duration-200 ease-in-out data-[closed]:-translate-y-1 data-[closed]:opacity-0"
|
className="flex w-3xs flex-col divide-y divide-black/5 rounded-xl border border-[#ECECEC] bg-white transition duration-200 ease-in-out data-[closed]:-translate-y-1 data-[closed]:opacity-0"
|
||||||
>
|
>
|
||||||
|
<div className="p-2">
|
||||||
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
className="w-full justify-start rounded p-1 px-3 text-base font-bold"
|
||||||
|
onClick={() => {
|
||||||
|
setEditProfile(true)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<UserIcon className="size-5" />
|
||||||
|
<span>Profile</span>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className="p-2">
|
||||||
<fetcher.Form
|
<fetcher.Form
|
||||||
method="POST"
|
method="POST"
|
||||||
action="/actions/admin/logout"
|
action="/actions/admin/logout"
|
||||||
@@ -56,11 +76,14 @@ export const Navbar = () => {
|
|||||||
disabled={fetcher.state !== 'idle'}
|
disabled={fetcher.state !== 'idle'}
|
||||||
isLoading={fetcher.state !== 'idle'}
|
isLoading={fetcher.state !== 'idle'}
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-full rounded p-1"
|
className="w-full justify-start rounded p-1 px-3 text-base font-bold"
|
||||||
|
variant="secondary"
|
||||||
|
icon={<ArrowRightStartOnRectangleIcon className="size-5" />}
|
||||||
>
|
>
|
||||||
Logout
|
<span>Logout</span>
|
||||||
</Button>
|
</Button>
|
||||||
</fetcher.Form>
|
</fetcher.Form>
|
||||||
|
</div>
|
||||||
</PopoverPanel>
|
</PopoverPanel>
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const Sidebar = () => {
|
|||||||
key={`${group}-${title}`}
|
key={`${group}-${title}`}
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
path === url ? 'bg-[#707FDD]/10 font-bold' : '',
|
path === url ? 'bg-[#707FDD]/10 font-bold' : '',
|
||||||
'group/menu flex h-[42px] w-[200px] items-center gap-x-3 rounded-md px-5 transition hover:bg-[#707FDD]/10 active:bg-[#707FDD]/20',
|
'group/menu flex h-[42px] w-[240px] items-center gap-x-3 rounded-md px-5 transition hover:bg-[#707FDD]/10 active:bg-[#707FDD]/20',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
|
|||||||
+19
-11
@@ -1,13 +1,20 @@
|
|||||||
|
import { Button } from '@headlessui/react'
|
||||||
import Autoplay from 'embla-carousel-autoplay'
|
import Autoplay from 'embla-carousel-autoplay'
|
||||||
import useEmblaCarousel from 'embla-carousel-react'
|
import useEmblaCarousel from 'embla-carousel-react'
|
||||||
import { Link, useRouteLoaderData } from 'react-router'
|
import { useFetcher, useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
import type { loader } from '~/routes/_news'
|
import type { loader } from '~/routes/_news'
|
||||||
|
|
||||||
export const Banner = () => {
|
export const Banner = () => {
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
||||||
const { adsData } = loaderData || {}
|
const { adsData } = loaderData || {}
|
||||||
const [emblaReference] = useEmblaCarousel({ loop: true }, [Autoplay()])
|
const [emblaReference] = useEmblaCarousel({ loop: true }, [
|
||||||
|
Autoplay({
|
||||||
|
stopOnInteraction: false,
|
||||||
|
stopOnMouseEnter: true,
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
const fetcher = useFetcher()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
@@ -17,24 +24,25 @@ export const Banner = () => {
|
|||||||
ref={emblaReference}
|
ref={emblaReference}
|
||||||
>
|
>
|
||||||
<div className="embla__container flex">
|
<div className="embla__container flex">
|
||||||
{adsData?.map(({ image_url: urlImage, url: link, id }, index) => (
|
{adsData?.map(({ image_url: urlImage, url, id }, index) => (
|
||||||
<div
|
<fetcher.Form
|
||||||
|
method="POST"
|
||||||
|
action={`/actions/log/ads/${id}`}
|
||||||
key={index}
|
key={index}
|
||||||
className="embla__slide max-h-[100px] min-h-[65px] w-full min-w-0 flex-none"
|
className="embla__slide max-h-[100px] min-h-[65px] w-full min-w-0 flex-none"
|
||||||
>
|
>
|
||||||
<Link
|
<Button
|
||||||
to={link}
|
className="h-full w-full cursor-pointer py-2"
|
||||||
className="mt-2 h-full py-2"
|
type="submit"
|
||||||
target="_blank"
|
onClick={() => window.open(url, '_blank')}
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={urlImage}
|
src={urlImage}
|
||||||
alt={id}
|
alt={id}
|
||||||
className="h-[70px] w-[100%] object-contain object-center sm:h-full"
|
className="h-[70px] w-[100%] object-contain object-center sm:h-full"
|
||||||
/>
|
/>
|
||||||
</Link>
|
</Button>
|
||||||
</div>
|
</fetcher.Form>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,34 +1,22 @@
|
|||||||
import { type PropsWithChildren } from 'react'
|
import { type PropsWithChildren } from 'react'
|
||||||
import { Toaster } from 'react-hot-toast'
|
import { Toaster } from 'react-hot-toast'
|
||||||
|
|
||||||
import { DialogNews } from '~/components/dialog/news'
|
|
||||||
import { DialogSuccess } from '~/components/dialog/success'
|
import { DialogSuccess } from '~/components/dialog/success'
|
||||||
import { useNewsContext } from '~/contexts/news'
|
import { useNewsContext } from '~/contexts/news'
|
||||||
import { Banner } from '~/layouts/news/banner'
|
import { Banner } from '~/layouts/news/banner'
|
||||||
import { FormForgotPassword } from '~/layouts/news/form-forgot-password'
|
import { DialogForgotPassword } from '~/layouts/news/dialog-forgot-password'
|
||||||
import { FormLogin } from '~/layouts/news/form-login'
|
import { DialogLogin } from '~/layouts/news/dialog-login'
|
||||||
import { FormRegister } from '~/layouts/news/form-register'
|
|
||||||
|
|
||||||
|
import { DialogRegister } from './dialog-register'
|
||||||
|
import { DialogSubscribePlan } from './dialog-subscribe-plan'
|
||||||
import { FooterLinks } from './footer-links'
|
import { FooterLinks } from './footer-links'
|
||||||
import { FooterNewsletter } from './footer-newsletter'
|
import { FooterNewsletter } from './footer-newsletter'
|
||||||
import { FormSubscribePlan } from './form-subscribe-plan'
|
|
||||||
import { HeaderMenu } from './header-menu'
|
import { HeaderMenu } from './header-menu'
|
||||||
import { HeaderTop } from './header-top'
|
import { HeaderTop } from './header-top'
|
||||||
|
|
||||||
export const NewsDefaultLayout = (properties: PropsWithChildren) => {
|
export const NewsDefaultLayout = (properties: PropsWithChildren) => {
|
||||||
const { children } = properties
|
const { children } = properties
|
||||||
const {
|
const { isSuccessOpen, setIsSuccessOpen } = useNewsContext()
|
||||||
isLoginOpen,
|
|
||||||
setIsLoginOpen,
|
|
||||||
isRegisterOpen,
|
|
||||||
setIsRegisterOpen,
|
|
||||||
isForgetOpen,
|
|
||||||
setIsForgetOpen,
|
|
||||||
isSuccessOpen,
|
|
||||||
setIsSuccessOpen,
|
|
||||||
isSubscribeOpen,
|
|
||||||
setIsSubscribeOpen,
|
|
||||||
} = useNewsContext()
|
|
||||||
return (
|
return (
|
||||||
<main className="relative min-h-dvh bg-[#ECECEC]">
|
<main className="relative min-h-dvh bg-[#ECECEC]">
|
||||||
<header>
|
<header>
|
||||||
@@ -46,39 +34,10 @@ export const NewsDefaultLayout = (properties: PropsWithChildren) => {
|
|||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<Toaster />
|
<Toaster />
|
||||||
|
<DialogLogin />
|
||||||
<DialogNews
|
<DialogRegister />
|
||||||
isOpen={isLoginOpen}
|
<DialogForgotPassword />
|
||||||
onClose={() => setIsLoginOpen(false)}
|
<DialogSubscribePlan />
|
||||||
description="Selamat Datang, silakan daftarkan akun Anda untuk melanjutkan!"
|
|
||||||
>
|
|
||||||
<FormLogin />
|
|
||||||
</DialogNews>
|
|
||||||
|
|
||||||
<DialogNews
|
|
||||||
isOpen={isRegisterOpen}
|
|
||||||
onClose={() => setIsRegisterOpen(false)}
|
|
||||||
description="Selamat Datang, silakan isi keterangan akun Anda untuk melanjutkan!"
|
|
||||||
>
|
|
||||||
<FormRegister />
|
|
||||||
</DialogNews>
|
|
||||||
|
|
||||||
<DialogNews
|
|
||||||
isOpen={isForgetOpen}
|
|
||||||
onClose={() => setIsForgetOpen(false)}
|
|
||||||
description="Selamat Datang, silakan isi keterangan akun Anda untuk melanjutkan!"
|
|
||||||
>
|
|
||||||
<FormForgotPassword />
|
|
||||||
</DialogNews>
|
|
||||||
|
|
||||||
<DialogNews
|
|
||||||
isOpen={isSubscribeOpen}
|
|
||||||
onClose={() => setIsSubscribeOpen(false)}
|
|
||||||
description="Selamat Datang, silakan Pilih Subscribe Plan Anda untuk melanjutkan!"
|
|
||||||
>
|
|
||||||
<FormSubscribePlan />
|
|
||||||
</DialogNews>
|
|
||||||
|
|
||||||
<DialogSuccess
|
<DialogSuccess
|
||||||
isOpen={isSuccessOpen}
|
isOpen={isSuccessOpen}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { useFetcher } from 'react-router'
|
||||||
|
|
||||||
|
import { DialogNews } from '~/components/dialog/news'
|
||||||
|
import { Button } from '~/components/ui/button'
|
||||||
|
import { useNewsContext } from '~/contexts/news'
|
||||||
|
|
||||||
|
export const DialogForgotPassword = () => {
|
||||||
|
const { isForgetOpen, setIsForgetOpen } = useNewsContext()
|
||||||
|
const fetcher = useFetcher()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DialogNews
|
||||||
|
isOpen={isForgetOpen}
|
||||||
|
onClose={() => {
|
||||||
|
if (fetcher.state === 'idle') {
|
||||||
|
setIsForgetOpen(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
description="Selamat Datang, silakan isi keterangan akun Anda untuk melanjutkan!"
|
||||||
|
>
|
||||||
|
<div className="flex flex-col items-center justify-center">
|
||||||
|
<div className="w-full max-w-md">
|
||||||
|
<form>
|
||||||
|
{/* Input Email / No Telepon */}
|
||||||
|
<div className="mb-4">
|
||||||
|
<label
|
||||||
|
htmlFor="email"
|
||||||
|
className="mb-1 block text-gray-700"
|
||||||
|
>
|
||||||
|
Email/No. Telepon
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Contoh: legal@legalgo.id"
|
||||||
|
className="focus:inheriten w-full rounded-md border border-[#DFDFDF] p-2"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Tombol Masuk */}
|
||||||
|
<Button className="mt-5 w-full rounded-md py-2">
|
||||||
|
Reset Password
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DialogNews>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
|
import { useFetcher } from 'react-router'
|
||||||
|
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
|
||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { DialogNews } from '~/components/dialog/news'
|
||||||
|
import { Button } from '~/components/ui/button'
|
||||||
|
import { Input } from '~/components/ui/input'
|
||||||
|
import { useNewsContext } from '~/contexts/news'
|
||||||
|
|
||||||
|
export const loginSchema = z.object({
|
||||||
|
email: z.string().email('Email tidak valid'),
|
||||||
|
password: z.string().min(6, 'Minimal 6 karakter'),
|
||||||
|
})
|
||||||
|
|
||||||
|
export type TLoginSchema = z.infer<typeof loginSchema>
|
||||||
|
|
||||||
|
export const DialogLogin = () => {
|
||||||
|
const {
|
||||||
|
setIsRegisterOpen,
|
||||||
|
setIsLoginOpen,
|
||||||
|
setIsForgetOpen,
|
||||||
|
setIsSubscribeOpen,
|
||||||
|
isLoginOpen,
|
||||||
|
} = useNewsContext()
|
||||||
|
const fetcher = useFetcher()
|
||||||
|
|
||||||
|
const formMethods = useRemixForm<TLoginSchema>({
|
||||||
|
mode: 'onSubmit',
|
||||||
|
fetcher,
|
||||||
|
resolver: zodResolver(loginSchema),
|
||||||
|
})
|
||||||
|
|
||||||
|
const { handleSubmit } = formMethods
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
|
toast.error(fetcher.data.message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fetcher.data?.success) {
|
||||||
|
setIsLoginOpen(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fetcher.data?.user.subscribe?.subscribe_plan?.code === 'basic') {
|
||||||
|
setIsSubscribeOpen(true)
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [fetcher.data])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DialogNews
|
||||||
|
isOpen={isLoginOpen}
|
||||||
|
onClose={() => {
|
||||||
|
if (fetcher.state === 'idle') {
|
||||||
|
setIsLoginOpen(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
description="Selamat Datang, silakan daftarkan akun Anda untuk melanjutkan!"
|
||||||
|
>
|
||||||
|
<div className="flex items-center justify-center">
|
||||||
|
<div className="w-full max-w-md">
|
||||||
|
<RemixFormProvider {...formMethods}>
|
||||||
|
<fetcher.Form
|
||||||
|
method="post"
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
className="space-y-4"
|
||||||
|
action="/actions/login"
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
id="email"
|
||||||
|
label="Email"
|
||||||
|
placeholder="Contoh: legal@legalgo.id"
|
||||||
|
name="email"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
id="password"
|
||||||
|
label="Kata Sandi"
|
||||||
|
placeholder="Masukkan Kata Sandi"
|
||||||
|
name="password"
|
||||||
|
type="password"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between text-sm">
|
||||||
|
<span className="text-gray-600">Lupa Kata Sandi?</span>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setIsLoginOpen(false)
|
||||||
|
setIsForgetOpen(true)
|
||||||
|
}}
|
||||||
|
variant="link"
|
||||||
|
size="fit"
|
||||||
|
>
|
||||||
|
Reset Kata Sandi
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
isLoading={fetcher.state !== 'idle'}
|
||||||
|
disabled={fetcher.state !== 'idle'}
|
||||||
|
type="submit"
|
||||||
|
className="w-full rounded-md py-2"
|
||||||
|
>
|
||||||
|
Masuk
|
||||||
|
</Button>
|
||||||
|
</fetcher.Form>
|
||||||
|
</RemixFormProvider>
|
||||||
|
|
||||||
|
{/* Link Daftar */}
|
||||||
|
<div className="mt-4 text-center text-sm">
|
||||||
|
Belum punya akun?{' '}
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setIsLoginOpen(false)
|
||||||
|
setIsRegisterOpen(true)
|
||||||
|
}}
|
||||||
|
variant="link"
|
||||||
|
size="fit"
|
||||||
|
>
|
||||||
|
Daftar Disini
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DialogNews>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
import { DevTool } from '@hookform/devtools'
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
|
import { useFetcher, useRouteLoaderData } from 'react-router'
|
||||||
|
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
|
||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { DialogNews } from '~/components/dialog/news'
|
||||||
|
import { Button } from '~/components/ui/button'
|
||||||
|
import { Combobox } from '~/components/ui/combobox'
|
||||||
|
import { Input } from '~/components/ui/input'
|
||||||
|
import { useNewsContext } from '~/contexts/news'
|
||||||
|
import type { loader } from '~/routes/_news'
|
||||||
|
|
||||||
|
export const registerSchema = z
|
||||||
|
.object({
|
||||||
|
email: z.string().email('Email tidak valid'),
|
||||||
|
password: z.string().min(6, 'Minimal 6 karakter'),
|
||||||
|
rePassword: z.string().min(6, 'Minimal 6 karakter'),
|
||||||
|
phone: z.string().min(10, 'No telepon tidak valid'),
|
||||||
|
subscribe_plan: z
|
||||||
|
.object({
|
||||||
|
id: z.string(),
|
||||||
|
code: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
})
|
||||||
|
.optional()
|
||||||
|
.nullable()
|
||||||
|
.refine((data) => !!data, {
|
||||||
|
message: 'Pilih paket berlangganan',
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.refine((field) => field.password === field.rePassword, {
|
||||||
|
message: 'Kata sandi tidak sama',
|
||||||
|
path: ['rePassword'],
|
||||||
|
})
|
||||||
|
|
||||||
|
export type TRegisterSchema = z.infer<typeof registerSchema>
|
||||||
|
|
||||||
|
export const DialogRegister = () => {
|
||||||
|
const {
|
||||||
|
setIsLoginOpen,
|
||||||
|
setIsRegisterOpen,
|
||||||
|
setIsSuccessOpen,
|
||||||
|
isRegisterOpen,
|
||||||
|
} = useNewsContext()
|
||||||
|
const fetcher = useFetcher()
|
||||||
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
||||||
|
const { subscribePlanData: subscribePlan } = loaderData || {}
|
||||||
|
|
||||||
|
const formMethods = useRemixForm<TRegisterSchema>({
|
||||||
|
mode: 'onSubmit',
|
||||||
|
fetcher,
|
||||||
|
resolver: zodResolver(registerSchema),
|
||||||
|
})
|
||||||
|
|
||||||
|
const { handleSubmit, control } = formMethods
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
|
toast.error(fetcher.data.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fetcher.data?.success) {
|
||||||
|
setIsRegisterOpen(false)
|
||||||
|
setIsSuccessOpen('register')
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [fetcher.data])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DialogNews
|
||||||
|
isOpen={isRegisterOpen}
|
||||||
|
onClose={() => {
|
||||||
|
if (fetcher.state === 'idle') {
|
||||||
|
setIsRegisterOpen(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
description="Selamat Datang, silakan isi keterangan akun Anda untuk melanjutkan!"
|
||||||
|
>
|
||||||
|
<div className="flex flex-col items-center justify-center">
|
||||||
|
<div className="w-full max-w-md">
|
||||||
|
<RemixFormProvider {...formMethods}>
|
||||||
|
<fetcher.Form
|
||||||
|
method="post"
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
className="space-y-4"
|
||||||
|
action="/actions/register"
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
id="email"
|
||||||
|
label="Email"
|
||||||
|
placeholder="Contoh: legal@legalgo.id"
|
||||||
|
name="email"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
id="password"
|
||||||
|
label="Kata Sandi"
|
||||||
|
placeholder="Masukkan Kata Sandi"
|
||||||
|
name="password"
|
||||||
|
type="password"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
id="re-password"
|
||||||
|
label="Ulangi Kata Sandi"
|
||||||
|
placeholder="Masukkan Kata Sandi"
|
||||||
|
name="rePassword"
|
||||||
|
type="password"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
id="phone"
|
||||||
|
label="No. Telepon"
|
||||||
|
placeholder="Masukkan No. Telepon"
|
||||||
|
name="phone"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Combobox
|
||||||
|
id="subscribe_plan"
|
||||||
|
name="subscribe_plan"
|
||||||
|
label="Paket Berlangganan"
|
||||||
|
placeholder="Pilih Paket Berlangganan"
|
||||||
|
options={subscribePlan}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
isLoading={fetcher.state !== 'idle'}
|
||||||
|
disabled={fetcher.state !== 'idle'}
|
||||||
|
type="submit"
|
||||||
|
className="w-full rounded-md py-2"
|
||||||
|
>
|
||||||
|
Daftar
|
||||||
|
</Button>
|
||||||
|
</fetcher.Form>
|
||||||
|
</RemixFormProvider>
|
||||||
|
|
||||||
|
{/* Link Login */}
|
||||||
|
<div className="mt-4 text-center text-sm">
|
||||||
|
Sudah punya akun?{' '}
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setIsLoginOpen(true)
|
||||||
|
setIsRegisterOpen(false)
|
||||||
|
}}
|
||||||
|
variant="link"
|
||||||
|
size="fit"
|
||||||
|
>
|
||||||
|
Masuk Disini
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<DevTool control={control} />
|
||||||
|
</div>
|
||||||
|
</DialogNews>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
|
import { useFetcher, useRouteLoaderData } from 'react-router'
|
||||||
|
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
|
||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { DialogNews } from '~/components/dialog/news'
|
||||||
|
import { Button } from '~/components/ui/button'
|
||||||
|
import { Combobox } from '~/components/ui/combobox'
|
||||||
|
import { useNewsContext } from '~/contexts/news'
|
||||||
|
import type { loader } from '~/routes/_news'
|
||||||
|
|
||||||
|
export const subscribeSchema = z.object({
|
||||||
|
subscribe_plan: z
|
||||||
|
.object({
|
||||||
|
id: z.string(),
|
||||||
|
code: z.string(),
|
||||||
|
name: z.string(),
|
||||||
|
})
|
||||||
|
.optional()
|
||||||
|
.nullable()
|
||||||
|
.refine((data) => !!data, {
|
||||||
|
message: 'Silakan pilih paket berlangganan',
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
export type TSubscribeSchema = z.infer<typeof subscribeSchema>
|
||||||
|
|
||||||
|
export const DialogSubscribePlan = () => {
|
||||||
|
const { setIsSubscribeOpen, setIsSuccessOpen, isSubscribeOpen } =
|
||||||
|
useNewsContext()
|
||||||
|
const fetcher = useFetcher()
|
||||||
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
||||||
|
const { subscribePlanData: subscribePlan } = loaderData || {}
|
||||||
|
|
||||||
|
const formMethods = useRemixForm<TSubscribeSchema>({
|
||||||
|
mode: 'onSubmit',
|
||||||
|
fetcher,
|
||||||
|
resolver: zodResolver(subscribeSchema),
|
||||||
|
})
|
||||||
|
|
||||||
|
const { handleSubmit } = formMethods
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
|
toast.error(fetcher.data.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fetcher.data?.success) {
|
||||||
|
setIsSubscribeOpen(false)
|
||||||
|
setIsSuccessOpen('payment')
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [fetcher.data])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DialogNews
|
||||||
|
isOpen={isSubscribeOpen}
|
||||||
|
onClose={() => {
|
||||||
|
if (fetcher.state === 'idle') {
|
||||||
|
setIsSubscribeOpen(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
description="Selamat Datang, silakan Pilih Paket Berlangganan Anda untuk melanjutkan!"
|
||||||
|
>
|
||||||
|
<div className="flex flex-col items-center justify-center">
|
||||||
|
<RemixFormProvider {...formMethods}>
|
||||||
|
<fetcher.Form
|
||||||
|
method="post"
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
className="w-full max-w-md"
|
||||||
|
action="/actions/subscribe"
|
||||||
|
>
|
||||||
|
<Combobox
|
||||||
|
id="subscribe_plan"
|
||||||
|
name="subscribe_plan"
|
||||||
|
label="Paket Berlangganan"
|
||||||
|
placeholder="Pilih Paket Berlangganan"
|
||||||
|
options={subscribePlan}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
isLoading={fetcher.state !== 'idle'}
|
||||||
|
disabled={fetcher.state !== 'idle'}
|
||||||
|
type="submit"
|
||||||
|
className="mt-5 w-full rounded-md py-2"
|
||||||
|
>
|
||||||
|
Lanjutkan
|
||||||
|
</Button>
|
||||||
|
</fetcher.Form>
|
||||||
|
</RemixFormProvider>
|
||||||
|
</div>
|
||||||
|
</DialogNews>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -34,7 +34,7 @@ export const FooterNewsletter = () => {
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
variant="newsPrimaryOutline"
|
variant="primaryOutline"
|
||||||
size="block"
|
size="block"
|
||||||
>
|
>
|
||||||
Subscribe
|
Subscribe
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import { Button } from '~/components/ui/button'
|
|
||||||
|
|
||||||
export const FormForgotPassword = () => {
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center justify-center">
|
|
||||||
<div className="w-full max-w-md">
|
|
||||||
<form>
|
|
||||||
{/* Input Email / No Telepon */}
|
|
||||||
<div className="mb-4">
|
|
||||||
<label
|
|
||||||
htmlFor="email"
|
|
||||||
className="mb-1 block text-gray-700"
|
|
||||||
>
|
|
||||||
Email/No. Telepon
|
|
||||||
</label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="Contoh: legal@legalgo.id"
|
|
||||||
className="focus:inheriten w-full rounded-md border border-[#DFDFDF] p-2"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Tombol Masuk */}
|
|
||||||
<Button className="mt-5 w-full rounded-md py-2">
|
|
||||||
Reset Password
|
|
||||||
</Button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
import { zodResolver } from '@hookform/resolvers/zod'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { useFetcher } from 'react-router'
|
|
||||||
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
|
|
||||||
import { z } from 'zod'
|
|
||||||
|
|
||||||
import { Button } from '~/components/ui/button'
|
|
||||||
import { Input } from '~/components/ui/input'
|
|
||||||
import { useNewsContext } from '~/contexts/news'
|
|
||||||
|
|
||||||
export const loginSchema = z.object({
|
|
||||||
email: z.string().email('Email tidak valid'),
|
|
||||||
password: z.string().min(6, 'Kata sandi minimal 6 karakter'),
|
|
||||||
})
|
|
||||||
|
|
||||||
export type TLoginSchema = z.infer<typeof loginSchema>
|
|
||||||
|
|
||||||
export const FormLogin = () => {
|
|
||||||
const {
|
|
||||||
setIsRegisterOpen,
|
|
||||||
setIsLoginOpen,
|
|
||||||
setIsForgetOpen,
|
|
||||||
setIsSubscribeOpen,
|
|
||||||
} = useNewsContext()
|
|
||||||
const fetcher = useFetcher()
|
|
||||||
const [error, setError] = useState<string>()
|
|
||||||
|
|
||||||
const formMethods = useRemixForm<TLoginSchema>({
|
|
||||||
mode: 'onSubmit',
|
|
||||||
fetcher,
|
|
||||||
resolver: zodResolver(loginSchema),
|
|
||||||
})
|
|
||||||
|
|
||||||
const { handleSubmit } = formMethods
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!fetcher.data?.success) {
|
|
||||||
setError(fetcher.data?.message)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setError(undefined)
|
|
||||||
setIsLoginOpen(false)
|
|
||||||
|
|
||||||
if (fetcher.data?.user.subscribe_plan_code === 'basic') {
|
|
||||||
setIsSubscribeOpen(true)
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [fetcher])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-center">
|
|
||||||
<div className="w-full max-w-md">
|
|
||||||
<RemixFormProvider {...formMethods}>
|
|
||||||
<fetcher.Form
|
|
||||||
method="post"
|
|
||||||
onSubmit={handleSubmit}
|
|
||||||
className="space-y-4"
|
|
||||||
action="/actions/login"
|
|
||||||
>
|
|
||||||
<Input
|
|
||||||
id="email"
|
|
||||||
label="Email"
|
|
||||||
placeholder="Contoh: legal@legalgo.id"
|
|
||||||
name="email"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Input
|
|
||||||
id="password"
|
|
||||||
label="Kata Sandi"
|
|
||||||
placeholder="Masukkan Kata Sandi"
|
|
||||||
name="password"
|
|
||||||
type="password"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{error && (
|
|
||||||
<div className="text-sm text-red-500 capitalize">{error}</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="flex items-center justify-between text-sm">
|
|
||||||
<span className="text-gray-600">Lupa Kata Sandi?</span>
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
setIsLoginOpen(false)
|
|
||||||
setIsForgetOpen(true)
|
|
||||||
}}
|
|
||||||
variant="link"
|
|
||||||
size="fit"
|
|
||||||
>
|
|
||||||
Reset Kata Sandi
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
isLoading={fetcher.state !== 'idle'}
|
|
||||||
disabled={fetcher.state !== 'idle'}
|
|
||||||
type="submit"
|
|
||||||
className="w-full rounded-md py-2"
|
|
||||||
>
|
|
||||||
Masuk
|
|
||||||
</Button>
|
|
||||||
</fetcher.Form>
|
|
||||||
</RemixFormProvider>
|
|
||||||
|
|
||||||
{/* Link Daftar */}
|
|
||||||
<div className="mt-4 text-center text-sm">
|
|
||||||
Belum punya akun?{' '}
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
setIsLoginOpen(false)
|
|
||||||
setIsRegisterOpen(true)
|
|
||||||
}}
|
|
||||||
variant="link"
|
|
||||||
size="fit"
|
|
||||||
>
|
|
||||||
Daftar Disini
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
import { DevTool } from '@hookform/devtools'
|
|
||||||
import { zodResolver } from '@hookform/resolvers/zod'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { useFetcher, useRouteLoaderData } from 'react-router'
|
|
||||||
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
|
|
||||||
import { z } from 'zod'
|
|
||||||
|
|
||||||
import { Button } from '~/components/ui/button'
|
|
||||||
import { Combobox } from '~/components/ui/combobox'
|
|
||||||
import { Input } from '~/components/ui/input'
|
|
||||||
import { useNewsContext } from '~/contexts/news'
|
|
||||||
import type { loader } from '~/routes/_news'
|
|
||||||
|
|
||||||
export const registerSchema = z
|
|
||||||
.object({
|
|
||||||
email: z.string().email('Email tidak valid'),
|
|
||||||
password: z.string().min(6, 'Kata sandi minimal 6 karakter'),
|
|
||||||
rePassword: z.string().min(6, 'Kata sandi minimal 6 karakter'),
|
|
||||||
phone: z.string().min(10, 'No telepon tidak valid'),
|
|
||||||
subscribe_plan: z
|
|
||||||
.object({
|
|
||||||
id: z.string(),
|
|
||||||
code: z.string(),
|
|
||||||
name: z.string(),
|
|
||||||
})
|
|
||||||
.optional()
|
|
||||||
.nullable()
|
|
||||||
.refine((data) => !!data, {
|
|
||||||
message: 'Please select a Subscribe Plan',
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
.refine((field) => field.password === field.rePassword, {
|
|
||||||
message: 'Kata sandi tidak sama',
|
|
||||||
path: ['rePassword'],
|
|
||||||
})
|
|
||||||
|
|
||||||
export type TRegisterSchema = z.infer<typeof registerSchema>
|
|
||||||
|
|
||||||
export const FormRegister = () => {
|
|
||||||
const { setIsLoginOpen, setIsRegisterOpen, setIsSuccessOpen } =
|
|
||||||
useNewsContext()
|
|
||||||
const [error, setError] = useState<string>()
|
|
||||||
const fetcher = useFetcher()
|
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
|
||||||
const { subscribePlanData: subscribePlan } = loaderData || {}
|
|
||||||
|
|
||||||
const formMethods = useRemixForm<TRegisterSchema>({
|
|
||||||
mode: 'onSubmit',
|
|
||||||
fetcher,
|
|
||||||
resolver: zodResolver(registerSchema),
|
|
||||||
})
|
|
||||||
|
|
||||||
const { handleSubmit, control } = formMethods
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!fetcher.data?.success) {
|
|
||||||
setError(fetcher.data?.message)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setError(undefined)
|
|
||||||
setIsRegisterOpen(false)
|
|
||||||
setIsSuccessOpen('register')
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [fetcher])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center justify-center">
|
|
||||||
<div className="w-full max-w-md">
|
|
||||||
<RemixFormProvider {...formMethods}>
|
|
||||||
<fetcher.Form
|
|
||||||
method="post"
|
|
||||||
onSubmit={handleSubmit}
|
|
||||||
className="space-y-4"
|
|
||||||
action="/actions/register"
|
|
||||||
>
|
|
||||||
<Input
|
|
||||||
id="email"
|
|
||||||
label="Email"
|
|
||||||
placeholder="Contoh: legal@legalgo.id"
|
|
||||||
name="email"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Input
|
|
||||||
id="password"
|
|
||||||
label="Kata Sandi"
|
|
||||||
placeholder="Masukkan Kata Sandi"
|
|
||||||
name="password"
|
|
||||||
type="password"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Input
|
|
||||||
id="re-password"
|
|
||||||
label="Ulangi Kata Sandi"
|
|
||||||
placeholder="Masukkan Kata Sandi"
|
|
||||||
name="rePassword"
|
|
||||||
type="password"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Input
|
|
||||||
id="phone"
|
|
||||||
label="No. Telepon"
|
|
||||||
placeholder="Masukkan No. Telepon"
|
|
||||||
name="phone"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Combobox
|
|
||||||
id="subscribe_plan"
|
|
||||||
name="subscribe_plan"
|
|
||||||
label="Subscribe Plan"
|
|
||||||
placeholder="Pilih Subscribe Plan"
|
|
||||||
options={subscribePlan}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{error && (
|
|
||||||
<div className="text-sm text-red-500 capitalize">{error}</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Button
|
|
||||||
isLoading={fetcher.state !== 'idle'}
|
|
||||||
disabled={fetcher.state !== 'idle'}
|
|
||||||
type="submit"
|
|
||||||
className="w-full rounded-md py-2"
|
|
||||||
>
|
|
||||||
Daftar
|
|
||||||
</Button>
|
|
||||||
</fetcher.Form>
|
|
||||||
</RemixFormProvider>
|
|
||||||
|
|
||||||
{/* Link Login */}
|
|
||||||
<div className="mt-4 text-center text-sm">
|
|
||||||
Sudah punya akun?{' '}
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
setIsLoginOpen(true)
|
|
||||||
setIsRegisterOpen(false)
|
|
||||||
}}
|
|
||||||
variant="link"
|
|
||||||
size="fit"
|
|
||||||
>
|
|
||||||
Masuk Disini
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<DevTool control={control} />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
import { zodResolver } from '@hookform/resolvers/zod'
|
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { useFetcher, useRouteLoaderData } from 'react-router'
|
|
||||||
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
|
|
||||||
import { z } from 'zod'
|
|
||||||
|
|
||||||
import { Button } from '~/components/ui/button'
|
|
||||||
import { Combobox } from '~/components/ui/combobox'
|
|
||||||
import { useNewsContext } from '~/contexts/news'
|
|
||||||
import type { loader } from '~/routes/_news'
|
|
||||||
|
|
||||||
export const subscribeSchema = z.object({
|
|
||||||
subscribe_plan: z
|
|
||||||
.object({
|
|
||||||
id: z.string(),
|
|
||||||
code: z.string(),
|
|
||||||
name: z.string(),
|
|
||||||
})
|
|
||||||
.optional()
|
|
||||||
.nullable()
|
|
||||||
.refine((data) => !!data, {
|
|
||||||
message: 'Please select a subscription',
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
|
|
||||||
export type TSubscribeSchema = z.infer<typeof subscribeSchema>
|
|
||||||
|
|
||||||
export const FormSubscribePlan = () => {
|
|
||||||
const { setIsSubscribeOpen, setIsSuccessOpen } = useNewsContext()
|
|
||||||
const fetcher = useFetcher()
|
|
||||||
const [error, setError] = useState<string>()
|
|
||||||
const loaderData = useRouteLoaderData<typeof loader>('routes/_news')
|
|
||||||
const { subscribePlanData: subscribePlan } = loaderData || {}
|
|
||||||
|
|
||||||
const formMethods = useRemixForm<TSubscribeSchema>({
|
|
||||||
mode: 'onSubmit',
|
|
||||||
fetcher,
|
|
||||||
resolver: zodResolver(subscribeSchema),
|
|
||||||
})
|
|
||||||
|
|
||||||
const { handleSubmit } = formMethods
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!fetcher.data?.success) {
|
|
||||||
setError(fetcher.data?.message)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setError(undefined)
|
|
||||||
setIsSubscribeOpen(false)
|
|
||||||
setIsSuccessOpen('payment')
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [fetcher])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col items-center justify-center">
|
|
||||||
<RemixFormProvider {...formMethods}>
|
|
||||||
<fetcher.Form
|
|
||||||
method="post"
|
|
||||||
onSubmit={handleSubmit}
|
|
||||||
className="w-full max-w-md"
|
|
||||||
action="/actions/subscribe"
|
|
||||||
>
|
|
||||||
<Combobox
|
|
||||||
id="subscribe_plan"
|
|
||||||
name="subscribe_plan"
|
|
||||||
label="Subscribe Plan"
|
|
||||||
placeholder="Pilih Subscribe Plan"
|
|
||||||
options={subscribePlan}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{error && (
|
|
||||||
<div className="text-sm text-red-500 capitalize">{error}</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Button
|
|
||||||
isLoading={fetcher.state !== 'idle'}
|
|
||||||
disabled={fetcher.state !== 'idle'}
|
|
||||||
type="submit"
|
|
||||||
className="mt-5 w-full rounded-md py-2"
|
|
||||||
>
|
|
||||||
Lanjutkan
|
|
||||||
</Button>
|
|
||||||
</fetcher.Form>
|
|
||||||
</RemixFormProvider>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -37,7 +37,7 @@ export const HeaderMenuMobile = (properties: THeaderMenuMobile) => {
|
|||||||
{/* Tombol Close */}
|
{/* Tombol Close */}
|
||||||
<button
|
<button
|
||||||
onClick={handleToggleMenu}
|
onClick={handleToggleMenu}
|
||||||
className="fixed top-5 right-5 z-20 flex h-9 w-9 items-center justify-center lg:hidden"
|
className="fixed top-5 right-5 z-20 flex size-9 items-center justify-center lg:hidden"
|
||||||
>
|
>
|
||||||
<CloseIcon
|
<CloseIcon
|
||||||
width={50}
|
width={50}
|
||||||
@@ -70,7 +70,7 @@ export const HeaderMenuMobile = (properties: THeaderMenuMobile) => {
|
|||||||
action="/actions/logout"
|
action="/actions/logout"
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="newsSecondary"
|
variant="outline"
|
||||||
className="w-full px-[35px] py-3 text-center sm:hidden"
|
className="w-full px-[35px] py-3 text-center sm:hidden"
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
@@ -79,7 +79,7 @@ export const HeaderMenuMobile = (properties: THeaderMenuMobile) => {
|
|||||||
</fetcher.Form>
|
</fetcher.Form>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
variant="newsSecondary"
|
variant="outline"
|
||||||
className="w-full px-[35px] py-3 text-center sm:hidden"
|
className="w-full px-[35px] py-3 text-center sm:hidden"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setIsMenuOpen(false)
|
setIsMenuOpen(false)
|
||||||
|
|||||||
@@ -3,11 +3,16 @@ import { Button } from '~/components/ui/button'
|
|||||||
|
|
||||||
export const HeaderSearch = () => {
|
export const HeaderSearch = () => {
|
||||||
return (
|
return (
|
||||||
<form className="flex flex-1 justify-between gap-[15px] px-[35px]">
|
<form
|
||||||
|
className="flex flex-1 justify-between gap-[15px] px-[35px]"
|
||||||
|
method="get"
|
||||||
|
action="/search"
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
placeholder="Cari..."
|
placeholder="Cari..."
|
||||||
className="flex-1 text-xl placeholder:text-white focus:ring-0 focus:outline-none"
|
className="flex-1 text-xl placeholder:text-white focus:ring-0 focus:outline-none"
|
||||||
size={1}
|
size={1}
|
||||||
|
name="q"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export const HeaderTop = () => {
|
|||||||
action="/actions/logout"
|
action="/actions/logout"
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="newsSecondary"
|
variant="outline"
|
||||||
className="hidden sm:flex"
|
className="hidden sm:flex"
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={fetcher.state !== 'idle'}
|
disabled={fetcher.state !== 'idle'}
|
||||||
@@ -44,7 +44,7 @@ export const HeaderTop = () => {
|
|||||||
</fetcher.Form>
|
</fetcher.Form>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
variant="newsSecondary"
|
variant="outline"
|
||||||
className="hidden sm:block"
|
className="hidden sm:block"
|
||||||
onClick={() => setIsLoginOpen(true)}
|
onClick={() => setIsLoginOpen(true)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export const FOOTER_MENU: TFooterMenu[] = [
|
|||||||
url: '/support',
|
url: '/support',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Rquest Topic',
|
title: 'Request Topic',
|
||||||
url: '/request-topic',
|
url: '/request-topic',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ import xior, { merge } from 'xior'
|
|||||||
|
|
||||||
const baseURL = import.meta.env.VITE_API_URL
|
const baseURL = import.meta.env.VITE_API_URL
|
||||||
|
|
||||||
export type THttpServer = { accessToken?: string }
|
export type THttpServer = {
|
||||||
|
accessToken?: string
|
||||||
|
ipAddress?: string | null
|
||||||
|
userAgent?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
export const HttpServer = (parameters?: THttpServer) => {
|
export const HttpServer = (parameters?: THttpServer) => {
|
||||||
const { accessToken } = parameters || {}
|
const { accessToken, ipAddress, userAgent } = parameters || {}
|
||||||
const instance = xior.create({
|
const instance = xior.create({
|
||||||
baseURL,
|
baseURL,
|
||||||
})
|
})
|
||||||
@@ -16,6 +20,8 @@ export const HttpServer = (parameters?: THttpServer) => {
|
|||||||
return merge(config, {
|
return merge(config, {
|
||||||
headers: {
|
headers: {
|
||||||
...(accessToken && { Authorization: `Bearer ${accessToken}` }),
|
...(accessToken && { Authorization: `Bearer ${accessToken}` }),
|
||||||
|
...(ipAddress && { 'X-Ip-Address': ipAddress }),
|
||||||
|
...(userAgent && { 'X-User-Agent': userAgent }),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
PencilSquareIcon,
|
PencilSquareIcon,
|
||||||
PlusIcon,
|
PlusIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
} from '@heroicons/react/20/solid'
|
} from '@heroicons/react/24/solid'
|
||||||
import type { ConfigColumns } from 'datatables.net-dt'
|
import type { ConfigColumns } from 'datatables.net-dt'
|
||||||
import type { DataTableSlots } from 'datatables.net-react'
|
import type { DataTableSlots } from 'datatables.net-react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
@@ -14,7 +14,7 @@ import { Button } from '~/components/ui/button'
|
|||||||
import { UiTable } from '~/components/ui/table'
|
import { UiTable } from '~/components/ui/table'
|
||||||
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
||||||
import type { loader } from '~/routes/_admin.lg-admin._dashboard.advertisements._index'
|
import type { loader } from '~/routes/_admin.lg-admin._dashboard.advertisements._index'
|
||||||
import { formatDate } from '~/utils/formatter'
|
import { formatDate, formatNumberWithPeriods } from '~/utils/formatter'
|
||||||
|
|
||||||
export const AdvertisementsPage = () => {
|
export const AdvertisementsPage = () => {
|
||||||
const loaderData = useRouteLoaderData<typeof loader>(
|
const loaderData = useRouteLoaderData<typeof loader>(
|
||||||
@@ -52,7 +52,11 @@ export const AdvertisementsPage = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Action',
|
title: 'Jumlah Klik',
|
||||||
|
data: 'clicked',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Tindakan',
|
||||||
data: 'id',
|
data: 'id',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -66,24 +70,25 @@ export const AdvertisementsPage = () => {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
5: (value: string, _type: unknown, data: TAdResponse) => (
|
5: (value: number) => formatNumberWithPeriods(value),
|
||||||
|
6: (value: string, _type: unknown, data: TAdResponse) => (
|
||||||
<div className="flex space-x-2">
|
<div className="flex space-x-2">
|
||||||
<Button
|
<Button
|
||||||
as="a"
|
as="a"
|
||||||
href={`/lg-admin/advertisements/update/${value}`}
|
href={`/lg-admin/advertisements/update/${value}`}
|
||||||
size="icon"
|
size="icon"
|
||||||
title="Update Banner Iklan"
|
title="Update Spanduk Iklan"
|
||||||
>
|
>
|
||||||
<PencilSquareIcon className="h-4 w-4" />
|
<PencilSquareIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="newsDanger"
|
variant="danger"
|
||||||
onClick={() => setSelectedAds(data)}
|
onClick={() => setSelectedAds(data)}
|
||||||
title="Hapus Banner Iklan"
|
title="Hapus Spanduk Iklan"
|
||||||
>
|
>
|
||||||
<TrashIcon className="h-4 w-4" />
|
<TrashIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
@@ -91,7 +96,7 @@ export const AdvertisementsPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<TitleDashboard title="Banner Iklan" />
|
<TitleDashboard title="Spanduk Iklan" />
|
||||||
|
|
||||||
<div className="mb-8 flex items-end justify-between gap-5">
|
<div className="mb-8 flex items-end justify-between gap-5">
|
||||||
<div className="flex-1">{/* TODO: Filter */}</div>
|
<div className="flex-1">{/* TODO: Filter */}</div>
|
||||||
@@ -101,21 +106,21 @@ export const AdvertisementsPage = () => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] px-4"
|
className="text-md h-[42px] px-4"
|
||||||
>
|
>
|
||||||
<PlusIcon className="h-8 w-8" /> Buat Banner Iklan
|
<PlusIcon className="size-8" /> Buat Spanduk Iklan
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UiTable
|
<UiTable
|
||||||
data={dataTable}
|
data={dataTable || []}
|
||||||
columns={dataColumns}
|
columns={dataColumns}
|
||||||
slots={dataSlot}
|
slots={dataSlot}
|
||||||
title="Daftar Banner Iklan"
|
title="Daftar Spanduk Iklan"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DialogDelete
|
<DialogDelete
|
||||||
selectedId={selectedAds?.id}
|
selectedId={selectedAds?.id}
|
||||||
close={() => setSelectedAds(undefined)}
|
close={() => setSelectedAds(undefined)}
|
||||||
title="Banner iklan"
|
title="Spanduk iklan"
|
||||||
fetcherAction={`/actions/admin/advertisements/delete/${selectedAds?.id}`}
|
fetcherAction={`/actions/admin/advertisements/delete/${selectedAds?.id}`}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import { PencilSquareIcon, TrashIcon } from '@heroicons/react/20/solid'
|
import {
|
||||||
|
PencilSquareIcon,
|
||||||
|
PlusIcon,
|
||||||
|
TrashIcon,
|
||||||
|
} from '@heroicons/react/24/solid'
|
||||||
import DT, { type Config, type ConfigColumns } from 'datatables.net-dt'
|
import DT, { type Config, type ConfigColumns } from 'datatables.net-dt'
|
||||||
import DataTable, { type DataTableSlots } from 'datatables.net-react'
|
import DataTable, { type DataTableSlots } from 'datatables.net-react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
@@ -47,7 +51,7 @@ export const CategoriesPage = () => {
|
|||||||
data: 'description',
|
data: 'description',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Action',
|
title: 'Tindakan',
|
||||||
data: 'id',
|
data: 'id',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -66,7 +70,7 @@ export const CategoriesPage = () => {
|
|||||||
size="icon"
|
size="icon"
|
||||||
title="Update Kategori"
|
title="Update Kategori"
|
||||||
>
|
>
|
||||||
<PencilSquareIcon className="h-4 w-4" />
|
<PencilSquareIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
{data.code === 'spotlight' ? (
|
{data.code === 'spotlight' ? (
|
||||||
''
|
''
|
||||||
@@ -74,11 +78,11 @@ export const CategoriesPage = () => {
|
|||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="newsDanger"
|
variant="danger"
|
||||||
onClick={() => setSelectedCategory(data)}
|
onClick={() => setSelectedCategory(data)}
|
||||||
title="Hapus Kategori"
|
title="Hapus Kategori"
|
||||||
>
|
>
|
||||||
<TrashIcon className="h-4 w-4" />
|
<TrashIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -102,7 +106,7 @@ export const CategoriesPage = () => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] px-4"
|
className="text-md h-[42px] px-4"
|
||||||
>
|
>
|
||||||
Buat Kategori
|
<PlusIcon className="size-8" /> Buat Kategori
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,28 @@
|
|||||||
|
import {
|
||||||
|
PencilSquareIcon,
|
||||||
|
PlusIcon,
|
||||||
|
TrashIcon,
|
||||||
|
} from '@heroicons/react/24/solid'
|
||||||
import DT, { type Config, type ConfigColumns } from 'datatables.net-dt'
|
import DT, { type Config, type ConfigColumns } from 'datatables.net-dt'
|
||||||
import DataTable, { type DataTableSlots } from 'datatables.net-react'
|
import DataTable, { type DataTableSlots } from 'datatables.net-react'
|
||||||
|
import { useState } from 'react'
|
||||||
import { Link, useRouteLoaderData } from 'react-router'
|
import { Link, useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
import type { TCategoryResponse } from '~/apis/common/get-categories'
|
import type { TCategoryResponse } from '~/apis/common/get-categories'
|
||||||
import type { TAuthorResponse } from '~/apis/common/get-news'
|
import type { TAuthorResponse, TNewsResponse } from '~/apis/common/get-news'
|
||||||
import type { TTagResponse } from '~/apis/common/get-tags'
|
import type { TTagResponse } from '~/apis/common/get-tags'
|
||||||
|
import { DialogDelete } from '~/components/dialog/delete'
|
||||||
import { Button } from '~/components/ui/button'
|
import { Button } from '~/components/ui/button'
|
||||||
import { UiTable } from '~/components/ui/table'
|
import { UiTable } from '~/components/ui/table'
|
||||||
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
||||||
import type { loader } from '~/routes/_admin.lg-admin._dashboard.contents._index'
|
import type { loader } from '~/routes/_admin.lg-admin._dashboard.contents._index'
|
||||||
import { formatDate } from '~/utils/formatter'
|
import { formatDate, formatNumberWithPeriods } from '~/utils/formatter'
|
||||||
|
|
||||||
export const ContentsPage = () => {
|
export const ContentsPage = () => {
|
||||||
const loaderData = useRouteLoaderData<typeof loader>(
|
const loaderData = useRouteLoaderData<typeof loader>(
|
||||||
'routes/_admin.lg-admin._dashboard.contents._index',
|
'routes/_admin.lg-admin._dashboard.contents._index',
|
||||||
)
|
)
|
||||||
|
const [selectedContent, setSelectedContent] = useState<TNewsResponse>()
|
||||||
DataTable.use(DT)
|
DataTable.use(DT)
|
||||||
const dataTable =
|
const dataTable =
|
||||||
loaderData?.newsData?.sort(
|
loaderData?.newsData?.sort(
|
||||||
@@ -34,7 +41,7 @@ export const ContentsPage = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Tanggal Live',
|
title: 'Mulai Tayang',
|
||||||
data: 'live_at',
|
data: 'live_at',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -48,28 +55,36 @@ export const ContentsPage = () => {
|
|||||||
},
|
},
|
||||||
{ title: 'Tag', data: 'tags' },
|
{ title: 'Tag', data: 'tags' },
|
||||||
{
|
{
|
||||||
title: 'Subscription',
|
title: 'Tipe Langganan',
|
||||||
data: 'is_premium',
|
data: 'is_premium',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Action',
|
title: 'Jumlah Penayangan',
|
||||||
data: 'slug',
|
data: 'views',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Tindakan',
|
||||||
|
data: 'id',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
const dataSlot: DataTableSlots = {
|
const dataSlot: DataTableSlots = {
|
||||||
1: (value: string) => formatDate(value),
|
1: (value: string) => formatDate(value),
|
||||||
2: (value: TAuthorResponse) => (
|
2: (value: TAuthorResponse) => (
|
||||||
<div>
|
<>
|
||||||
<div>{value.name}</div>
|
<div>{value.name}</div>
|
||||||
<div className="text-sm text-[#7C7C7C]">ID: {value.id.slice(0, 8)}</div>
|
<div className="text-xs text-[#7C7C7C]">ID: {value.id.slice(0, 8)}</div>
|
||||||
</div>
|
</>
|
||||||
),
|
),
|
||||||
3: (value: string) => <span className="text-sm">{value}</span>,
|
3: (value: string) => <span className="text-sm">{value}</span>,
|
||||||
4: (value: TCategoryResponse[]) => (
|
4: (value: TCategoryResponse[]) => (
|
||||||
<div className="text-xs">{value.map((item) => item.name).join(', ')}</div>
|
<span className="text-xs">
|
||||||
|
{value.map((item) => item.name).join(', ')}
|
||||||
|
</span>
|
||||||
),
|
),
|
||||||
5: (value: TTagResponse[]) => (
|
5: (value: TTagResponse[]) => (
|
||||||
<div className="text-xs">{value.map((item) => item.name).join(', ')}</div>
|
<span className="text-xs">
|
||||||
|
{value.map((item) => item.name).join(', ')}
|
||||||
|
</span>
|
||||||
),
|
),
|
||||||
6: (value: string) =>
|
6: (value: string) =>
|
||||||
value ? (
|
value ? (
|
||||||
@@ -78,18 +93,30 @@ export const ContentsPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="rounded-full bg-[#F5F5F5] px-2 text-center text-[#4C5CA0]">
|
<div className="rounded-full bg-[#F5F5F5] px-2 text-center text-[#4C5CA0]">
|
||||||
Normal
|
Biasa
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
7: (value: string) => (
|
7: (value: number) => formatNumberWithPeriods(value),
|
||||||
|
8: (value: string, _type: unknown, data: TNewsResponse) => (
|
||||||
|
<div className="flex space-x-2">
|
||||||
<Button
|
<Button
|
||||||
as="a"
|
as="a"
|
||||||
href={`/lg-admin/contents/update/${encodeURIComponent(value)}`}
|
href={`/lg-admin/contents/update/${encodeURIComponent(value)}`}
|
||||||
className="text-md rounded-md"
|
size="icon"
|
||||||
size="sm"
|
title="Update Artikel"
|
||||||
>
|
>
|
||||||
Update Artikel
|
<PencilSquareIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
size="icon"
|
||||||
|
variant="danger"
|
||||||
|
onClick={() => setSelectedContent(data)}
|
||||||
|
title="Hapus Artikel"
|
||||||
|
>
|
||||||
|
<TrashIcon className="size-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
const dataOptions: Config = {
|
const dataOptions: Config = {
|
||||||
@@ -110,7 +137,7 @@ export const ContentsPage = () => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] px-4"
|
className="text-md h-[42px] px-4"
|
||||||
>
|
>
|
||||||
Buat Artikel
|
<PlusIcon className="size-8" /> Buat Artikel
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -121,6 +148,15 @@ export const ContentsPage = () => {
|
|||||||
options={dataOptions}
|
options={dataOptions}
|
||||||
title="Daftar Artikel"
|
title="Daftar Artikel"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<DialogDelete
|
||||||
|
selectedId={selectedContent?.id}
|
||||||
|
close={() => setSelectedContent(undefined)}
|
||||||
|
title="Artikel"
|
||||||
|
fetcherAction={`/actions/admin/contents/delete/${selectedContent?.id}`}
|
||||||
|
>
|
||||||
|
<p>{selectedContent?.title}</p>
|
||||||
|
</DialogDelete>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import { PlusIcon } from '@heroicons/react/24/solid'
|
||||||
|
import DT, { type ConfigColumns } from 'datatables.net-dt'
|
||||||
|
import DataTable, { type DataTableSlots } from 'datatables.net-react'
|
||||||
|
import { Link, useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
|
import type { TStaffResponse } from '~/apis/admin/get-staffs'
|
||||||
|
import { Button } from '~/components/ui/button'
|
||||||
|
import { UiTable } from '~/components/ui/table'
|
||||||
|
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
||||||
|
import type { loader } from '~/routes/_admin.lg-admin._dashboard.staffs._index'
|
||||||
|
|
||||||
|
export const StaffsPage = () => {
|
||||||
|
const loaderData = useRouteLoaderData<typeof loader>(
|
||||||
|
'routes/_admin.lg-admin._dashboard.staffs._index',
|
||||||
|
)
|
||||||
|
|
||||||
|
DataTable.use(DT)
|
||||||
|
const { staffsData: dataTable } = loaderData || {}
|
||||||
|
|
||||||
|
const dataColumns: ConfigColumns[] = [
|
||||||
|
{
|
||||||
|
title: 'No',
|
||||||
|
render: (
|
||||||
|
_data: unknown,
|
||||||
|
_type: unknown,
|
||||||
|
_row: unknown,
|
||||||
|
meta: { row: number },
|
||||||
|
) => {
|
||||||
|
return meta.row + 1
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Staf',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Email',
|
||||||
|
data: 'email',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
const dataSlot: DataTableSlots = {
|
||||||
|
1: (_value: unknown, _type: unknown, data: TStaffResponse) => (
|
||||||
|
<div className="flex items-center gap-x-2">
|
||||||
|
<img
|
||||||
|
src={data?.profile_picture || '/images/profile-placeholder.svg'}
|
||||||
|
onError={(event) => {
|
||||||
|
event.currentTarget.src = '/images/profile-placeholder.svg'
|
||||||
|
}}
|
||||||
|
alt={data?.name}
|
||||||
|
className="size-8 rounded-full bg-[#C4C4C4] object-cover"
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<div>{data.name}</div>
|
||||||
|
<div className="text-xs text-[#7C7C7C]">
|
||||||
|
ID: {data.id.slice(0, 8)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="relative">
|
||||||
|
<TitleDashboard title="Staf" />
|
||||||
|
<div className="mb-8 flex items-end justify-between gap-5">
|
||||||
|
<div className="flex-1">{/* TODO: Filter */}</div>
|
||||||
|
<Button
|
||||||
|
as={Link}
|
||||||
|
to="/lg-admin/staffs/create"
|
||||||
|
size="lg"
|
||||||
|
className="text-md h-[42px] px-4"
|
||||||
|
>
|
||||||
|
<PlusIcon className="size-8" /> Buat Staf
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<UiTable
|
||||||
|
data={dataTable}
|
||||||
|
columns={dataColumns}
|
||||||
|
slots={dataSlot}
|
||||||
|
title="Daftar Staf"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -2,9 +2,9 @@ import {
|
|||||||
PencilSquareIcon,
|
PencilSquareIcon,
|
||||||
PlusIcon,
|
PlusIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
} from '@heroicons/react/20/solid'
|
} from '@heroicons/react/24/solid'
|
||||||
import DT from 'datatables.net-dt'
|
import DT, { type ConfigColumns } from 'datatables.net-dt'
|
||||||
import DataTable from 'datatables.net-react'
|
import DataTable, { type DataTableSlots } from 'datatables.net-react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Link, useRouteLoaderData } from 'react-router'
|
import { Link, useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ export const SubscribePlanPage = () => {
|
|||||||
DataTable.use(DT)
|
DataTable.use(DT)
|
||||||
const { subscribePlanData: dataTable } = loaderData || {}
|
const { subscribePlanData: dataTable } = loaderData || {}
|
||||||
|
|
||||||
const dataColumns = [
|
const dataColumns: ConfigColumns[] = [
|
||||||
{
|
{
|
||||||
title: 'No',
|
title: 'No',
|
||||||
render: (
|
render: (
|
||||||
@@ -48,26 +48,25 @@ export const SubscribePlanPage = () => {
|
|||||||
data: 'code',
|
data: 'code',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Length',
|
title: 'Durasi',
|
||||||
data: 'length',
|
data: 'length',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Harga',
|
title: 'Harga',
|
||||||
data: 'price',
|
data: 'price',
|
||||||
|
className: 'dt-type-numeric',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Status',
|
title: 'Status',
|
||||||
data: 'status',
|
data: 'status',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Action',
|
title: 'Tindakan',
|
||||||
data: 'id',
|
data: 'id',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
const dataSlot = {
|
const dataSlot: DataTableSlots = {
|
||||||
4: (value: number) => (
|
4: (value: number) => `Rp. ${formatNumberWithPeriods(value)}`,
|
||||||
<div className="text-right">Rp. {formatNumberWithPeriods(value)}</div>
|
|
||||||
),
|
|
||||||
5: (value: number) => (
|
5: (value: number) => (
|
||||||
<span
|
<span
|
||||||
className={`rounded-lg px-2 text-sm ${getStatusBadge(value as TColorBadge)}`}
|
className={`rounded-lg px-2 text-sm ${getStatusBadge(value as TColorBadge)}`}
|
||||||
@@ -84,25 +83,25 @@ export const SubscribePlanPage = () => {
|
|||||||
as="a"
|
as="a"
|
||||||
href={`/lg-admin/subscribe-plan/update/${value}`}
|
href={`/lg-admin/subscribe-plan/update/${value}`}
|
||||||
size="icon"
|
size="icon"
|
||||||
title="Update Subscribe Plan"
|
title="Update Paket Berlangganan"
|
||||||
>
|
>
|
||||||
<PencilSquareIcon className="h-4 w-4" />
|
<PencilSquareIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="newsDanger"
|
variant="danger"
|
||||||
onClick={() => setSelectedSubscribePlan(data)}
|
onClick={() => setSelectedSubscribePlan(data)}
|
||||||
title="Hapus Subscribe Plan"
|
title="Hapus Paket Berlangganan"
|
||||||
>
|
>
|
||||||
<TrashIcon className="h-4 w-4" />
|
<TrashIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<TitleDashboard title="Subscribe Plan" />
|
<TitleDashboard title="Paket Berlangganan" />
|
||||||
<div className="mb-8 flex items-end justify-between">
|
<div className="mb-8 flex items-end justify-between">
|
||||||
<div className="flex-1">{/* TODO: Filter */}</div>
|
<div className="flex-1">{/* TODO: Filter */}</div>
|
||||||
<Button
|
<Button
|
||||||
@@ -111,12 +110,12 @@ export const SubscribePlanPage = () => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] px-4"
|
className="text-md h-[42px] px-4"
|
||||||
>
|
>
|
||||||
<PlusIcon className="h-8 w-8" /> Buat Subscribe Plan
|
<PlusIcon className="size-8" /> Buat Paket Berlangganan
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UiTable
|
<UiTable
|
||||||
data={dataTable || []}
|
data={dataTable}
|
||||||
columns={dataColumns}
|
columns={dataColumns}
|
||||||
slots={dataSlot}
|
slots={dataSlot}
|
||||||
options={{
|
options={{
|
||||||
@@ -125,13 +124,13 @@ export const SubscribePlanPage = () => {
|
|||||||
ordering: true,
|
ordering: true,
|
||||||
info: true,
|
info: true,
|
||||||
}}
|
}}
|
||||||
title=" Daftar Subscribe Plan"
|
title=" Daftar Paket Berlangganan"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DialogDelete
|
<DialogDelete
|
||||||
selectedId={selectedSubscribePlan?.id}
|
selectedId={selectedSubscribePlan?.id}
|
||||||
close={() => setSelectedSubscribePlan(undefined)}
|
close={() => setSelectedSubscribePlan(undefined)}
|
||||||
title="Subscribe plan"
|
title="Paket Berlangganan"
|
||||||
fetcherAction={`/actions/admin/subscribe-plan/delete/${selectedSubscribePlan?.id}`}
|
fetcherAction={`/actions/admin/subscribe-plan/delete/${selectedSubscribePlan?.id}`}
|
||||||
>
|
>
|
||||||
<p>{selectedSubscribePlan?.name}</p>
|
<p>{selectedSubscribePlan?.name}</p>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export const SubscriptionsPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<TitleDashboard title="Subscription" />
|
<TitleDashboard title="Pelanggan" />
|
||||||
|
|
||||||
<div className="mb-8 flex items-end justify-between">
|
<div className="mb-8 flex items-end justify-between">
|
||||||
<div className="flex items-center gap-5 rounded-lg bg-gray-50 text-[#363636]">
|
<div className="flex items-center gap-5 rounded-lg bg-gray-50 text-[#363636]">
|
||||||
@@ -43,7 +43,7 @@ export const SubscriptionsPage = () => {
|
|||||||
className="w-full rounded-lg bg-white p-2 pr-10 pl-4 shadow focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none"
|
className="w-full rounded-lg bg-white p-2 pr-10 pl-4 shadow focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none"
|
||||||
/>
|
/>
|
||||||
<div className="absolute inset-y-0 right-0 flex items-center pr-3">
|
<div className="absolute inset-y-0 right-0 flex items-center pr-3">
|
||||||
<SearchIcon className="h-5 w-5" />
|
<SearchIcon className="size-5" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
@@ -71,7 +71,7 @@ export const SubscriptionsPage = () => {
|
|||||||
ordering: true,
|
ordering: true,
|
||||||
info: true,
|
info: true,
|
||||||
}}
|
}}
|
||||||
title="Daftar Subscription"
|
title="Daftar Pelanggan"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
PencilSquareIcon,
|
PencilSquareIcon,
|
||||||
PlusIcon,
|
PlusIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
} from '@heroicons/react/20/solid'
|
} from '@heroicons/react/24/solid'
|
||||||
import DT, { type Config, type ConfigColumns } from 'datatables.net-dt'
|
import DT, { type Config, type ConfigColumns } from 'datatables.net-dt'
|
||||||
import DataTable, { type DataTableSlots } from 'datatables.net-react'
|
import DataTable, { type DataTableSlots } from 'datatables.net-react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
@@ -46,7 +46,7 @@ export const TagsPage = () => {
|
|||||||
data: 'code',
|
data: 'code',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Action',
|
title: 'Tindakan',
|
||||||
data: 'id',
|
data: 'id',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -59,16 +59,16 @@ export const TagsPage = () => {
|
|||||||
size="icon"
|
size="icon"
|
||||||
title="Update Tag"
|
title="Update Tag"
|
||||||
>
|
>
|
||||||
<PencilSquareIcon className="h-4 w-4" />
|
<PencilSquareIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
size="icon"
|
size="icon"
|
||||||
variant="newsDanger"
|
variant="danger"
|
||||||
onClick={() => setSelectedTag(data)}
|
onClick={() => setSelectedTag(data)}
|
||||||
title="Hapus Tag"
|
title="Hapus Tag"
|
||||||
>
|
>
|
||||||
<TrashIcon className="h-4 w-4" />
|
<TrashIcon className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
@@ -88,7 +88,7 @@ export const TagsPage = () => {
|
|||||||
})
|
})
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<TitleDashboard title="Tags" />
|
<TitleDashboard title="Tag" />
|
||||||
<div className="mb-8 flex items-end justify-between gap-5">
|
<div className="mb-8 flex items-end justify-between gap-5">
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<TableSearchFilter
|
<TableSearchFilter
|
||||||
@@ -102,7 +102,7 @@ export const TagsPage = () => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] px-4"
|
className="text-md h-[42px] px-4"
|
||||||
>
|
>
|
||||||
<PlusIcon className="h-8 w-8" /> Buat Tag
|
<PlusIcon className="size-8" /> Buat Tag
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ export const TagsPage = () => {
|
|||||||
columns={dataColumns}
|
columns={dataColumns}
|
||||||
options={dataOptions}
|
options={dataOptions}
|
||||||
slots={dataSlot}
|
slots={dataSlot}
|
||||||
title="Daftar Tags"
|
title="Daftar Tag"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<DialogDelete
|
<DialogDelete
|
||||||
|
|||||||
@@ -36,18 +36,14 @@ export const UsersPage = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Tanggal Daftar',
|
title: 'Tanggal Daftar',
|
||||||
data: 'subscribe.start_date',
|
data: 'created_at',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Nama User',
|
title: 'Pengguna',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Email',
|
title: 'No. Telepon',
|
||||||
data: 'email',
|
data: 'phone',
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Kategori',
|
|
||||||
data: 'subscribe.status',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Status',
|
title: 'Status',
|
||||||
@@ -58,12 +54,12 @@ export const UsersPage = () => {
|
|||||||
1: (value: string) => formatDate(value),
|
1: (value: string) => formatDate(value),
|
||||||
2: (_value: unknown, _type: unknown, data: TUserResponse) => (
|
2: (_value: unknown, _type: unknown, data: TUserResponse) => (
|
||||||
<div>
|
<div>
|
||||||
<div>{data.phone}</div>
|
<div>{data.email}</div>
|
||||||
<div className="text-sm text-[#7C7C7C]">ID: {data.id.slice(0, 8)}</div>
|
<div className="text-xs text-[#7C7C7C]">ID: {data.id.slice(0, 8)}</div>
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
4: (_value: string) => <span className="text-sm">Pribadi</span>,
|
3: (value: string) => <span>{value}</span>,
|
||||||
5: (value: TColorBadge, _type: unknown, data: TUserResponse) => (
|
4: (value: TColorBadge, _type: unknown, data: TUserResponse) => (
|
||||||
<span
|
<span
|
||||||
className={`rounded-lg px-2 text-sm ${getStatusBadge(data.subscribe.status as TColorBadge)}`}
|
className={`rounded-lg px-2 text-sm ${getStatusBadge(data.subscribe.status as TColorBadge)}`}
|
||||||
>
|
>
|
||||||
@@ -74,17 +70,17 @@ export const UsersPage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<TitleDashboard title="Users" />
|
<TitleDashboard title="Pengguna" />
|
||||||
|
|
||||||
<div className="mb-8 flex items-end justify-between gap-5">
|
<div className="mb-8 flex items-end justify-between gap-5">
|
||||||
<div className="flex-1">{/* TODO: Filter */}</div>
|
<div className="flex-1">{/* TODO: Filter */}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UiTable
|
<UiTable
|
||||||
data={dataTable || []}
|
data={dataTable}
|
||||||
columns={dataColumns}
|
columns={dataColumns}
|
||||||
slots={dataSlot}
|
slots={dataSlot}
|
||||||
title="Daftar Users"
|
title="Daftar Pengguna"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export const ChartDonut = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="rounded-xl bg-white p-6 shadow-sm">
|
<div className="rounded-xl bg-white p-6 shadow-sm">
|
||||||
<h2 className="mb-4 text-[20px]">Subscription Selesai</h2>
|
<h2 className="mb-4 text-[20px]">Langganan Selesai</h2>
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div style={{ height: 'auto', width: '100%' }}>
|
<div style={{ height: 'auto', width: '100%' }}>
|
||||||
<Doughnut
|
<Doughnut
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export const ChartPie = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-[300px] w-full items-center justify-center rounded-xl bg-white p-5 text-center shadow-sm">
|
<div className="h-[300px] w-full items-center justify-center rounded-xl bg-white p-5 text-center shadow-sm">
|
||||||
<h2 className="text-xl font-bold">Top 5 Artikel</h2>
|
<h2 className="text-xl font-bold">5 Artikel Teratas</h2>
|
||||||
<Pie
|
<Pie
|
||||||
height={225}
|
height={225}
|
||||||
width={450}
|
width={450}
|
||||||
|
|||||||
+12
-15
@@ -1,28 +1,25 @@
|
|||||||
import { DoctorIcon } from '~/components/icons/doctor'
|
import { ChartBarIcon, ChartPieIcon } from '@heroicons/react/24/solid'
|
||||||
import { GraphIcon } from '~/components/icons/graph'
|
|
||||||
|
|
||||||
export const REPORT = [
|
export const REPORT = [
|
||||||
{ title: 'Total User', amount: 10_800, icon: GraphIcon },
|
{ title: 'Total Pengguna', amount: 8, icon: ChartBarIcon },
|
||||||
{ title: 'Total User Subscribe', amount: 5000, icon: GraphIcon },
|
{ title: 'Total Pelanggan', amount: 0, icon: ChartBarIcon },
|
||||||
{
|
{
|
||||||
title: 'Total Nilai Subscribe',
|
title: 'Total Nilai Berlangganan',
|
||||||
amount: 250_000_000,
|
amount: 0,
|
||||||
icon: GraphIcon,
|
icon: ChartBarIcon,
|
||||||
currency: 'Rp. ',
|
currency: 'Rp. ',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
export const HISTORY = [
|
export const HISTORY = [
|
||||||
{
|
{
|
||||||
title: 'Total Content Biasa',
|
title: 'Total Artikel Biasa',
|
||||||
amount: 2890,
|
amount: 7,
|
||||||
icon: GraphIcon,
|
icon: ChartPieIcon,
|
||||||
counter: [2190, 700],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Total Content Premium',
|
title: 'Total Artikel Premium',
|
||||||
amount: 274,
|
amount: 3,
|
||||||
icon: DoctorIcon,
|
icon: ChartPieIcon,
|
||||||
counter: [211, 54],
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export const DashboardPage = () => {
|
|||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<section className="mb-5 flex items-center justify-between">
|
<section className="mb-5 flex items-center justify-between">
|
||||||
<h1 className="text-xl font-bold">Dashboard</h1>
|
<h1 className="text-xl font-bold">Dasbor</h1>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span>Tanggal:</span>
|
<span>Tanggal:</span>
|
||||||
<input
|
<input
|
||||||
@@ -34,13 +34,12 @@ export const DashboardPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-5 grid grid-cols-1 gap-6 sm:grid-cols-3 sm:grid-rows-2">
|
<div className="mt-5 grid grid-cols-1 gap-6 sm:grid-cols-3 sm:grid-rows-2">
|
||||||
{HISTORY.map(({ title, amount, icon, counter }, index) => (
|
{HISTORY.map(({ title, amount, icon }, index) => (
|
||||||
<CardReport
|
<CardReport
|
||||||
key={index}
|
key={index}
|
||||||
title={title}
|
title={title}
|
||||||
amount={amount}
|
amount={amount}
|
||||||
icon={icon}
|
icon={icon}
|
||||||
counter={counter}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<div className="max-h-[300px] sm:col-span-2 sm:col-start-2 sm:row-span-2 sm:row-start-1">
|
<div className="max-h-[300px] sm:col-span-2 sm:col-start-2 sm:row-span-2 sm:row-start-1">
|
||||||
|
|||||||
@@ -10,20 +10,21 @@ import { Button } from '~/components/ui/button'
|
|||||||
import { Input } from '~/components/ui/input'
|
import { Input } from '~/components/ui/input'
|
||||||
import { InputFile } from '~/components/ui/input-file'
|
import { InputFile } from '~/components/ui/input-file'
|
||||||
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
||||||
|
import { dateInput } from '~/utils/formatter'
|
||||||
|
|
||||||
export const adsSchema = z.object({
|
export const adsSchema = z.object({
|
||||||
id: z.string().optional(),
|
id: z.string().optional(),
|
||||||
image: z.string().url({
|
image: z.string().url({
|
||||||
message: 'Gambar must be a valid URL',
|
message: 'URL tidak valid',
|
||||||
}),
|
}),
|
||||||
url: z.string().url({
|
url: z.string().url({
|
||||||
message: 'URL must be valid',
|
message: 'URL tidak valid',
|
||||||
}),
|
}),
|
||||||
start_date: z.string().min(1, {
|
start_date: z.string().min(1, {
|
||||||
message: 'Tanggal mulai is required',
|
message: 'Pilih tanggal',
|
||||||
}),
|
}),
|
||||||
end_date: z.string().min(1, {
|
end_date: z.string().min(1, {
|
||||||
message: 'Tanggal berakhir is required',
|
message: 'Pilih tanggal',
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
export type TAdsSchema = z.infer<typeof adsSchema>
|
export type TAdsSchema = z.infer<typeof adsSchema>
|
||||||
@@ -43,34 +44,28 @@ export const FormAdvertisementsPage = (properties: TProperties) => {
|
|||||||
id: adData?.id || undefined,
|
id: adData?.id || undefined,
|
||||||
image: adData?.image_url || '',
|
image: adData?.image_url || '',
|
||||||
url: adData?.url || '',
|
url: adData?.url || '',
|
||||||
start_date: adData?.start_date
|
start_date: adData?.start_date ? dateInput(adData.start_date) : '',
|
||||||
? new Date(adData.start_date).toISOString().split('T')[0]
|
end_date: adData?.end_date ? dateInput(adData.end_date) : '',
|
||||||
: '',
|
|
||||||
end_date: adData?.end_date
|
|
||||||
? new Date(adData.end_date).toISOString().split('T')[0]
|
|
||||||
: '',
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const { handleSubmit } = formMethods
|
const { handleSubmit } = formMethods
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fetcher.data?.success === false) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
toast.error(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fetcher.data?.success === true) {
|
if (fetcher.data?.success) {
|
||||||
toast.success(`Banner iklan berhasil ${adData ? 'diupdate' : 'dibuat'}!`)
|
toast.success(`Spanduk iklan berhasil ${adData ? 'diupdate' : 'dibuat'}!`)
|
||||||
navigate('/lg-admin/advertisements')
|
navigate('/lg-admin/advertisements')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher.data])
|
}, [fetcher.data])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<TitleDashboard title={`${adData ? 'Update' : 'Buat'} Banner Iklan`} />
|
<TitleDashboard title={`${adData ? 'Update' : 'Buat'} Spanduk Iklan`} />
|
||||||
<div>
|
<div>
|
||||||
<RemixFormProvider {...formMethods}>
|
<RemixFormProvider {...formMethods}>
|
||||||
<fetcher.Form
|
<fetcher.Form
|
||||||
@@ -106,7 +101,7 @@ export const FormAdvertisementsPage = (properties: TProperties) => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] rounded-md"
|
className="text-md h-[42px] rounded-md"
|
||||||
>
|
>
|
||||||
Save
|
Simpan
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-end justify-between gap-4">
|
<div className="flex items-end justify-between gap-4">
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { urlFriendlyCode } from '~/utils/formatter'
|
|||||||
|
|
||||||
export const categorySchema = z.object({
|
export const categorySchema = z.object({
|
||||||
id: z.string().optional(),
|
id: z.string().optional(),
|
||||||
name: z.string().min(3, 'Nama minimal 3 karakter'),
|
name: z.string().min(3, 'Minimal 3 karakter'),
|
||||||
code: z.string(),
|
code: z.string(),
|
||||||
sequence: z.preprocess(Number, z.number().optional()),
|
sequence: z.preprocess(Number, z.number().optional()),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
@@ -35,7 +35,7 @@ export const FormCategoryPage = (properties: TProperties) => {
|
|||||||
id: categoryData?.id || undefined,
|
id: categoryData?.id || undefined,
|
||||||
code: categoryData?.code || '',
|
code: categoryData?.code || '',
|
||||||
name: categoryData?.name || '',
|
name: categoryData?.name || '',
|
||||||
sequence: categoryData?.sequence || undefined,
|
sequence: categoryData?.sequence ?? undefined,
|
||||||
description: categoryData?.description || '',
|
description: categoryData?.description || '',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -44,17 +44,15 @@ export const FormCategoryPage = (properties: TProperties) => {
|
|||||||
const watchName = watch('name')
|
const watchName = watch('name')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fetcher.data?.success === false) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
toast.error(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fetcher.data?.success === true) {
|
if (fetcher.data?.success) {
|
||||||
toast.success(
|
toast.success(
|
||||||
`Kategori berhasil ${categoryData ? 'diupdate' : 'dibuat'}!`,
|
`Kategori berhasil ${categoryData ? 'diupdate' : 'dibuat'}!`,
|
||||||
)
|
)
|
||||||
navigate('/lg-admin/categories')
|
navigate('/lg-admin/categories')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher.data])
|
}, [fetcher.data])
|
||||||
@@ -84,6 +82,7 @@ export const FormCategoryPage = (properties: TProperties) => {
|
|||||||
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
||||||
labelClassName="text-sm font-medium text-[#363636]"
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
containerClassName="flex-1"
|
containerClassName="flex-1"
|
||||||
|
readOnly={categoryData?.code === 'spotlight'}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
id="code"
|
id="code"
|
||||||
@@ -102,7 +101,7 @@ export const FormCategoryPage = (properties: TProperties) => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] rounded-md"
|
className="text-md h-[42px] rounded-md"
|
||||||
>
|
>
|
||||||
Save
|
Simpan
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-end justify-between gap-4">
|
<div className="flex items-end justify-between gap-4">
|
||||||
@@ -115,6 +114,7 @@ export const FormCategoryPage = (properties: TProperties) => {
|
|||||||
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
||||||
labelClassName="text-sm font-medium text-[#363636]"
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
containerClassName="w-44"
|
containerClassName="w-44"
|
||||||
|
readOnly={categoryData?.code === 'spotlight'}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
id="description"
|
id="description"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { InputFile } from '~/components/ui/input-file'
|
|||||||
import { Switch } from '~/components/ui/switch'
|
import { Switch } from '~/components/ui/switch'
|
||||||
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
||||||
import type { loader } from '~/routes/_admin.lg-admin._dashboard'
|
import type { loader } from '~/routes/_admin.lg-admin._dashboard'
|
||||||
|
import { dateInput } from '~/utils/formatter'
|
||||||
|
|
||||||
export const contentSchema = z.object({
|
export const contentSchema = z.object({
|
||||||
id: z.string().optional(),
|
id: z.string().optional(),
|
||||||
@@ -30,7 +31,7 @@ export const contentSchema = z.object({
|
|||||||
.nullable(),
|
.nullable(),
|
||||||
)
|
)
|
||||||
.refine((data) => data.length, {
|
.refine((data) => data.length, {
|
||||||
message: 'Please select a category',
|
message: 'Pilih kategori',
|
||||||
}),
|
}),
|
||||||
tags: z
|
tags: z
|
||||||
.array(
|
.array(
|
||||||
@@ -45,17 +46,17 @@ export const contentSchema = z.object({
|
|||||||
)
|
)
|
||||||
.optional(),
|
.optional(),
|
||||||
title: z.string().min(1, {
|
title: z.string().min(1, {
|
||||||
message: 'Judul is required',
|
message: 'Wajib diisi',
|
||||||
}),
|
}),
|
||||||
content: z.string().min(1, {
|
content: z.string().min(1, {
|
||||||
message: 'Konten is required',
|
message: 'Wajib diisi',
|
||||||
}),
|
}),
|
||||||
featured_image: z.string().url({
|
featured_image: z.string().url({
|
||||||
message: 'Gambar Unggulan must be a valid URL',
|
message: 'URL tidak valid',
|
||||||
}),
|
}),
|
||||||
is_premium: z.boolean().optional(),
|
is_premium: z.boolean().optional(),
|
||||||
live_at: z.string().min(1, {
|
live_at: z.string().min(1, {
|
||||||
message: 'Tanggal live is required',
|
message: 'Pilih tanggal',
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -86,9 +87,7 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
content: newsData?.content || '',
|
content: newsData?.content || '',
|
||||||
featured_image: newsData?.featured_image || '',
|
featured_image: newsData?.featured_image || '',
|
||||||
is_premium: newsData?.is_premium || false,
|
is_premium: newsData?.is_premium || false,
|
||||||
live_at: newsData?.live_at
|
live_at: newsData?.live_at ? dateInput(newsData.live_at) : '',
|
||||||
? new Date(newsData.live_at).toISOString().split('T')[0]
|
|
||||||
: '',
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -97,15 +96,13 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
const watchTags = watch('tags')
|
const watchTags = watch('tags')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fetcher.data?.success === false) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
toast.error(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fetcher.data?.success === true) {
|
if (fetcher.data?.success) {
|
||||||
toast.success(`Artikel berhasil ${newsData ? 'diupdate' : 'dibuat'}!`)
|
toast.success(`Artikel berhasil ${newsData ? 'diupdate' : 'dibuat'}!`)
|
||||||
navigate('/lg-admin/contents')
|
navigate('/lg-admin/contents')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher.data])
|
}, [fetcher.data])
|
||||||
@@ -129,7 +126,6 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
||||||
labelClassName="text-sm font-medium text-[#363636]"
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
containerClassName="flex-1"
|
containerClassName="flex-1"
|
||||||
disabled={!!newsData}
|
|
||||||
/>
|
/>
|
||||||
<InputFile
|
<InputFile
|
||||||
id="featured_image"
|
id="featured_image"
|
||||||
@@ -148,7 +144,7 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] rounded-md"
|
className="text-md h-[42px] rounded-md"
|
||||||
>
|
>
|
||||||
Save
|
Simpan
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-end justify-between gap-4">
|
<div className="flex items-end justify-between gap-4">
|
||||||
@@ -158,7 +154,7 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
name="categories"
|
name="categories"
|
||||||
label="Kategori"
|
label="Kategori"
|
||||||
placeholder={
|
placeholder={
|
||||||
watchCategories
|
watchCategories?.length
|
||||||
? watchCategories.map((category) => category?.name).join(', ')
|
? watchCategories.map((category) => category?.name).join(', ')
|
||||||
: 'Pilih Kategori'
|
: 'Pilih Kategori'
|
||||||
}
|
}
|
||||||
@@ -171,11 +167,11 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
multiple
|
multiple
|
||||||
id="tags"
|
id="tags"
|
||||||
name="tags"
|
name="tags"
|
||||||
label="Tags"
|
label="Tag"
|
||||||
placeholder={
|
placeholder={
|
||||||
watchTags
|
watchTags?.length
|
||||||
? watchTags.map((tag) => tag?.name).join(', ')
|
? watchTags.map((tag) => tag?.name).join(', ')
|
||||||
: 'Pilih Tags'
|
: 'Pilih Tag'
|
||||||
}
|
}
|
||||||
options={tags}
|
options={tags}
|
||||||
className="border-0 bg-white shadow focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none"
|
className="border-0 bg-white shadow focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none"
|
||||||
@@ -184,7 +180,7 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
id="live_at"
|
id="live_at"
|
||||||
label="Tanggal Live"
|
label="Mulai Tayang"
|
||||||
placeholder="Pilih Tanggal"
|
placeholder="Pilih Tanggal"
|
||||||
name="live_at"
|
name="live_at"
|
||||||
type="date"
|
type="date"
|
||||||
@@ -194,10 +190,10 @@ export const FormContentsPage = (properties: TProperties) => {
|
|||||||
<Switch
|
<Switch
|
||||||
id="is_premium"
|
id="is_premium"
|
||||||
name="is_premium"
|
name="is_premium"
|
||||||
label="Subscription"
|
label="Tipe Langganan"
|
||||||
labelClassName="text-sm font-medium text-[#363636]"
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
className="h-[42px]"
|
className="h-[42px]"
|
||||||
options={{ true: 'Premium', false: 'Normal' }}
|
options={{ true: 'Premium', false: 'Biasa' }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
|
import { useFetcher, useNavigate } from 'react-router'
|
||||||
|
import { RemixFormProvider, useRemixForm } from 'remix-hook-form'
|
||||||
|
import { z } from 'zod'
|
||||||
|
|
||||||
|
import { Button } from '~/components/ui/button'
|
||||||
|
import { Input } from '~/components/ui/input'
|
||||||
|
import { InputFile } from '~/components/ui/input-file'
|
||||||
|
import { TitleDashboard } from '~/components/ui/title-dashboard'
|
||||||
|
|
||||||
|
export const staffSchema = z
|
||||||
|
.object({
|
||||||
|
profile_picture: z
|
||||||
|
.string()
|
||||||
|
.url({
|
||||||
|
message: 'URL tidak valid',
|
||||||
|
})
|
||||||
|
.or(z.literal('')),
|
||||||
|
name: z.string().min(1, {
|
||||||
|
message: 'Wajib diisi',
|
||||||
|
}),
|
||||||
|
password: z.string().min(6, 'Minimal 6 karakter'),
|
||||||
|
rePassword: z.string().min(6, 'Minimal 6 karakter'),
|
||||||
|
email: z.string().email('Email tidak valid'),
|
||||||
|
})
|
||||||
|
.refine((field) => field.password === field.rePassword, {
|
||||||
|
message: 'Kata sandi tidak sama',
|
||||||
|
path: ['rePassword'],
|
||||||
|
})
|
||||||
|
export type TStaffSchema = z.infer<typeof staffSchema>
|
||||||
|
|
||||||
|
export const FormStaffPage = () => {
|
||||||
|
const fetcher = useFetcher()
|
||||||
|
const navigate = useNavigate()
|
||||||
|
const formMethods = useRemixForm<TStaffSchema>({
|
||||||
|
mode: 'onSubmit',
|
||||||
|
fetcher,
|
||||||
|
resolver: zodResolver(staffSchema),
|
||||||
|
})
|
||||||
|
|
||||||
|
const { handleSubmit } = formMethods
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
|
toast.error(fetcher.data.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fetcher.data?.success) {
|
||||||
|
toast.success(`Staff berhasil dibuat!`)
|
||||||
|
navigate('/lg-admin/staffs')
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [fetcher.data])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="relative">
|
||||||
|
<TitleDashboard title={`Buat Staf`} />
|
||||||
|
<div>
|
||||||
|
<RemixFormProvider {...formMethods}>
|
||||||
|
<fetcher.Form
|
||||||
|
method="post"
|
||||||
|
onSubmit={handleSubmit}
|
||||||
|
action={`/actions/admin/staffs/create`}
|
||||||
|
className="space-y-4"
|
||||||
|
>
|
||||||
|
<div className="flex items-end justify-between gap-4">
|
||||||
|
<Input
|
||||||
|
id="name"
|
||||||
|
label="Nama Staf"
|
||||||
|
placeholder="Masukkan nama staf"
|
||||||
|
name="name"
|
||||||
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
||||||
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
|
containerClassName="flex-1"
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
id="email"
|
||||||
|
label="Email"
|
||||||
|
placeholder="Contoh: legal@legalgo.id"
|
||||||
|
name="email"
|
||||||
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
||||||
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
|
containerClassName="flex-1"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
isLoading={fetcher.state !== 'idle'}
|
||||||
|
disabled={fetcher.state !== 'idle'}
|
||||||
|
type="submit"
|
||||||
|
size="lg"
|
||||||
|
className="text-md h-[42px] rounded-md"
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-end justify-between gap-4">
|
||||||
|
<Input
|
||||||
|
id="password"
|
||||||
|
label="Kata Sandi"
|
||||||
|
placeholder="Masukkan Kata Sandi"
|
||||||
|
name="password"
|
||||||
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
||||||
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
|
containerClassName="flex-1"
|
||||||
|
type="password"
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
id="re-password"
|
||||||
|
label="Ulangi Kata Sandi"
|
||||||
|
placeholder="Masukkan Kata Sandi"
|
||||||
|
name="rePassword"
|
||||||
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
||||||
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
|
containerClassName="flex-1"
|
||||||
|
type="password"
|
||||||
|
/>
|
||||||
|
<InputFile
|
||||||
|
id="profile_picture"
|
||||||
|
label="Gambar Profil"
|
||||||
|
placeholder="Unggah gambar profil Anda"
|
||||||
|
name="profile_picture"
|
||||||
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
||||||
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
|
containerClassName="flex-1"
|
||||||
|
category="profile_picture"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</fetcher.Form>
|
||||||
|
</RemixFormProvider>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -15,11 +15,11 @@ import { urlFriendlyCode } from '~/utils/formatter'
|
|||||||
|
|
||||||
export const subscribePlanSchema = z.object({
|
export const subscribePlanSchema = z.object({
|
||||||
id: z.string().optional(),
|
id: z.string().optional(),
|
||||||
name: z.string().min(3, 'Nama minimal 3 karakter'),
|
name: z.string().min(3, 'Minimal 3 karakter'),
|
||||||
code: z.string(),
|
code: z.string(),
|
||||||
length: z.preprocess(Number, z.number().min(1, 'Length minimal 1')),
|
length: z.preprocess(Number, z.number().min(1, 'Durasi minimal 1')),
|
||||||
price: z.preprocess(Number, z.number().min(1, 'Harga minimal 1')),
|
price: z.preprocess(Number, z.number().min(1, 'Harga minimal 1')),
|
||||||
status: z.string().min(1, 'Status is required'),
|
status: z.string().min(1, 'Pilih status'),
|
||||||
})
|
})
|
||||||
export type TSubscribePlanSchema = z.infer<typeof subscribePlanSchema>
|
export type TSubscribePlanSchema = z.infer<typeof subscribePlanSchema>
|
||||||
type TProperties = {
|
type TProperties = {
|
||||||
@@ -48,17 +48,15 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
|
|||||||
const watchName = watch('name')
|
const watchName = watch('name')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fetcher.data?.success === false) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
toast.error(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fetcher.data?.success === true) {
|
if (fetcher.data?.success) {
|
||||||
toast.success(
|
toast.success(
|
||||||
`Subscribe Plan berhasil ${subscribePlanData ? 'diupdate' : 'dibuat'}!`,
|
`Paket Berlangganan berhasil ${subscribePlanData ? 'diupdate' : 'dibuat'}!`,
|
||||||
)
|
)
|
||||||
navigate('/lg-admin/subscribe-plan')
|
navigate('/lg-admin/subscribe-plan')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher.data])
|
}, [fetcher.data])
|
||||||
@@ -71,7 +69,7 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
|
|||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<TitleDashboard
|
<TitleDashboard
|
||||||
title={`${subscribePlanData ? 'Update' : 'Buat'} Subscribe Plan`}
|
title={`${subscribePlanData ? 'Update' : 'Buat'} Paket Berlangganan`}
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<RemixFormProvider {...formMethods}>
|
<RemixFormProvider {...formMethods}>
|
||||||
@@ -84,8 +82,8 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
|
|||||||
<div className="flex items-end justify-between gap-4">
|
<div className="flex items-end justify-between gap-4">
|
||||||
<Input
|
<Input
|
||||||
id="name"
|
id="name"
|
||||||
label="Subscribe Plan"
|
label="Paket Berlangganan"
|
||||||
placeholder="Masukkan Nama Subscribe Plan"
|
placeholder="Masukkan Nama Paket Berlangganan"
|
||||||
name="name"
|
name="name"
|
||||||
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
||||||
labelClassName="text-sm font-medium text-[#363636]"
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
@@ -94,7 +92,7 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
|
|||||||
<Input
|
<Input
|
||||||
id="code"
|
id="code"
|
||||||
label="Kode"
|
label="Kode"
|
||||||
placeholder="Masukkan Kode Subscribe Plan"
|
placeholder="Masukkan Kode Paket Berlangganan"
|
||||||
readOnly
|
readOnly
|
||||||
name="code"
|
name="code"
|
||||||
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none disabled:bg-gray-100"
|
||||||
@@ -108,15 +106,15 @@ export const FormSubscribePlanPage = (properties: TProperties) => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] rounded-md"
|
className="text-md h-[42px] rounded-md"
|
||||||
>
|
>
|
||||||
Save
|
Simpan
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-end justify-between gap-4">
|
<div className="flex items-end justify-between gap-4">
|
||||||
<Input
|
<Input
|
||||||
id="length"
|
id="length"
|
||||||
label="Length"
|
label="Durasi"
|
||||||
type="number"
|
type="number"
|
||||||
placeholder="Masukkan Subscribe Plan Length (days)"
|
placeholder="Masukkan Durasi Paket Berlangganan (hari)"
|
||||||
name="length"
|
name="length"
|
||||||
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none"
|
className="border-0 bg-white shadow read-only:bg-gray-100 focus:ring-1 focus:ring-[#2E2F7C] focus:outline-none"
|
||||||
labelClassName="text-sm font-medium text-[#363636]"
|
labelClassName="text-sm font-medium text-[#363636]"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { urlFriendlyCode } from '~/utils/formatter'
|
|||||||
|
|
||||||
export const tagSchema = z.object({
|
export const tagSchema = z.object({
|
||||||
id: z.string().optional(),
|
id: z.string().optional(),
|
||||||
name: z.string().min(3, 'Nama minimal 3 karakter'),
|
name: z.string().min(3, 'Minimal 3 karakter'),
|
||||||
code: z.string(),
|
code: z.string(),
|
||||||
})
|
})
|
||||||
export type TTagSchema = z.infer<typeof tagSchema>
|
export type TTagSchema = z.infer<typeof tagSchema>
|
||||||
@@ -40,15 +40,13 @@ export const FormTagPage = (properties: TProperties) => {
|
|||||||
const watchName = watch('name')
|
const watchName = watch('name')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fetcher.data?.success === false) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
toast.error(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fetcher.data?.success === true) {
|
if (fetcher.data?.success) {
|
||||||
toast.success(`Tag berhasil ${tagData ? 'diupdate' : 'dibuat'}!`)
|
toast.success(`Tag berhasil ${tagData ? 'diupdate' : 'dibuat'}!`)
|
||||||
navigate('/lg-admin/tags')
|
navigate('/lg-admin/tags')
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher.data])
|
}, [fetcher.data])
|
||||||
@@ -96,7 +94,7 @@ export const FormTagPage = (properties: TProperties) => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
className="text-md h-[42px] rounded-md"
|
className="text-md h-[42px] rounded-md"
|
||||||
>
|
>
|
||||||
Save
|
Simpan
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</fetcher.Form>
|
</fetcher.Form>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export const NewsCategoriesPage = () => {
|
|||||||
<CategorySection
|
<CategorySection
|
||||||
title={name || ''}
|
title={name || ''}
|
||||||
description={description || ''}
|
description={description || ''}
|
||||||
items={newsData || []}
|
items={newsData || Promise.resolve({ data: [] })}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,27 +1,32 @@
|
|||||||
import htmlParse from 'html-react-parser'
|
import htmlParse from 'html-react-parser'
|
||||||
import { useReadingTime } from 'react-hook-reading-time'
|
import { useReadingTime } from 'react-hook-reading-time'
|
||||||
import { useRouteLoaderData } from 'react-router'
|
import { useRouteLoaderData } from 'react-router'
|
||||||
|
import { twMerge } from 'tailwind-merge'
|
||||||
|
|
||||||
|
import { Button } from '~/components/ui/button'
|
||||||
import { Card } from '~/components/ui/card'
|
import { Card } from '~/components/ui/card'
|
||||||
import { CarouselSection } from '~/components/ui/carousel-section'
|
import { CarouselSection } from '~/components/ui/carousel-section'
|
||||||
import { NewsAuthor } from '~/components/ui/news-author'
|
import { NewsAuthor } from '~/components/ui/news-author'
|
||||||
import { SocialShareButtons } from '~/components/ui/social-share'
|
import { SocialShareButtons } from '~/components/ui/social-share'
|
||||||
import { Tags } from '~/components/ui/tags'
|
import { Tags } from '~/components/ui/tags'
|
||||||
|
import { useNewsContext } from '~/contexts/news'
|
||||||
import type { loader } from '~/routes/_news.detail.$slug'
|
import type { loader } from '~/routes/_news.detail.$slug'
|
||||||
import type { TNews } from '~/types/news'
|
import type { TNews } from '~/types/news'
|
||||||
|
|
||||||
export const NewsDetailPage = () => {
|
export const NewsDetailPage = () => {
|
||||||
|
const { setIsSuccessOpen } = useNewsContext()
|
||||||
const loaderData = useRouteLoaderData<typeof loader>(
|
const loaderData = useRouteLoaderData<typeof loader>(
|
||||||
'routes/_news.detail.$slug',
|
'routes/_news.detail.$slug',
|
||||||
)
|
)
|
||||||
const berita: TNews = {
|
const berita: TNews = {
|
||||||
title: loaderData?.beritaCategory?.name || '',
|
title: loaderData?.beritaCategory?.name || '',
|
||||||
description: loaderData?.beritaCategory?.description || '',
|
description: loaderData?.beritaCategory?.description || '',
|
||||||
items: loaderData?.beritaNews || [],
|
items: loaderData?.beritaData || Promise.resolve({ data: [] }),
|
||||||
}
|
}
|
||||||
const currentUrl = globalThis.location
|
const currentUrl = globalThis.location
|
||||||
const { title, content, featured_image, author, live_at, tags } =
|
const { title, content, featured_image, author, live_at, tags } =
|
||||||
loaderData?.newsDetailData || {}
|
loaderData?.newsDetailData || {}
|
||||||
|
const { shouldSubscribe } = loaderData || {}
|
||||||
|
|
||||||
const { text } = useReadingTime(content || '')
|
const { text } = useReadingTime(content || '')
|
||||||
|
|
||||||
@@ -51,10 +56,23 @@ export const NewsDetailPage = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-8 flex items-center justify-center">
|
<div className="mt-8 flex flex-col items-center justify-center gap-y-4">
|
||||||
<article className="prose prose-headings:my-0.5 prose-p:my-0.5">
|
<article
|
||||||
|
className={twMerge(
|
||||||
|
'prose prose-headings:my-0.5 prose-p:my-0.5',
|
||||||
|
shouldSubscribe ? 'line-clamp-5' : '',
|
||||||
|
)}
|
||||||
|
>
|
||||||
{content && htmlParse(content)}
|
{content && htmlParse(content)}
|
||||||
</article>
|
</article>
|
||||||
|
{shouldSubscribe && (
|
||||||
|
<Button
|
||||||
|
onClick={() => setIsSuccessOpen('warning')}
|
||||||
|
className="w-full"
|
||||||
|
>
|
||||||
|
Read More
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="items-end justify-between border-b-gray-300 py-4 sm:flex">
|
<div className="items-end justify-between border-b-gray-300 py-4 sm:flex">
|
||||||
<div className="flex flex-col max-sm:mb-3">
|
<div className="flex flex-col max-sm:mb-3">
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { useRouteLoaderData } from 'react-router'
|
||||||
|
|
||||||
|
import { Card } from '~/components/ui/card'
|
||||||
|
import { CategorySection } from '~/components/ui/category-section'
|
||||||
|
import type { loader } from '~/routes/_news.search'
|
||||||
|
|
||||||
|
export const NewsSearchPage = () => {
|
||||||
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_news.search')
|
||||||
|
const { newsData, query } = loaderData || {}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="relative">
|
||||||
|
<Card>
|
||||||
|
<CategorySection
|
||||||
|
title="Hasil pencarian:"
|
||||||
|
description={query || ''}
|
||||||
|
items={newsData || Promise.resolve({ data: [] })}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import { Card } from '~/components/ui/card'
|
|||||||
import { CarouselHero } from '~/components/ui/carousel-hero'
|
import { CarouselHero } from '~/components/ui/carousel-hero'
|
||||||
import { CarouselSection } from '~/components/ui/carousel-section'
|
import { CarouselSection } from '~/components/ui/carousel-section'
|
||||||
import { Newsletter } from '~/components/ui/newsletter'
|
import { Newsletter } from '~/components/ui/newsletter'
|
||||||
import type { loader } from '~/routes/_news._index'
|
import { type loader } from '~/routes/_news._index'
|
||||||
import type { TNews } from '~/types/news'
|
import type { TNews } from '~/types/news'
|
||||||
|
|
||||||
export const NewsPage = () => {
|
export const NewsPage = () => {
|
||||||
@@ -12,17 +12,17 @@ export const NewsPage = () => {
|
|||||||
const spotlight: TNews = {
|
const spotlight: TNews = {
|
||||||
title: loaderData?.spotlightCategory?.name || '',
|
title: loaderData?.spotlightCategory?.name || '',
|
||||||
description: loaderData?.spotlightCategory?.description || '',
|
description: loaderData?.spotlightCategory?.description || '',
|
||||||
items: loaderData?.spotlightNews || [],
|
items: loaderData?.spotlightData || Promise.resolve({ data: [] }),
|
||||||
}
|
}
|
||||||
const berita: TNews = {
|
const berita: TNews = {
|
||||||
title: loaderData?.beritaCategory?.name || '',
|
title: loaderData?.beritaCategory?.name || '',
|
||||||
description: loaderData?.beritaCategory?.description || '',
|
description: loaderData?.beritaCategory?.description || '',
|
||||||
items: loaderData?.beritaNews || [],
|
items: loaderData?.beritaData || Promise.resolve({ data: [] }),
|
||||||
}
|
}
|
||||||
const kajian: TNews = {
|
const kajian: TNews = {
|
||||||
title: loaderData?.kajianCategory?.name || '',
|
title: loaderData?.kajianCategory?.name || '',
|
||||||
description: loaderData?.kajianCategory?.description || '',
|
description: loaderData?.kajianCategory?.description || '',
|
||||||
items: loaderData?.kajianNews || [],
|
items: loaderData?.kajianData || Promise.resolve({ data: [] }),
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { zodResolver } from '@hookform/resolvers/zod'
|
import { zodResolver } from '@hookform/resolvers/zod'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect } from 'react'
|
||||||
|
import toast from 'react-hot-toast'
|
||||||
import { Link, useFetcher } from 'react-router'
|
import { Link, 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'
|
||||||
@@ -10,7 +11,7 @@ import { APP } from '~/configs/meta'
|
|||||||
|
|
||||||
export const loginSchema = z.object({
|
export const loginSchema = z.object({
|
||||||
email: z.string().email('Email tidak valid'),
|
email: z.string().email('Email tidak valid'),
|
||||||
password: z.string().min(6, 'Kata sandi minimal 6 karakter'),
|
password: z.string().min(6, 'Minimal 6 karakter'),
|
||||||
})
|
})
|
||||||
|
|
||||||
export type TLoginSchema = z.infer<typeof loginSchema>
|
export type TLoginSchema = z.infer<typeof loginSchema>
|
||||||
@@ -22,17 +23,15 @@ export const AdminLoginPage = () => {
|
|||||||
fetcher,
|
fetcher,
|
||||||
resolver: zodResolver(loginSchema),
|
resolver: zodResolver(loginSchema),
|
||||||
})
|
})
|
||||||
const [error, setError] = useState<string>()
|
|
||||||
|
|
||||||
const { handleSubmit } = formMethods
|
const { handleSubmit } = formMethods
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fetcher.data?.success) {
|
if (!fetcher.data?.success && fetcher.data?.message) {
|
||||||
setError(fetcher.data?.message)
|
toast.error(fetcher.data.message)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [fetcher])
|
}, [fetcher.data])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-dvh min-w-dvw flex-col items-center justify-center space-y-8">
|
<div className="flex min-h-dvh min-w-dvw flex-col items-center justify-center space-y-8">
|
||||||
@@ -72,10 +71,6 @@ export const AdminLoginPage = () => {
|
|||||||
type="password"
|
type="password"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{error && (
|
|
||||||
<div className="text-sm text-red-500 capitalize">{error}</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* 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>
|
||||||
|
|||||||
+3
-3
@@ -23,9 +23,9 @@ export const links: Route.LinksFunction = () => [
|
|||||||
|
|
||||||
export const meta = ({ location }: Route.MetaArgs) => {
|
export const meta = ({ location }: Route.MetaArgs) => {
|
||||||
const { pathname } = location
|
const { pathname } = location
|
||||||
const pageTitle = META_TITLE_CONFIG.find(
|
const segments = pathname.split('/')
|
||||||
(meta) => meta.path === pathname,
|
const path = segments.length > 4 ? segments.slice(0, 4).join('/') : pathname
|
||||||
)?.title
|
const pageTitle = META_TITLE_CONFIG.find((meta) => meta.path === path)?.title
|
||||||
const metaTitle = APP.title
|
const metaTitle = APP.title
|
||||||
const title = `${pageTitle ? `${pageTitle} - ` : ''}${metaTitle}`
|
const title = `${pageTitle ? `${pageTitle} - ` : ''}${metaTitle}`
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import type { Route } from './+types/_admin.lg-admin._dashboard.advertisements.u
|
|||||||
export const loader = async ({ params }: Route.LoaderArgs) => {
|
export const loader = async ({ params }: Route.LoaderArgs) => {
|
||||||
const { data: adsData } = await getAds()
|
const { data: adsData } = await getAds()
|
||||||
const { id } = params
|
const { id } = params
|
||||||
const adData = adsData.find((ads) => ads.id === id)
|
const adData = adsData?.find((ads) => ads.id === id)
|
||||||
return { adData }
|
return { adData }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,15 +1,15 @@
|
|||||||
import { isRouteErrorResponse } from 'react-router'
|
import { isRouteErrorResponse } from 'react-router'
|
||||||
|
|
||||||
import { getNewsBySlug } from '~/apis/common/get-news-by-slug'
|
import { getNewsById } from '~/apis/admin/get-news-by-id'
|
||||||
import { handleCookie } from '~/libs/cookies'
|
import { handleCookie } from '~/libs/cookies'
|
||||||
import { FormContentsPage } from '~/pages/form-contents'
|
import { FormContentsPage } from '~/pages/form-contents'
|
||||||
|
|
||||||
import type { Route } from './+types/_admin.lg-admin._dashboard.contents.update.$slug'
|
import type { Route } from './+types/_admin.lg-admin._dashboard.contents.update.$id'
|
||||||
|
|
||||||
export const loader = async ({ request, params }: Route.LoaderArgs) => {
|
export const loader = async ({ request, params }: Route.LoaderArgs) => {
|
||||||
const { staffToken: accessToken } = await handleCookie(request)
|
const { staffToken: accessToken } = await handleCookie(request)
|
||||||
const { slug } = params
|
const { id } = params
|
||||||
const { data: newsData } = await getNewsBySlug({ accessToken, slug })
|
const { data: newsData } = await getNewsById({ accessToken, id })
|
||||||
return { newsData }
|
return { newsData }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { isRouteErrorResponse } from 'react-router'
|
||||||
|
|
||||||
|
import { getStaffs } from '~/apis/admin/get-staffs'
|
||||||
|
import { handleCookie } from '~/libs/cookies'
|
||||||
|
import { StaffsPage } from '~/pages/dashboard-staffs'
|
||||||
|
|
||||||
|
import type { Route } from './+types/_admin.lg-admin._dashboard.staffs._index'
|
||||||
|
|
||||||
|
export const loader = async ({ request }: Route.LoaderArgs) => {
|
||||||
|
const { staffToken: accessToken } = await handleCookie(request)
|
||||||
|
const { data: staffsData } = await getStaffs({ accessToken })
|
||||||
|
|
||||||
|
return { staffsData }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ErrorBoundary = ({ error }: Route.ErrorBoundaryProps) => {
|
||||||
|
let message = 'Oops!'
|
||||||
|
let details = 'An unexpected error occurred.'
|
||||||
|
let stack: string | undefined
|
||||||
|
|
||||||
|
if (isRouteErrorResponse(error)) {
|
||||||
|
message = error.status === 404 ? '404' : 'Error'
|
||||||
|
details =
|
||||||
|
error.status === 404
|
||||||
|
? 'The requested page could not be found.'
|
||||||
|
: error.statusText || details
|
||||||
|
} else if (import.meta.env.DEV && error && error instanceof Error) {
|
||||||
|
details = error.message
|
||||||
|
stack = error.stack
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container mx-auto p-4">
|
||||||
|
<h1>{message}</h1>
|
||||||
|
<p>{details}</p>
|
||||||
|
{stack && (
|
||||||
|
<pre className="w-full p-4 whitespace-pre-wrap">
|
||||||
|
<code>{stack}</code>
|
||||||
|
</pre>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const DashboardStaffsLayout = () => <StaffsPage />
|
||||||
|
export default DashboardStaffsLayout
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { FormStaffPage } from '~/pages/form-staff'
|
||||||
|
|
||||||
|
const DashboardStaffsCreateLayout = () => <FormStaffPage />
|
||||||
|
export default DashboardStaffsCreateLayout
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
import { isRouteErrorResponse, Outlet, redirect } from 'react-router'
|
import { isRouteErrorResponse, Outlet, redirect } from 'react-router'
|
||||||
import { XiorError } from 'xior'
|
|
||||||
|
|
||||||
import { getStaff } from '~/apis/admin/get-staff'
|
import { getProfile } from '~/apis/admin/get-profile'
|
||||||
import { AUTH_PAGES } from '~/configs/pages'
|
import { AUTH_PAGES } from '~/configs/pages'
|
||||||
import { AdminDefaultLayout } from '~/layouts/admin/default'
|
import { AdminDefaultLayout } from '~/layouts/admin/default'
|
||||||
import { handleCookie } from '~/libs/cookies'
|
import { handleCookie } from '~/libs/cookies'
|
||||||
import { setStaffLogoutHeaders } from '~/libs/logout-header.server'
|
|
||||||
|
|
||||||
import type { Route } from './+types/_admin.lg-admin'
|
import type { Route } from './+types/_admin.lg-admin'
|
||||||
|
|
||||||
@@ -16,14 +14,8 @@ export const loader = async ({ request }: Route.LoaderArgs) => {
|
|||||||
let staffData
|
let staffData
|
||||||
|
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
try {
|
const { data } = await getProfile({ accessToken })
|
||||||
const { data } = await getStaff({ accessToken })
|
|
||||||
staffData = data
|
staffData = data
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof XiorError && error.response?.status === 401) {
|
|
||||||
setStaffLogoutHeaders()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isAuthPage && !accessToken) {
|
if (!isAuthPage && !accessToken) {
|
||||||
|
|||||||
+27
-16
@@ -2,6 +2,7 @@ import { isRouteErrorResponse } from 'react-router'
|
|||||||
|
|
||||||
import { getCategories } from '~/apis/common/get-categories'
|
import { getCategories } from '~/apis/common/get-categories'
|
||||||
import { getNews } from '~/apis/common/get-news'
|
import { getNews } from '~/apis/common/get-news'
|
||||||
|
import { Card } from '~/components/ui/card'
|
||||||
import { NewsPage } from '~/pages/news'
|
import { NewsPage } from '~/pages/news'
|
||||||
|
|
||||||
import type { Route } from './+types/_news._index'
|
import type { Route } from './+types/_news._index'
|
||||||
@@ -13,32 +14,36 @@ export const loader = async ({}: Route.LoaderArgs) => {
|
|||||||
const spotlightCategory = categoriesData.find(
|
const spotlightCategory = categoriesData.find(
|
||||||
(category) => category.code === spotlightCode,
|
(category) => category.code === spotlightCode,
|
||||||
)
|
)
|
||||||
let { data: spotlightNews } = await getNews({ categories: [spotlightCode] })
|
|
||||||
spotlightNews = spotlightNews.filter(
|
|
||||||
(news) => new Date(news.live_at) <= new Date(),
|
|
||||||
)
|
|
||||||
|
|
||||||
const beritaCode = 'berita'
|
const beritaCode = 'berita'
|
||||||
const beritaCategory = categoriesData.find(
|
const beritaCategory = categoriesData.find(
|
||||||
(category) => category.code === beritaCode,
|
(category) => category.code === beritaCode,
|
||||||
)
|
)
|
||||||
let { data: beritaNews } = await getNews({ categories: [beritaCode] })
|
|
||||||
beritaNews = beritaNews.filter((news) => new Date(news.live_at) <= new Date())
|
|
||||||
|
|
||||||
const kajianCode = 'kajian'
|
const kajianCode = 'kajian'
|
||||||
const kajianCategory = categoriesData.find(
|
const kajianCategory = categoriesData.find(
|
||||||
(category) => category.code === kajianCode,
|
(category) => category.code === kajianCode,
|
||||||
)
|
)
|
||||||
let { data: kajianNews } = await getNews({ categories: [kajianCode] })
|
|
||||||
kajianNews = kajianNews.filter((news) => new Date(news.live_at) <= new Date())
|
|
||||||
|
|
||||||
|
const spotlightData = getNews({
|
||||||
|
categories: [spotlightCode],
|
||||||
|
active: true,
|
||||||
|
})
|
||||||
|
const beritaData = getNews({
|
||||||
|
categories: [beritaCode],
|
||||||
|
active: true,
|
||||||
|
})
|
||||||
|
const kajianData = getNews({
|
||||||
|
categories: [kajianCode],
|
||||||
|
active: true,
|
||||||
|
})
|
||||||
return {
|
return {
|
||||||
spotlightCategory,
|
spotlightCategory,
|
||||||
spotlightNews,
|
|
||||||
beritaCategory,
|
beritaCategory,
|
||||||
beritaNews,
|
|
||||||
kajianCategory,
|
kajianCategory,
|
||||||
kajianNews,
|
spotlightData,
|
||||||
|
beritaData,
|
||||||
|
kajianData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,15 +64,21 @@ export const ErrorBoundary = ({ error }: Route.ErrorBoundaryProps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto p-4">
|
<Card>
|
||||||
<h1>{message}</h1>
|
<div className="mt-3 mb-3 grid items-center justify-between border-b border-black pb-3 sm:mb-[30px] sm:pb-[30px]">
|
||||||
<p>{details}</p>
|
<h2 className="text-2xl font-extrabold text-[#2E2F7C] sm:text-4xl">
|
||||||
|
{message}
|
||||||
|
</h2>
|
||||||
|
<p className="text-xl font-light text-[#777777] italic sm:text-2xl">
|
||||||
|
{details}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
{stack && (
|
{stack && (
|
||||||
<pre className="w-full p-4 whitespace-pre-wrap">
|
<pre className="w-full whitespace-pre-wrap">
|
||||||
<code>{stack}</code>
|
<code>{stack}</code>
|
||||||
</pre>
|
</pre>
|
||||||
)}
|
)}
|
||||||
</div>
|
</Card>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ export const loader = async ({ params }: Route.LoaderArgs) => {
|
|||||||
const { data: categoriesData } = await getCategories()
|
const { data: categoriesData } = await getCategories()
|
||||||
const { code } = params
|
const { code } = params
|
||||||
const categoryData = categoriesData.find((category) => category.code === code)
|
const categoryData = categoriesData.find((category) => category.code === code)
|
||||||
let { data: newsData } = await getNews({ categories: [code] })
|
const newsData = getNews({ categories: [code], active: true })
|
||||||
newsData = newsData.filter((news) => new Date(news.live_at) <= new Date())
|
|
||||||
return { categoryData, newsData }
|
return { categoryData, newsData }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import { isRouteErrorResponse } from 'react-router'
|
import { isRouteErrorResponse } from 'react-router'
|
||||||
|
import { getClientIPAddress } from 'remix-utils/get-client-ip-address'
|
||||||
|
import { stripHtml } from 'string-strip-html'
|
||||||
|
|
||||||
import { getCategories } from '~/apis/common/get-categories'
|
import { getCategories } from '~/apis/common/get-categories'
|
||||||
import { getNews } from '~/apis/common/get-news'
|
import { getNews } from '~/apis/common/get-news'
|
||||||
import { getNewsBySlug } from '~/apis/common/get-news-by-slug'
|
import { getNewsBySlug } from '~/apis/news/get-news-by-slug'
|
||||||
|
import { getUser } from '~/apis/news/get-user'
|
||||||
import { APP } from '~/configs/meta'
|
import { APP } from '~/configs/meta'
|
||||||
import { handleCookie } from '~/libs/cookies'
|
import { handleCookie } from '~/libs/cookies'
|
||||||
import { NewsDetailPage } from '~/pages/news-detail'
|
import { NewsDetailPage } from '~/pages/news-detail'
|
||||||
@@ -10,28 +13,49 @@ import { NewsDetailPage } from '~/pages/news-detail'
|
|||||||
import type { Route } from './+types/_news.detail.$slug'
|
import type { Route } from './+types/_news.detail.$slug'
|
||||||
|
|
||||||
export const loader = async ({ request, params }: Route.LoaderArgs) => {
|
export const loader = async ({ request, params }: Route.LoaderArgs) => {
|
||||||
|
const userAgent = request.headers.get('user-agent')
|
||||||
|
const ipAddress = getClientIPAddress(request) || 'localhost'
|
||||||
const { userToken: accessToken } = await handleCookie(request)
|
const { userToken: accessToken } = await handleCookie(request)
|
||||||
|
let userData
|
||||||
|
if (accessToken) {
|
||||||
|
const { data } = await getUser({ accessToken })
|
||||||
|
userData = data
|
||||||
|
}
|
||||||
const { slug } = params
|
const { slug } = params
|
||||||
const { data: newsDetailData } = await getNewsBySlug({ slug, accessToken })
|
let { data: newsDetailData } = await getNewsBySlug({
|
||||||
|
slug,
|
||||||
|
accessToken,
|
||||||
|
userAgent,
|
||||||
|
ipAddress,
|
||||||
|
})
|
||||||
|
const shouldSubscribe =
|
||||||
|
(!accessToken || userData?.subscribe?.subscribe_plan?.code === 'basic') &&
|
||||||
|
newsDetailData?.is_premium
|
||||||
|
newsDetailData = {
|
||||||
|
...newsDetailData,
|
||||||
|
content: shouldSubscribe
|
||||||
|
? stripHtml(newsDetailData.content).result.slice(0, 600)
|
||||||
|
: newsDetailData.content,
|
||||||
|
}
|
||||||
const { data: categoriesData } = await getCategories()
|
const { data: categoriesData } = await getCategories()
|
||||||
const beritaCode = 'berita'
|
const beritaCode = 'berita'
|
||||||
const beritaCategory = categoriesData.find(
|
const beritaCategory = categoriesData.find(
|
||||||
(category) => category.code === beritaCode,
|
(category) => category.code === beritaCode,
|
||||||
)
|
)
|
||||||
let { data: beritaNews } = await getNews({ categories: [beritaCode] })
|
const beritaData = getNews({ categories: [beritaCode], active: true })
|
||||||
beritaNews = beritaNews.filter((news) => new Date(news.live_at) <= new Date())
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
newsDetailData,
|
newsDetailData,
|
||||||
beritaCategory,
|
beritaCategory,
|
||||||
beritaNews,
|
beritaData,
|
||||||
|
shouldSubscribe,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const meta = ({ data }: Route.MetaArgs) => {
|
export const meta = ({ data }: Route.MetaArgs) => {
|
||||||
const { newsDetailData } = data
|
const { newsDetailData } = data || {}
|
||||||
const metaTitle = APP.title
|
const metaTitle = APP.title
|
||||||
const title = `${newsDetailData.title} - ${metaTitle}`
|
const title = `${newsDetailData?.title} - ${metaTitle}`
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import { isRouteErrorResponse } from 'react-router'
|
||||||
|
|
||||||
|
import { getNews } from '~/apis/common/get-news'
|
||||||
|
import { APP } from '~/configs/meta'
|
||||||
|
import { NewsSearchPage } from '~/pages/news-search'
|
||||||
|
|
||||||
|
import type { Route } from './+types/_news.search'
|
||||||
|
|
||||||
|
export const loader = async ({ request }: Route.LoaderArgs) => {
|
||||||
|
const url = new URL(request.url)
|
||||||
|
const query = url.searchParams.get('q') || ''
|
||||||
|
const newsData = getNews({ query, active: true })
|
||||||
|
return { query, newsData }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const meta = ({ data }: Route.MetaArgs) => {
|
||||||
|
const { query } = data
|
||||||
|
const metaTitle = APP.title
|
||||||
|
const title = `Pencarian: ${query} - ${metaTitle}`
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ErrorBoundary = ({ error }: Route.ErrorBoundaryProps) => {
|
||||||
|
let message = 'Oops!'
|
||||||
|
let details = 'An unexpected error occurred.'
|
||||||
|
let stack: string | undefined
|
||||||
|
|
||||||
|
if (isRouteErrorResponse(error)) {
|
||||||
|
message = error.status === 404 ? '404' : 'Error'
|
||||||
|
details =
|
||||||
|
error.status === 404
|
||||||
|
? 'The requested page could not be found.'
|
||||||
|
: error.statusText || details
|
||||||
|
} else if (import.meta.env.DEV && error && error instanceof Error) {
|
||||||
|
details = error.message
|
||||||
|
stack = error.stack
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container mx-auto p-4">
|
||||||
|
<h1>{message}</h1>
|
||||||
|
<p>{details}</p>
|
||||||
|
{stack && (
|
||||||
|
<pre className="w-full p-4 whitespace-pre-wrap">
|
||||||
|
<code>{stack}</code>
|
||||||
|
</pre>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const NewsSearchLayout = () => <NewsSearchPage />
|
||||||
|
|
||||||
|
export default NewsSearchLayout
|
||||||
@@ -28,11 +28,13 @@ export const loader = async ({ request }: Route.LoaderArgs) => {
|
|||||||
const { data: subscribePlanData } = await getSubscribePlan()
|
const { data: subscribePlanData } = await getSubscribePlan()
|
||||||
const { data: categoriesData } = await getCategories()
|
const { data: categoriesData } = await getCategories()
|
||||||
let { data: adsData } = await getAds()
|
let { data: adsData } = await getAds()
|
||||||
adsData = adsData.filter(
|
if (adsData) {
|
||||||
|
adsData = adsData?.filter(
|
||||||
(ad) =>
|
(ad) =>
|
||||||
new Date(ad.start_date) <= new Date() &&
|
new Date(ad.start_date) <= new Date() &&
|
||||||
new Date(ad.end_date) >= new Date(),
|
new Date(ad.end_date) >= new Date(),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
userData,
|
userData,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { XiorError } from 'xior'
|
|||||||
import { deleteAdsRequest } from '~/apis/admin/delete-ads'
|
import { deleteAdsRequest } from '~/apis/admin/delete-ads'
|
||||||
import { handleCookie } from '~/libs/cookies'
|
import { handleCookie } from '~/libs/cookies'
|
||||||
|
|
||||||
import type { Route } from './+types/actions.admin.advertisements.create'
|
import type { Route } from './+types/actions.admin.advertisements.delete.$id'
|
||||||
|
|
||||||
export const action = async ({ request, params }: Route.ActionArgs) => {
|
export const action = async ({ request, params }: Route.ActionArgs) => {
|
||||||
const { staffToken: accessToken } = await handleCookie(request)
|
const { staffToken: accessToken } = await handleCookie(request)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { updateAdsRequest } from '~/apis/admin/update-ads'
|
|||||||
import { handleCookie } from '~/libs/cookies'
|
import { handleCookie } from '~/libs/cookies'
|
||||||
import { adsSchema, type TAdsSchema } from '~/pages/form-advertisements'
|
import { adsSchema, type TAdsSchema } from '~/pages/form-advertisements'
|
||||||
|
|
||||||
import type { Route } from './+types/actions.admin.advertisements.create'
|
import type { Route } from './+types/actions.admin.advertisements.update'
|
||||||
|
|
||||||
export const action = async ({ request }: Route.ActionArgs) => {
|
export const action = async ({ request }: Route.ActionArgs) => {
|
||||||
const { staffToken: accessToken } = await handleCookie(request)
|
const { staffToken: accessToken } = await handleCookie(request)
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { data } from 'react-router'
|
||||||
|
import { XiorError } from 'xior'
|
||||||
|
|
||||||
|
import { deleteContentsRequest } from '~/apis/admin/delete-contents'
|
||||||
|
import { handleCookie } from '~/libs/cookies'
|
||||||
|
|
||||||
|
import type { Route } from './+types/actions.admin.contents.delete.$id'
|
||||||
|
|
||||||
|
export const action = async ({ request, params }: Route.ActionArgs) => {
|
||||||
|
const { staffToken: accessToken } = await handleCookie(request)
|
||||||
|
const { id } = params
|
||||||
|
try {
|
||||||
|
const { data: newsData } = await deleteContentsRequest({
|
||||||
|
accessToken,
|
||||||
|
id,
|
||||||
|
})
|
||||||
|
|
||||||
|
return data(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
newsData,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: 200,
|
||||||
|
statusText: 'OK',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof XiorError) {
|
||||||
|
return data(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: error?.response?.data?.error?.message || error.message,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: error?.response?.status || 500,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return data(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: 'Internal server error',
|
||||||
|
},
|
||||||
|
{ status: 500 },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user