diff --git a/apps/web/api/ius/query.ts b/apps/web/api/ius/query.ts index 068df80..1453f78 100644 --- a/apps/web/api/ius/query.ts +++ b/apps/web/api/ius/query.ts @@ -2,24 +2,40 @@ import type * as t from './types'; import { urls } from '@/config/urls'; import wretch from 'wretch'; -const api = wretch(urls.URL_UIS) - .errorType('json') - .resolve(({ json }) => json()); +const api = wretch(urls.URL_UIS).errorType('json'); export async function getData(params: t.Request) { const url = `/${params.slug}?${new URLSearchParams(params.searchParams)}`; - return api.get(url).then((res) => res as t.ResponseGetData); + return api + .get(url) + .res((cb) => cb.json()) + .then((res) => res); } export async function getMetaData(params: t.Request) { const url = `/${params.slug}/meta?${new URLSearchParams(params.searchParams)}`; - return api.get(url).then((res) => res as t.ResponseMetaData); + return api + .get(url) + .res((res) => res.json()) + .then((res) => res); } export async function getConfig(params: t.Request) { const url = `/${params.slug}/config`; - return api.get(url).then((res) => res as t.ResponseConfig); + return api + .get(url) + .res((res) => res.json()) + .then((res) => res); +} + +export async function getConditions(params: t.Request) { + const url = `/${params.slug}/conditions?${new URLSearchParams(params.searchParams)}`; + + return api + .get(url) + .res((res) => res.text()) + .then((res) => res); } diff --git a/apps/web/api/ius/types.ts b/apps/web/api/ius/types.ts index 9666c7e..50d1def 100644 --- a/apps/web/api/ius/types.ts +++ b/apps/web/api/ius/types.ts @@ -13,3 +13,4 @@ export type Request = { searchParams: any; slug: string }; export type ResponseGetData = Record; export type ResponseMetaData = Record; export type ResponseConfig = { title: string }; +export type ResponseConditions = string; diff --git a/apps/web/app/ius/[slug]/conditions/page.tsx b/apps/web/app/ius/[slug]/conditions/page.tsx new file mode 100644 index 0000000..90359d0 --- /dev/null +++ b/apps/web/app/ius/[slug]/conditions/page.tsx @@ -0,0 +1,28 @@ +import * as apiIUS from '@/api/ius/query'; +import { Conditions } from '@/components/Conditions'; +import type { Metadata } from 'next'; + +type Props = { + params: { slug: string }; + searchParams: { [key: string]: string | string[] | undefined }; +}; + +export async function generateMetadata({ params, searchParams }: Props): Promise { + const { title } = await apiIUS.getConfig({ searchParams, ...params }); + const text = `Условия: ${title} | Эволюция`; + + return { + description: text, + openGraph: { + description: text, + title: text, + }, + title: text, + }; +} + +export default async function Page({ params, searchParams }: Props) { + const conditions = await apiIUS.getConditions({ searchParams, ...params }); + + return ; +} diff --git a/apps/web/components/Conditions.tsx b/apps/web/components/Conditions.tsx new file mode 100644 index 0000000..523d066 --- /dev/null +++ b/apps/web/components/Conditions.tsx @@ -0,0 +1,15 @@ +/* eslint-disable react/no-danger */ +/* eslint-disable react/forbid-component-props */ +import { Background } from 'ui'; + +type Props = { + readonly html: string; +}; + +export function Conditions({ html }: Props) { + return ( + +
+ + ); +} diff --git a/packages/ui/background.tsx b/packages/ui/background.tsx index 6a71a92..994df7e 100644 --- a/packages/ui/background.tsx +++ b/packages/ui/background.tsx @@ -1,9 +1,18 @@ -import type { PropsWithChildren } from 'react'; +import { cn } from './utils'; +import type { VariantProps } from 'class-variance-authority'; +import { cva } from 'class-variance-authority'; +import { forwardRef, type HTMLAttributes } from 'react'; -export function Background({ children }: PropsWithChildren) { - return ( -
+const variants = cva( + 'grid w-full gap-2 rounded-sm border border-slate-100 bg-white p-5 lg:w-[1104px]' +); + +export type BackgroundProps = HTMLAttributes & VariantProps; + +export const Background = forwardRef( + ({ children, className, ...props }, ref) => ( +
{children}
- ); -} + ) +);