apps/web: add type CreateUrl to utils/url
This commit is contained in:
parent
c7559a0adc
commit
5d8aecfeb0
@ -1,12 +1,11 @@
|
||||
import type * as t from './types';
|
||||
import { urls } from '@/config/urls';
|
||||
import type { makeCreateUrl } from '@/utils/url';
|
||||
import type { CreateUrl } from '@/utils/url';
|
||||
import type { WretchError } from 'wretch';
|
||||
import wretch from 'wretch';
|
||||
|
||||
const api = wretch(urls.URL_UIS).errorType('json');
|
||||
|
||||
type CreateUrl = ReturnType<typeof makeCreateUrl>;
|
||||
type Input = { createUrl: CreateUrl; payload?: unknown };
|
||||
|
||||
export async function getData({ createUrl }: Input) {
|
||||
|
||||
@ -4,6 +4,8 @@ export function getPageUrlParams({ params, searchParams }: PageProps) {
|
||||
return { path: `/${params.slug}`, urlSearchParams: new URLSearchParams(searchParams) };
|
||||
}
|
||||
|
||||
export type PageUrlParams = ReturnType<typeof getPageUrlParams>;
|
||||
|
||||
export function makeCreateUrl({ path, urlSearchParams }: ReturnType<typeof getPageUrlParams>) {
|
||||
return function (route: string) {
|
||||
if (urlSearchParams) return `${path}${route}?${urlSearchParams}`;
|
||||
@ -11,3 +13,5 @@ export function makeCreateUrl({ path, urlSearchParams }: ReturnType<typeof getPa
|
||||
return path + route;
|
||||
};
|
||||
}
|
||||
|
||||
export type CreateUrl = ReturnType<typeof makeCreateUrl>;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user