diff --git a/app/apis/admin/update-tag.ts b/app/apis/admin/update-tag.ts index 71c0064..6e6da1f 100644 --- a/app/apis/admin/update-tag.ts +++ b/app/apis/admin/update-tag.ts @@ -15,10 +15,10 @@ type TParameters = { } export const updateTagRequest = async (parameters: TParameters) => { - const { accessToken, payload } = parameters + const { payload, ...restParameters } = parameters + const { id, ...restPayload } = payload try { - const { id, ...restPayload } = payload - const { data } = await HttpServer({ accessToken }).put( + const { data } = await HttpServer(restParameters).put( `/api/tag/${id}/update`, restPayload, ) diff --git a/app/apis/common/get-news-by-slug.ts b/app/apis/common/get-news-by-slug.ts index de39135..c676c7f 100644 --- a/app/apis/common/get-news-by-slug.ts +++ b/app/apis/common/get-news-by-slug.ts @@ -1,6 +1,6 @@ import { z } from 'zod' -import { newsResponseSchema } from '~/apis/admin/get-news' +import { newsResponseSchema } from '~/apis/common/get-news' import { HttpServer, type THttpServer } from '~/libs/http-server' const dataResponseSchema = z.object({ diff --git a/app/apis/admin/get-news.ts b/app/apis/common/get-news.ts similarity index 72% rename from app/apis/admin/get-news.ts rename to app/apis/common/get-news.ts index a6f5896..ab70020 100644 --- a/app/apis/admin/get-news.ts +++ b/app/apis/common/get-news.ts @@ -30,10 +30,20 @@ const dataResponseSchema = z.object({ export type TNewsResponse = z.infer export type TAuthor = z.infer +type TParameters = { + categories?: string[] + tags?: string[] +} & THttpServer -export const getNews = async (parameters: THttpServer) => { +export const getNews = async (parameters: TParameters) => { + const { categories, tags, ...restParameters } = parameters try { - const { data } = await HttpServer(parameters).get(`/api/news`) + const { data } = await HttpServer(restParameters).get(`/api/news`, { + params: { + ...(categories && { categories: categories.join('+') }), + ...(tags && { tags: tags.join('+') }), + }, + }) return dataResponseSchema.parse(data) } catch (error) { // eslint-disable-next-line unicorn/no-useless-promise-resolve-reject diff --git a/app/components/ui/card.tsx b/app/components/ui/card.tsx index b5ae5ec..3b0bc4d 100644 --- a/app/components/ui/card.tsx +++ b/app/components/ui/card.tsx @@ -3,11 +3,11 @@ import type { ComponentProps, FC, PropsWithChildren } from 'react' type TProperties = PropsWithChildren> export const Card: FC = (properties) => { - const { children, ...rest } = properties + const { children, ...restProperties } = properties return (
{children}
diff --git a/app/components/ui/combobox.tsx b/app/components/ui/combobox.tsx index d0fb882..e75d9ba 100644 --- a/app/components/ui/combobox.tsx +++ b/app/components/ui/combobox.tsx @@ -53,7 +53,7 @@ export const Combobox = >( className, labelClassName, containerClassName, - ...rest + ...restProperties } = properties const { control, @@ -88,7 +88,7 @@ export const Combobox = >( onChange={field.onChange} disabled={disabled} immediate - {...rest} + {...restProperties} >
>( className, containerClassName, labelClassName, - ...rest + ...restProperties } = properties const [inputType, setInputType] = useState(type) @@ -68,7 +68,7 @@ export const Input = >( )} placeholder={inputType === 'password' ? '******' : placeholder} {...register(name, rules)} - {...rest} + {...restProperties} /> {type === 'password' && (