apps/web: add payload to api function type
This commit is contained in:
parent
d7d418db68
commit
c7559a0adc
@ -7,8 +7,9 @@ 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: CreateUrl) {
|
||||
export async function getData({ createUrl }: Input) {
|
||||
const url = createUrl('');
|
||||
|
||||
return api
|
||||
@ -17,7 +18,7 @@ export async function getData(createUrl: CreateUrl) {
|
||||
.then((res) => res);
|
||||
}
|
||||
|
||||
export async function getMetaData(createUrl: CreateUrl) {
|
||||
export async function getMetaData({ createUrl }: Input) {
|
||||
const url = createUrl('/meta');
|
||||
|
||||
return api
|
||||
@ -26,7 +27,7 @@ export async function getMetaData(createUrl: CreateUrl) {
|
||||
.then((res) => res);
|
||||
}
|
||||
|
||||
export async function getConfig(createUrl: CreateUrl) {
|
||||
export async function getConfig({ createUrl }: Input) {
|
||||
const url = createUrl('/config');
|
||||
|
||||
return api
|
||||
@ -35,7 +36,7 @@ export async function getConfig(createUrl: CreateUrl) {
|
||||
.then((res) => res);
|
||||
}
|
||||
|
||||
export async function getConditions(createUrl: CreateUrl) {
|
||||
export async function getConditions({ createUrl }: Input) {
|
||||
const url = createUrl('/conditions');
|
||||
|
||||
return api
|
||||
@ -44,7 +45,7 @@ export async function getConditions(createUrl: CreateUrl) {
|
||||
.then((res) => res);
|
||||
}
|
||||
|
||||
export async function validate(createUrl: CreateUrl) {
|
||||
export async function validate({ createUrl }: Input) {
|
||||
const url = createUrl('/validate');
|
||||
|
||||
return api
|
||||
|
||||
@ -10,7 +10,7 @@ import { Background } from 'ui';
|
||||
export async function generateMetadata(pageProps: PageProps): Promise<Metadata> {
|
||||
const pageUrlParams = getPageUrlParams(pageProps);
|
||||
const createUrl = makeCreateUrl(pageUrlParams);
|
||||
const { title } = await apiIUS.getConfig(createUrl);
|
||||
const { title } = await apiIUS.getConfig({ createUrl });
|
||||
const text = `Условия: ${title} | Эволюция`;
|
||||
|
||||
return {
|
||||
@ -28,7 +28,7 @@ export default async function Page(pageProps: PageProps) {
|
||||
render: async () => {
|
||||
const pageUrlParams = getPageUrlParams(pageProps);
|
||||
const createUrl = makeCreateUrl(pageUrlParams);
|
||||
const conditions = await apiIUS.getConditions(createUrl);
|
||||
const conditions = await apiIUS.getConditions({ createUrl });
|
||||
|
||||
return (
|
||||
<Background className="justify-center">
|
||||
|
||||
@ -9,7 +9,7 @@ import { Background, Divider } from 'ui';
|
||||
export async function generateMetadata(pageProps: PageProps): Promise<Metadata> {
|
||||
const pageUrlParams = getPageUrlParams(pageProps);
|
||||
const createUrl = makeCreateUrl(pageUrlParams);
|
||||
const { title } = await apiIUS.getConfig(createUrl);
|
||||
const { title } = await apiIUS.getConfig({ createUrl });
|
||||
const text = `${title} | Эволюция`;
|
||||
|
||||
return {
|
||||
@ -29,9 +29,9 @@ export default async function Page(pageProps: PageProps) {
|
||||
const createUrl = makeCreateUrl(pageUrlParams);
|
||||
|
||||
return Promise.all([
|
||||
apiIUS.getData(createUrl),
|
||||
apiIUS.getMetaData(createUrl),
|
||||
apiIUS.getConfig(createUrl),
|
||||
apiIUS.getData({ createUrl }),
|
||||
apiIUS.getMetaData({ createUrl }),
|
||||
apiIUS.getConfig({ createUrl }),
|
||||
]).then(([data, metaData, { title }]) => {
|
||||
const props = { data, metaData };
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user