2023-11-09 14:43:06 +03:00

52 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as apiIUS from '@/api/ius/query';
import type { Request } from '@/api/ius/types';
import { Background, Button, Content, Input, Title, Wrapper } from 'ui';
type Props = {
params: { slug: string };
searchParams: { [key: string]: string | string[] | undefined };
};
export default async function Page(props: Props) {
const { data, metaData } = await getData({
searchParams: props.searchParams,
slug: props.params.slug,
});
return (
<Content>
<Background>
<div className="grid auto-rows-auto grid-cols-2 gap-2 ">
{Object.keys(metaData).map((name) => (
<Wrapper key={name}>
<Title htmlFor={name} title={metaData[name].label} />
<Input
id={name}
type="text"
required={metaData[name].required}
defaultValue={data[name]}
disabled={metaData[name].disabled}
/>
</Wrapper>
))}
</div>
<div className="grid grid-cols-3 gap-5 pt-3">
<Button>Сохранить</Button>
<Button>Возврат на доработку</Button>
<Button color="danger">Отмена</Button>
</div>
</Background>
</Content>
);
}
async function getData(params: Request) {
const data = await apiIUS.getData(params);
const metaData = await apiIUS.getMetaData(params);
return {
data,
metaData,
};
}