Compare commits
49 Commits
experiment
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e668f0ded2 | ||
|
|
dc1c315702 | ||
|
|
4d5ab7fd36 | ||
|
|
4733f2bb61 | ||
|
|
54df128e56 | ||
|
|
08aee48f07 | ||
|
|
b6001ca466 | ||
|
|
8ebf5ff249 | ||
|
|
a821906190 | ||
|
|
be938b4d62 | ||
|
|
381ba678d9 | ||
|
|
7590352ba5 | ||
|
|
2b9cdd0d73 | ||
|
|
c40eda7fd8 | ||
|
|
cf60724068 | ||
|
|
f97597d1fb | ||
|
|
83317cd0d2 | ||
|
|
e1e12da730 | ||
|
|
e40d5488b9 | ||
|
|
0a5be044b1 | ||
|
|
0f82f208d9 | ||
|
|
4b9ba14ee4 | ||
|
|
8bce97b40a | ||
|
|
782408da5e | ||
|
|
566c362c8a | ||
|
|
36e158cb19 | ||
|
|
ef827fb73e | ||
|
|
f611e561ac | ||
|
|
780794c53f | ||
|
|
ae7faa2cbf | ||
|
|
4502b05b6f | ||
|
|
22da611c52 | ||
|
|
126643982b | ||
|
|
e033886097 | ||
|
|
6918fb3766 | ||
|
|
e56285070e | ||
|
|
92c3b0ca02 | ||
|
|
b7c2cc0ff2 | ||
|
|
27d5fe4741 | ||
|
|
a8d3c96d6d | ||
|
|
5f8a9c5320 | ||
|
|
74d5c11f8e | ||
|
|
6ffb48a3b9 | ||
|
|
aaaa6fffbb | ||
|
|
2ff3589715 | ||
|
|
55372c01b7 | ||
|
|
a5eb858f4a | ||
|
|
498a64cdc9 | ||
|
|
24a12720d2 |
13
.gitignore
vendored
13
.gitignore
vendored
@ -1,9 +1,14 @@
|
|||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
# dependencies
|
# Logs
|
||||||
node_modules
|
logs
|
||||||
.pnp
|
*.log
|
||||||
.pnp.js
|
npm-debug.log*
|
||||||
|
|
||||||
|
# Dependency directory
|
||||||
|
**/node_modules/**
|
||||||
|
_node_modules
|
||||||
|
.pnp.cjs
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
coverage
|
coverage
|
||||||
|
|||||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -31,5 +31,6 @@
|
|||||||
"tailwindCSS.experimental.classRegex": [
|
"tailwindCSS.experimental.classRegex": [
|
||||||
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
|
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
|
||||||
["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
|
["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
|
||||||
]
|
],
|
||||||
|
"editor.inlineSuggest.showToolbar": "always"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,9 +18,9 @@ This Turborepo includes the following packages/apps:
|
|||||||
|
|
||||||
- `docs`: a [Next.js](https://nextjs.org/) app
|
- `docs`: a [Next.js](https://nextjs.org/) app
|
||||||
- `web`: another [Next.js](https://nextjs.org/) app
|
- `web`: another [Next.js](https://nextjs.org/) app
|
||||||
- `ui`: a stub React component library shared by both `web` and `docs` applications
|
- `@repo/ui`: a stub React component library shared by both `web` and `docs` applications
|
||||||
- `eslint-config-custom`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
|
- `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
|
||||||
- `tsconfig`: `tsconfig.json`s used throughout the monorepo
|
- `@repo/tsconfig`: `tsconfig.json`s used throughout the monorepo
|
||||||
|
|
||||||
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
|
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,19 @@
|
|||||||
FROM node:alpine AS builder
|
FROM node:alpine AS builder
|
||||||
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
ENV PNPM_HOME=/usr/local/bin
|
||||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||||
RUN apk add --no-cache libc6-compat
|
RUN apk add --no-cache libc6-compat
|
||||||
RUN apk update
|
RUN apk update
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN yarn global add turbo
|
RUN pnpm add -g turbo
|
||||||
RUN yarn global add dotenv-cli
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN turbo prune --scope=web --docker
|
RUN turbo prune --scope=web --docker
|
||||||
|
|
||||||
# Add lockfile and package.json's of isolated subworkspace
|
# Add lockfile and package.json's of isolated subworkspace
|
||||||
FROM node:alpine AS installer
|
FROM node:alpine AS installer
|
||||||
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
ENV PNPM_HOME=/usr/local/bin
|
||||||
RUN apk add --no-cache libc6-compat
|
RUN apk add --no-cache libc6-compat
|
||||||
RUN apk update
|
RUN apk update
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@ -18,14 +21,16 @@ WORKDIR /app
|
|||||||
# First install the dependencies (as they change less often)
|
# First install the dependencies (as they change less often)
|
||||||
COPY .gitignore .gitignore
|
COPY .gitignore .gitignore
|
||||||
COPY --from=builder /app/out/json/ .
|
COPY --from=builder /app/out/json/ .
|
||||||
COPY --from=builder /app/out/yarn.lock ./yarn.lock
|
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
|
||||||
RUN yarn install
|
COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
# Build the project
|
# Build the project
|
||||||
COPY --from=builder /app/out/full/ .
|
COPY --from=builder /app/out/full/ .
|
||||||
COPY turbo.json turbo.json
|
COPY turbo.json turbo.json
|
||||||
COPY .env .env
|
ARG URL_IUS_DIRECT
|
||||||
RUN yarn dotenv -e .env turbo run build --filter=web...
|
ARG NEXT_PUBLIC_USE_DEV_COLORS
|
||||||
|
RUN pnpm turbo run build --filter=web...
|
||||||
|
|
||||||
FROM node:alpine AS runner
|
FROM node:alpine AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@ -7,42 +7,46 @@ import wretch from 'wretch';
|
|||||||
const urls = getUrls();
|
const urls = getUrls();
|
||||||
const api = wretch(urls.URL_IUS).options({ cache: 'no-store' }).errorType('json');
|
const api = wretch(urls.URL_IUS).options({ cache: 'no-store' }).errorType('json');
|
||||||
|
|
||||||
type Input = { pageUrlParams: PageUrlParams; payload?: unknown };
|
type Input = { cookie?: string; pageUrlParams: PageUrlParams; payload?: unknown };
|
||||||
|
|
||||||
export async function getData({ pageUrlParams }: Input) {
|
export async function getData({ pageUrlParams, cookie = '' }: Input) {
|
||||||
const url = createUrl({
|
const url = createUrl({
|
||||||
...pageUrlParams,
|
...pageUrlParams,
|
||||||
route: '',
|
route: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
return api
|
return api
|
||||||
|
.headers({ cookie })
|
||||||
.get(url)
|
.get(url)
|
||||||
.res<t.ResponseGetData>((cb) => cb.json())
|
.res<t.ResponseGetData>((cb) => cb.json())
|
||||||
.then((res) => res);
|
.then((res) => res);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMetaData({ pageUrlParams }: Input) {
|
export async function getMetaData({ pageUrlParams, cookie = '' }: Input) {
|
||||||
const url = createUrl({ ...pageUrlParams, route: '/meta' });
|
const url = createUrl({ ...pageUrlParams, route: '/meta' });
|
||||||
|
|
||||||
return api
|
return api
|
||||||
|
.headers({ cookie })
|
||||||
.get(url)
|
.get(url)
|
||||||
.res<t.ResponseMetaData>((res) => res.json())
|
.res<t.ResponseMetaData>((res) => res.json())
|
||||||
.then((res) => res);
|
.then((res) => res);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getConfig({ pageUrlParams }: Input) {
|
export async function getConfig({ pageUrlParams, cookie = '' }: Input) {
|
||||||
const url = createUrl({ ...pageUrlParams, route: '/config' });
|
const url = createUrl({ ...pageUrlParams, route: '/config' });
|
||||||
|
|
||||||
return api
|
return api
|
||||||
|
.headers({ cookie })
|
||||||
.get(url)
|
.get(url)
|
||||||
.res<t.ResponseConfig>((res) => res.json())
|
.res<t.ResponseConfig>((res) => res.json())
|
||||||
.then((res) => res);
|
.then((res) => res);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getConditions({ pageUrlParams }: Input) {
|
export async function getConditions({ pageUrlParams, cookie = '' }: Input) {
|
||||||
const url = createUrl({ ...pageUrlParams, route: '/conditions' });
|
const url = createUrl({ ...pageUrlParams, route: '/conditions' });
|
||||||
|
|
||||||
return api
|
return api
|
||||||
|
.headers({ cookie })
|
||||||
.get(url)
|
.get(url)
|
||||||
.res<t.ResponseConditions>((res) => res.text())
|
.res<t.ResponseConditions>((res) => res.text())
|
||||||
.then((res) => res);
|
.then((res) => res);
|
||||||
@ -55,7 +59,7 @@ export async function save({ pageUrlParams, payload }: Input) {
|
|||||||
.post(payload, url)
|
.post(payload, url)
|
||||||
.res<boolean>((res) => res.ok)
|
.res<boolean>((res) => res.ok)
|
||||||
.then((res) => res)
|
.then((res) => res)
|
||||||
.catch((error: WretchError) => error.json as t.HttpValidationError);
|
.catch((error: WretchError) => error.json as t.HttpValidationError | t.HttpError);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function retract({ pageUrlParams, payload }: Input) {
|
export async function retract({ pageUrlParams, payload }: Input) {
|
||||||
@ -65,28 +69,30 @@ export async function retract({ pageUrlParams, payload }: Input) {
|
|||||||
.post(payload, url)
|
.post(payload, url)
|
||||||
.res<boolean>((res) => res.ok)
|
.res<boolean>((res) => res.ok)
|
||||||
.then((res) => res)
|
.then((res) => res)
|
||||||
.catch((error: WretchError) => error.json as t.HttpValidationError);
|
.catch((error: WretchError) => error.json as t.HttpValidationError | t.HttpError);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getDocumentTypes({ pageUrlParams }: Input) {
|
export async function getDocumentTypes({ pageUrlParams, cookie = '' }: Input) {
|
||||||
const url = createUrl({ ...pageUrlParams, route: '/documenttypes' });
|
const url = createUrl({ ...pageUrlParams, route: '/documenttypes' });
|
||||||
|
|
||||||
return api
|
return api
|
||||||
|
.headers({ cookie })
|
||||||
.get(url)
|
.get(url)
|
||||||
.res<t.ResponseDocumentTypes>((res) => res.json())
|
.res<t.ResponseDocumentTypes>((res) => res.json())
|
||||||
.then((res) => res);
|
.then((res) => res);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getDocuments({ pageUrlParams }: Input) {
|
export async function getDocuments({ pageUrlParams, cookie = '' }: Input) {
|
||||||
const url = createUrl({ ...pageUrlParams, route: '/documents' });
|
const url = createUrl({ ...pageUrlParams, route: '/documents' });
|
||||||
|
|
||||||
return api
|
return api
|
||||||
|
.headers({ cookie })
|
||||||
.get(url)
|
.get(url)
|
||||||
.res<t.ResponseDocuments>((res) => res.json())
|
.res<t.ResponseDocuments>((res) => res.json())
|
||||||
.then((res) => res);
|
.then((res) => res);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uploadDocument({
|
export function uploadDocument({
|
||||||
pageUrlParams,
|
pageUrlParams,
|
||||||
document,
|
document,
|
||||||
formData,
|
formData,
|
||||||
@ -100,5 +106,15 @@ export async function uploadDocument({
|
|||||||
return fetch(urls.URL_IUS + url, {
|
return fetch(urls.URL_IUS + url, {
|
||||||
body: formData,
|
body: formData,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
});
|
})
|
||||||
|
.then((res) => {
|
||||||
|
if (res.ok) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.json();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
throw error as t.HttpError;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
34
apps/web/api/ius/tools.ts
Normal file
34
apps/web/api/ius/tools.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import type { Document, DocumentType } from './types';
|
||||||
|
|
||||||
|
export function combineDocuments({
|
||||||
|
documentTypes,
|
||||||
|
documents,
|
||||||
|
}: {
|
||||||
|
documentTypes: DocumentType[];
|
||||||
|
documents: Document[];
|
||||||
|
}) {
|
||||||
|
if (!documents.length) {
|
||||||
|
return documentTypes.map((x) => ({ ...(x as Document), canUpload: true }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const nonUploadableDocuments = documents
|
||||||
|
.filter(
|
||||||
|
(document) =>
|
||||||
|
!documentTypes.some(
|
||||||
|
(documentType) => documentType.documentTypeId === document.documentTypeId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map((document) => ({ ...document, canUpload: false }));
|
||||||
|
|
||||||
|
return documentTypes
|
||||||
|
.map((documentType) => {
|
||||||
|
const targetDocument = documents.find(
|
||||||
|
(document) => document.documentTypeId === documentType.documentTypeId
|
||||||
|
);
|
||||||
|
|
||||||
|
return { ...documentType, ...targetDocument, canUpload: true };
|
||||||
|
})
|
||||||
|
.concat(nonUploadableDocuments);
|
||||||
|
}
|
||||||
|
|
||||||
|
export type CombinedDocuments = ReturnType<typeof combineDocuments>;
|
||||||
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
export type MetaObject = {
|
export type MetaObject = {
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
fieldType: 'CHECKBOX' | 'DECIMAL' | 'INT' | 'STRING' | 'TEXTAREA';
|
fieldType: 'CHECKBOX' | 'DECIMAL' | 'INT' | 'STRING' | 'BIGSTRING';
|
||||||
label: string;
|
label: string;
|
||||||
max: number;
|
max: number;
|
||||||
min: number;
|
min: number;
|
||||||
@ -16,11 +16,9 @@ export type DocumentType = {
|
|||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Document = {
|
export type Document = DocumentType & {
|
||||||
documentId: string;
|
documentId?: string;
|
||||||
documentTypeId: string;
|
href?: string;
|
||||||
href: string;
|
|
||||||
name: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResponseGetData = Record<string, Value>;
|
export type ResponseGetData = Record<string, Value>;
|
||||||
|
|||||||
@ -4,10 +4,14 @@ import type { PageProps } from '@/types/page';
|
|||||||
import { withError } from '@/utils/error';
|
import { withError } from '@/utils/error';
|
||||||
import { getPageUrlParams } from '@/utils/url';
|
import { getPageUrlParams } from '@/utils/url';
|
||||||
import type { Metadata } from 'next';
|
import type { Metadata } from 'next';
|
||||||
|
import { headers } from 'next/headers';
|
||||||
|
|
||||||
export async function generateMetadata(pageProps: PageProps): Promise<Metadata> {
|
export async function generateMetadata(pageProps: PageProps): Promise<Metadata> {
|
||||||
const pageUrlParams = getPageUrlParams(pageProps);
|
const pageUrlParams = getPageUrlParams(pageProps);
|
||||||
const { title } = await apiIUS.getConfig({ pageUrlParams });
|
const headersList = headers();
|
||||||
|
const cookie = headersList.get('cookie') ?? '';
|
||||||
|
|
||||||
|
const { title } = await apiIUS.getConfig({ cookie, pageUrlParams });
|
||||||
const text = `Условия: ${title} | Эволюция`;
|
const text = `Условия: ${title} | Эволюция`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -24,7 +28,10 @@ export default async function Page(pageProps: PageProps) {
|
|||||||
return withError({
|
return withError({
|
||||||
render: async () => {
|
render: async () => {
|
||||||
const pageUrlParams = getPageUrlParams(pageProps);
|
const pageUrlParams = getPageUrlParams(pageProps);
|
||||||
const conditions = await apiIUS.getConditions({ pageUrlParams });
|
const headersList = headers();
|
||||||
|
const cookie = headersList.get('cookie') ?? '';
|
||||||
|
|
||||||
|
const conditions = await apiIUS.getConditions({ cookie, pageUrlParams });
|
||||||
|
|
||||||
return <Conditions html={conditions} />;
|
return <Conditions html={conditions} />;
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,13 +1,19 @@
|
|||||||
import * as apiIUS from '@/api/ius/query';
|
import * as apiIUS from '@/api/ius/query';
|
||||||
|
import { combineDocuments } from '@/api/ius/tools';
|
||||||
import { Form } from '@/components/Form';
|
import { Form } from '@/components/Form';
|
||||||
|
import type { FormComponentProps } from '@/components/Form/types';
|
||||||
import type { PageProps } from '@/types/page';
|
import type { PageProps } from '@/types/page';
|
||||||
import { withError } from '@/utils/error';
|
import { withError } from '@/utils/error';
|
||||||
import { getPageUrlParams } from '@/utils/url';
|
import { getPageUrlParams } from '@/utils/url';
|
||||||
import type { Metadata } from 'next';
|
import type { Metadata } from 'next';
|
||||||
|
import { headers } from 'next/headers';
|
||||||
|
|
||||||
export async function generateMetadata(pageProps: PageProps): Promise<Metadata> {
|
export async function generateMetadata(pageProps: PageProps): Promise<Metadata> {
|
||||||
const pageUrlParams = getPageUrlParams(pageProps);
|
const pageUrlParams = getPageUrlParams(pageProps);
|
||||||
const { title } = await apiIUS.getConfig({ pageUrlParams });
|
const headersList = headers();
|
||||||
|
const cookie = headersList.get('cookie') ?? '';
|
||||||
|
|
||||||
|
const { title } = await apiIUS.getConfig({ cookie, pageUrlParams });
|
||||||
const text = `${title} | Эволюция`;
|
const text = `${title} | Эволюция`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -25,14 +31,24 @@ export default async function Page(pageProps: PageProps) {
|
|||||||
render: async () => {
|
render: async () => {
|
||||||
const pageUrlParams = getPageUrlParams(pageProps);
|
const pageUrlParams = getPageUrlParams(pageProps);
|
||||||
|
|
||||||
|
const headersList = headers();
|
||||||
|
const cookie = headersList.get('cookie') ?? '';
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
apiIUS.getData({ pageUrlParams }),
|
apiIUS.getData({ cookie, pageUrlParams }),
|
||||||
apiIUS.getMetaData({ pageUrlParams }),
|
apiIUS.getMetaData({ cookie, pageUrlParams }),
|
||||||
apiIUS.getConfig({ pageUrlParams }),
|
apiIUS.getConfig({ cookie, pageUrlParams }),
|
||||||
apiIUS.getDocumentTypes({ pageUrlParams }),
|
apiIUS.getDocumentTypes({ cookie, pageUrlParams }),
|
||||||
apiIUS.getDocuments({ pageUrlParams }),
|
apiIUS.getDocuments({ cookie, pageUrlParams }),
|
||||||
]).then(([data, metaData, { title }, documentTypes, documents]) => {
|
]).then(([data, metaData, { title }, documentTypes, documents]) => {
|
||||||
const props = { data, documentTypes, documents, metaData, pageUrlParams, title };
|
const combinedDocuments = combineDocuments({ documentTypes, documents });
|
||||||
|
const props: FormComponentProps = {
|
||||||
|
combinedDocuments,
|
||||||
|
data,
|
||||||
|
metaData,
|
||||||
|
pageUrlParams,
|
||||||
|
title,
|
||||||
|
};
|
||||||
|
|
||||||
return <Form {...props} />;
|
return <Form {...props} />;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import './globals.css';
|
import './globals.css';
|
||||||
import { Auth, Logo } from '@/components/layout';
|
import { Auth, Logo } from '@/components/layout';
|
||||||
import { Controls } from '@/components/layout/controls';
|
import { Controls } from '@/components/layout/controls';
|
||||||
|
import { Content, Header } from '@repo/ui';
|
||||||
import type { Metadata } from 'next';
|
import type { Metadata } from 'next';
|
||||||
import localFont from 'next/font/local';
|
import localFont from 'next/font/local';
|
||||||
import { Content, Header } from 'ui';
|
|
||||||
|
|
||||||
const inter = localFont({
|
const inter = localFont({
|
||||||
src: [
|
src: [
|
||||||
@ -46,6 +46,7 @@ export default function RootLayout({ children }: { readonly children: React.Reac
|
|||||||
<head>
|
<head>
|
||||||
<meta charSet="utf-8" />
|
<meta charSet="utf-8" />
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
|
<link rel="manifest" href="/manifest.webmanifest" crossOrigin="use-credentials" />
|
||||||
</head>
|
</head>
|
||||||
<body className={inter.className}>
|
<body className={inter.className}>
|
||||||
<Header>
|
<Header>
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
import type { MetadataRoute } from 'next';
|
|
||||||
|
|
||||||
export default function manifest(): MetadataRoute.Manifest {
|
|
||||||
return {
|
|
||||||
background_color: '#fff',
|
|
||||||
description: 'External | Эволюция',
|
|
||||||
display: 'standalone',
|
|
||||||
icons: [
|
|
||||||
{
|
|
||||||
sizes: '192x192',
|
|
||||||
src: '/android-chrome-192x192.png',
|
|
||||||
type: 'image/png',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sizes: '512x512',
|
|
||||||
src: '/android-chrome-512x512.png',
|
|
||||||
type: 'image/png',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
name: 'External | Эволюция',
|
|
||||||
short_name: 'External | Эволюция',
|
|
||||||
start_url: '/',
|
|
||||||
theme_color: '#fff',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { HttpError } from 'ui';
|
import { HttpError } from '@repo/ui';
|
||||||
|
|
||||||
export default function NotFound() {
|
export default function NotFound() {
|
||||||
return <HttpError code="404" title="Страница не найдена" />;
|
return <HttpError code="404" title="Страница не найдена" />;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Background } from 'ui';
|
import { Background } from '@repo/ui';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
readonly html: string;
|
readonly html: string;
|
||||||
|
|||||||
@ -1,99 +0,0 @@
|
|||||||
/* eslint-disable react/jsx-curly-newline */
|
|
||||||
/* eslint-disable no-negated-condition */
|
|
||||||
import { FormContext } from './context/form-context';
|
|
||||||
import * as apiIus from '@/api/ius/query';
|
|
||||||
import { useFormStore } from '@/store/ius/form';
|
|
||||||
import { useRouter } from 'next/navigation';
|
|
||||||
import { pick } from 'radash';
|
|
||||||
import { useCallback } from 'react';
|
|
||||||
import { useContext } from 'react';
|
|
||||||
import { Button } from 'ui';
|
|
||||||
|
|
||||||
const ERROR_UPLOAD_DOCUMENT = 'Произошла ошибка при загрузке документов';
|
|
||||||
|
|
||||||
export function Buttons() {
|
|
||||||
const { reset, resetValidation, setValidation, values } = useFormStore();
|
|
||||||
const { formFiles, pageUrlParams, setFormState } = useContext(FormContext);
|
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const handleSave = useCallback(() => {
|
|
||||||
apiIus.save({ pageUrlParams, payload: values }).then((res) => {
|
|
||||||
if (typeof res !== 'boolean') {
|
|
||||||
setTimeout(() => {
|
|
||||||
setFormState({ status: 'edit' });
|
|
||||||
}, 300);
|
|
||||||
Object.keys(res.errors).forEach((name) => {
|
|
||||||
const elementValidation = res?.errors?.[name];
|
|
||||||
if (elementValidation)
|
|
||||||
setValidation({ message: elementValidation[0] ?? '', name, valid: false });
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setFormState({ status: 'success' });
|
|
||||||
setTimeout(() => {
|
|
||||||
router.refresh();
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, [pageUrlParams, router, setFormState, setValidation, values]);
|
|
||||||
|
|
||||||
const handleUploadFiles = useCallback(() => {
|
|
||||||
setFormState({ status: 'pending' });
|
|
||||||
resetValidation();
|
|
||||||
const uploadFiles = formFiles.map((formFile) => {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('file', formFile.file);
|
|
||||||
const document = pick(formFile, ['documentTypeId']);
|
|
||||||
|
|
||||||
return apiIus.uploadDocument({
|
|
||||||
document,
|
|
||||||
formData,
|
|
||||||
pageUrlParams,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return Promise.allSettled(uploadFiles).catch(() => {
|
|
||||||
setFormState({ status: 'error', text: ERROR_UPLOAD_DOCUMENT });
|
|
||||||
throw new Error(ERROR_UPLOAD_DOCUMENT);
|
|
||||||
});
|
|
||||||
}, [formFiles, pageUrlParams, resetValidation, setFormState]);
|
|
||||||
|
|
||||||
const handleRetract = useCallback(() => {
|
|
||||||
setFormState({ status: 'pending' });
|
|
||||||
resetValidation();
|
|
||||||
apiIus.retract({ pageUrlParams, payload: values }).then((res) => {
|
|
||||||
if (typeof res !== 'boolean') {
|
|
||||||
setTimeout(() => {
|
|
||||||
setFormState({ status: 'edit' });
|
|
||||||
}, 300);
|
|
||||||
Object.keys(res.errors).forEach((name) => {
|
|
||||||
const elementValidation = res?.errors?.[name];
|
|
||||||
if (elementValidation)
|
|
||||||
setValidation({ message: elementValidation[0] ?? '', name, valid: false });
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setFormState({ status: 'success' });
|
|
||||||
setTimeout(() => {
|
|
||||||
router.refresh();
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, [pageUrlParams, resetValidation, router, setFormState, setValidation, values]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="grid grid-cols-1 gap-2 gap-x-4 md:grid-cols-3">
|
|
||||||
<Button
|
|
||||||
intent="outline-danger"
|
|
||||||
onClick={() => {
|
|
||||||
reset();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Отмена
|
|
||||||
</Button>
|
|
||||||
<Button intent="outline-secondary" onClick={() => handleRetract()}>
|
|
||||||
Возврат на доработку
|
|
||||||
</Button>
|
|
||||||
<Button onClick={() => handleUploadFiles().then(() => handleSave())}>Сохранить</Button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
95
apps/web/components/Form/Common/Buttons.tsx
Normal file
95
apps/web/components/Form/Common/Buttons.tsx
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/* eslint-disable react/jsx-curly-newline */
|
||||||
|
/* eslint-disable no-negated-condition */
|
||||||
|
import { FormContext } from '../context/form-context';
|
||||||
|
import * as apiIus from '@/api/ius/query';
|
||||||
|
import { useFormStore } from '@/store/ius/form';
|
||||||
|
import { Button } from '@repo/ui';
|
||||||
|
import { useCallback, useContext } from 'react';
|
||||||
|
|
||||||
|
const ERROR_RETRACT = 'Произошла ошибка при возврате на доработку';
|
||||||
|
const ERROR_SAVE = 'Произошла ошибка при сохранении';
|
||||||
|
|
||||||
|
export function Buttons() {
|
||||||
|
const { reset, resetValidation, setValidation, status, values } = useFormStore();
|
||||||
|
const { pageUrlParams, setFormState } = useContext(FormContext);
|
||||||
|
|
||||||
|
const handleSave = useCallback(() => {
|
||||||
|
setFormState({ status: 'pending' });
|
||||||
|
resetValidation();
|
||||||
|
apiIus.save({ pageUrlParams, payload: values }).then((res) => {
|
||||||
|
if (typeof res !== 'boolean') {
|
||||||
|
const { errors } = res;
|
||||||
|
|
||||||
|
if (Array.isArray(errors)) {
|
||||||
|
setFormState({ status: 'error', text: errors?.at(0) || ERROR_SAVE });
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(errors).forEach((name) => {
|
||||||
|
const elementValidation = errors?.[name];
|
||||||
|
if (elementValidation)
|
||||||
|
setValidation({ message: elementValidation[0] ?? '', name, valid: false });
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setFormState({ status: 'edit' });
|
||||||
|
}, 300);
|
||||||
|
} else {
|
||||||
|
setFormState({ status: 'success' });
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, [pageUrlParams, resetValidation, setFormState, setValidation, values]);
|
||||||
|
|
||||||
|
const handleRetract = useCallback(() => {
|
||||||
|
setFormState({ status: 'pending' });
|
||||||
|
resetValidation();
|
||||||
|
apiIus.retract({ pageUrlParams, payload: values }).then((res) => {
|
||||||
|
if (typeof res !== 'boolean') {
|
||||||
|
const { errors } = res;
|
||||||
|
|
||||||
|
if (Array.isArray(errors)) {
|
||||||
|
setFormState({ status: 'error', text: errors?.at(0) || ERROR_RETRACT });
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setFormState({ status: 'edit' });
|
||||||
|
}, 300);
|
||||||
|
Object.keys(errors).forEach((name) => {
|
||||||
|
const elementValidation = errors?.[name];
|
||||||
|
if (elementValidation)
|
||||||
|
setValidation({ message: elementValidation[0] ?? '', name, valid: false });
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setFormState({ status: 'success' });
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, [pageUrlParams, resetValidation, setFormState, setValidation, values]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid grid-cols-1 gap-2 gap-x-4 md:grid-cols-3">
|
||||||
|
<Button
|
||||||
|
intent="outline-danger"
|
||||||
|
onClick={() => {
|
||||||
|
reset();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Отмена
|
||||||
|
</Button>
|
||||||
|
<Button intent="outline-secondary" onClick={handleRetract}>
|
||||||
|
Возврат на доработку
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleSave} disabled={status !== 'edited'}>
|
||||||
|
Сохранить
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,19 +1,10 @@
|
|||||||
import type { Props } from './types';
|
import type { FormComponentProps } from '../types';
|
||||||
|
import type { MetaObject } from '@/api/ius/types';
|
||||||
import { mapFieldTypeElement } from '@/config/elements';
|
import { mapFieldTypeElement } from '@/config/elements';
|
||||||
import { useFormStore } from '@/store/ius/form';
|
import { useFormStore } from '@/store/ius/form';
|
||||||
|
import { ElementContainer } from '@repo/ui';
|
||||||
|
import { get } from 'radash';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { ElementContainer } from 'ui';
|
|
||||||
|
|
||||||
function compatMetadata(metaData: Props['metaData']) {
|
|
||||||
const { comment, ...meta } = metaData;
|
|
||||||
if (comment) {
|
|
||||||
comment.fieldType = 'TEXTAREA';
|
|
||||||
|
|
||||||
return { ...meta, comment };
|
|
||||||
}
|
|
||||||
|
|
||||||
return metaData;
|
|
||||||
}
|
|
||||||
|
|
||||||
function RenderElement({
|
function RenderElement({
|
||||||
fieldType,
|
fieldType,
|
||||||
@ -23,7 +14,7 @@ function RenderElement({
|
|||||||
name,
|
name,
|
||||||
visible,
|
visible,
|
||||||
...props
|
...props
|
||||||
}: Props['metaData'][number] & { readonly name: string }) {
|
}: MetaObject & { readonly name: string }) {
|
||||||
const { setValue, validation, values } = useFormStore();
|
const { setValue, validation, values } = useFormStore();
|
||||||
|
|
||||||
if (!visible) return false;
|
if (!visible) return false;
|
||||||
@ -40,15 +31,16 @@ function RenderElement({
|
|||||||
>
|
>
|
||||||
<Element
|
<Element
|
||||||
loading={!Object.keys(values).length}
|
loading={!Object.keys(values).length}
|
||||||
checked={fieldType === 'CHECKBOX' ? Boolean(values[name]) || false : false}
|
checked={fieldType === 'CHECKBOX' ? Boolean(values[name]) ?? false : false}
|
||||||
id={name}
|
id={name}
|
||||||
value={values[name] || ''}
|
value={values[name] ?? ''}
|
||||||
min={min}
|
min={min}
|
||||||
max={max}
|
max={max}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setValue({
|
setValue({
|
||||||
name,
|
name,
|
||||||
value: fieldType === 'CHECKBOX' ? e.target.checked : e.target.value,
|
value:
|
||||||
|
fieldType === 'CHECKBOX' ? (e.target as HTMLInputElement).checked : e.target.value,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
{...props}
|
{...props}
|
||||||
@ -57,23 +49,31 @@ function RenderElement({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Elements({ data, metaData }: Props) {
|
export function Elements({ data, metaData }: FormComponentProps) {
|
||||||
const { init } = useFormStore();
|
const { init } = useFormStore();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
init(data);
|
init(data);
|
||||||
}, [data, init]);
|
}, [data, init]);
|
||||||
|
|
||||||
const { comment, ...meta } = compatMetadata(metaData);
|
const defaultElements = Object.keys(metaData).filter(
|
||||||
|
(x) => metaData[x]?.fieldType !== 'BIGSTRING'
|
||||||
|
);
|
||||||
|
|
||||||
|
const bigStringElements = Object.keys(metaData).filter(
|
||||||
|
(x) => metaData[x]?.fieldType === 'BIGSTRING'
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="mt-2 grid gap-2 gap-x-4 md:grid md:grid-cols-2 lg:grid-cols-3">
|
<div className="mt-2 grid gap-2 gap-x-4 md:grid md:grid-cols-2 lg:grid-cols-3">
|
||||||
{Object.keys(meta).map((name) => (
|
{defaultElements.map((name) => (
|
||||||
<RenderElement key={name} {...metaData[name]} name={name} />
|
<RenderElement key={name} {...get(metaData, name)} name={name} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<RenderElement {...comment} name="comment" />
|
{bigStringElements.map((name) => (
|
||||||
|
<RenderElement key={name} {...get(metaData, name)} name={name} fieldType="BIGSTRING" />
|
||||||
|
))}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
2
apps/web/components/Form/Common/index.ts
Normal file
2
apps/web/components/Form/Common/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './Buttons';
|
||||||
|
export * from './Elements';
|
||||||
76
apps/web/components/Form/Documents/Buttons.tsx
Normal file
76
apps/web/components/Form/Documents/Buttons.tsx
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/* eslint-disable react/jsx-curly-newline */
|
||||||
|
/* eslint-disable no-negated-condition */
|
||||||
|
import { FormContext } from '../context/form-context';
|
||||||
|
import * as apiIus from '@/api/ius/query';
|
||||||
|
import type { HttpError } from '@/api/ius/types';
|
||||||
|
import { useFormStore } from '@/store/ius/form';
|
||||||
|
import { Button } from '@repo/ui';
|
||||||
|
import { pick } from 'radash';
|
||||||
|
import { useCallback, useContext } from 'react';
|
||||||
|
|
||||||
|
const ERROR_UPLOAD_DOCUMENT = 'Произошла ошибка при загрузке документов';
|
||||||
|
const SUCCESS_UPLOAD_DOCUMENTS = 'Файлы успешно загружены';
|
||||||
|
|
||||||
|
export function Buttons() {
|
||||||
|
const { resetValidation } = useFormStore();
|
||||||
|
const { formFiles, pageUrlParams, setFormFiles, setFormState } = useContext(FormContext);
|
||||||
|
|
||||||
|
const handleUploadFiles = useCallback(() => {
|
||||||
|
setFormState({ status: 'pending' });
|
||||||
|
resetValidation();
|
||||||
|
const uploadFiles = formFiles.map((formFile) => {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', formFile.file);
|
||||||
|
const document = pick(formFile, ['documentTypeId']);
|
||||||
|
|
||||||
|
return apiIus.uploadDocument({
|
||||||
|
document,
|
||||||
|
formData,
|
||||||
|
pageUrlParams,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return Promise.all(uploadFiles)
|
||||||
|
.then(async (res) => {
|
||||||
|
const errors = res.filter((x) => typeof x !== 'boolean') as HttpError[];
|
||||||
|
|
||||||
|
if (!errors.length) {
|
||||||
|
setFormState({
|
||||||
|
status: 'success',
|
||||||
|
text: SUCCESS_UPLOAD_DOCUMENTS,
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload();
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const error = errors.find((x) => x.errors.length)?.errors.at(0) || ERROR_UPLOAD_DOCUMENT;
|
||||||
|
|
||||||
|
setFormState({ status: 'error', text: error });
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
setFormState({
|
||||||
|
status: 'error',
|
||||||
|
text: error ? JSON.stringify(error) : ERROR_UPLOAD_DOCUMENT,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, [formFiles, pageUrlParams, resetValidation, setFormState]);
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
setFormFiles([]);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid grid-cols-1 gap-2 gap-x-4 md:grid-cols-3">
|
||||||
|
<Button intent="outline-danger" onClick={handleCancel} disabled={!formFiles.length}>
|
||||||
|
Отмена
|
||||||
|
</Button>
|
||||||
|
<Button onClick={handleUploadFiles} disabled={!formFiles.length}>
|
||||||
|
Загрузить файлы
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
75
apps/web/components/Form/Documents/Files.tsx
Normal file
75
apps/web/components/Form/Documents/Files.tsx
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import { FormContext } from '../context/form-context';
|
||||||
|
import type { FormComponentProps } from '../types';
|
||||||
|
import { ArrowDownTrayIcon } from '@heroicons/react/24/solid';
|
||||||
|
import { Heading, InputFile } from '@repo/ui';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { useContext, useEffect, useRef } from 'react';
|
||||||
|
|
||||||
|
type DownloadDocumentProps = Pick<FileProps, 'document'>;
|
||||||
|
|
||||||
|
function DownloadDocument({ document }: DownloadDocumentProps) {
|
||||||
|
return document?.href ? (
|
||||||
|
<Link
|
||||||
|
href={'/api/ius' + document.href}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="text-primary-600 h-10 px-5 py-2.5 text-sm font-medium hover:underline"
|
||||||
|
>
|
||||||
|
<div className="flex flex-row items-center gap-1">
|
||||||
|
<ArrowDownTrayIcon className="h-4 w-4" />
|
||||||
|
Скачать
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type FileProps = {
|
||||||
|
readonly document: FormComponentProps['combinedDocuments'][number];
|
||||||
|
};
|
||||||
|
|
||||||
|
function File({ document }: FileProps) {
|
||||||
|
const { formFiles, setFormFiles } = useContext(FormContext);
|
||||||
|
|
||||||
|
const { canUpload, documentTypeId, name } = document;
|
||||||
|
|
||||||
|
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
if (event.target.files !== null) {
|
||||||
|
const file = event.target.files.item(0);
|
||||||
|
if (file)
|
||||||
|
setFormFiles([
|
||||||
|
...formFiles.filter((x) => x.documentTypeId !== documentTypeId),
|
||||||
|
{ documentTypeId, file, name },
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const uploadableFile = formFiles.some((x) => x.documentTypeId === document.documentTypeId);
|
||||||
|
if (!uploadableFile && inputRef.current) inputRef.current.value = '';
|
||||||
|
}, [document.documentTypeId, formFiles]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={documentTypeId} className="flex flex-col gap-1">
|
||||||
|
<label className="mb-2 block text-sm font-normal text-gray-900">{name}:</label>
|
||||||
|
<InputFile ref={inputRef} onChange={handleFileChange} disabled={!canUpload} />
|
||||||
|
<DownloadDocument document={document} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Files({ combinedDocuments }: FormComponentProps) {
|
||||||
|
return (
|
||||||
|
<div className="grid gap-4">
|
||||||
|
<Heading className="text-sm">Документы</Heading>
|
||||||
|
<div className="grid gap-2 md:grid-cols-2">
|
||||||
|
{combinedDocuments.map((document) => (
|
||||||
|
<File key={document.documentTypeId} document={document} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
2
apps/web/components/Form/Documents/index.ts
Normal file
2
apps/web/components/Form/Documents/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './Buttons';
|
||||||
|
export * from './Files';
|
||||||
@ -1,71 +0,0 @@
|
|||||||
import { FormContext } from './context/form-context';
|
|
||||||
import type { Props } from './types';
|
|
||||||
import type * as IUS from '@/api/ius/types';
|
|
||||||
import { ArrowDownTrayIcon } from '@heroicons/react/24/solid';
|
|
||||||
import Link from 'next/link';
|
|
||||||
import { useContext } from 'react';
|
|
||||||
import { Heading, InputFile } from 'ui';
|
|
||||||
|
|
||||||
type DownloadDocumentProps = Pick<FileProps, 'document'>;
|
|
||||||
|
|
||||||
function DownloadDocument({ document }: DownloadDocumentProps) {
|
|
||||||
return document ? (
|
|
||||||
<Link
|
|
||||||
href={'/api/ius' + document?.href}
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="text-primary-600 h-10 px-5 py-2.5 text-sm font-medium hover:underline"
|
|
||||||
>
|
|
||||||
<div className="flex flex-row items-center gap-1">
|
|
||||||
<ArrowDownTrayIcon className="h-4 w-4" />
|
|
||||||
Скачать
|
|
||||||
</div>
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
type FileProps = {
|
|
||||||
readonly document: IUS.Document | undefined;
|
|
||||||
readonly documentType: IUS.DocumentType;
|
|
||||||
};
|
|
||||||
|
|
||||||
function File({ document, documentType }: FileProps) {
|
|
||||||
const { documentTypeId, name } = documentType;
|
|
||||||
const { formFiles, setFormFiles } = useContext(FormContext);
|
|
||||||
|
|
||||||
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
if (event.target.files) {
|
|
||||||
setFormFiles([
|
|
||||||
...formFiles.filter((x) => x.documentTypeId !== documentTypeId),
|
|
||||||
{ documentTypeId, file: event.target.files[0], name },
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div key={documentTypeId} className="flex flex-col gap-1">
|
|
||||||
<label className="mb-2 block text-sm font-normal text-gray-900">{name}:</label>
|
|
||||||
<InputFile onChange={handleFileChange} />
|
|
||||||
<DownloadDocument document={document} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Files({ documentTypes, documents }: Props) {
|
|
||||||
return (
|
|
||||||
<div className="grid gap-4">
|
|
||||||
<Heading className="text-sms">Документы</Heading>
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
{documentTypes.map((documentType) => (
|
|
||||||
<File
|
|
||||||
key={documentType.documentTypeId}
|
|
||||||
documentType={documentType}
|
|
||||||
document={documents.find((x) => x.documentTypeId === documentType.documentTypeId)}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
|
import { Heading } from '@repo/ui';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { Heading } from 'ui';
|
|
||||||
|
|
||||||
export function Header({ link, title }: { readonly link: string; readonly title: string }) {
|
export function Header({ link, title }: { readonly link: string; readonly title: string }) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,44 +1,61 @@
|
|||||||
'use client';
|
'use client';
|
||||||
import { FormContext } from './context/form-context';
|
import { FormContext } from './context/form-context';
|
||||||
import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/solid';
|
import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/solid';
|
||||||
|
import { Background, Button, LoadingSpinner } from '@repo/ui';
|
||||||
import type { PropsWithChildren } from 'react';
|
import type { PropsWithChildren } from 'react';
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { Background, LoadingSpinner } from 'ui';
|
|
||||||
|
|
||||||
function OverlayWrapper({ children }: PropsWithChildren) {
|
function OverlayWrapper({ children }: PropsWithChildren) {
|
||||||
return (
|
return (
|
||||||
<Background className="absolute left-0 top-0 grid h-full w-full place-items-center bg-opacity-80 backdrop-blur-sm">
|
<Background className="absolute left-0 top-0 grid h-full w-full place-items-center bg-opacity-80 backdrop-blur-sm">
|
||||||
<div className="absolute bottom-[50vh] flex flex-row items-center gap-2 md:relative md:bottom-0">
|
<div className="absolute bottom-[50vh] flex flex-col items-center gap-2 md:relative md:bottom-0">
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</Background>
|
</Background>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function StateContentWrapper({ children }: PropsWithChildren) {
|
||||||
|
return <div className="flex flex-row items-center gap-2">{children}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
export function Overlay() {
|
export function Overlay() {
|
||||||
const { formState } = useContext(FormContext);
|
const { formState, setFormState } = useContext(FormContext);
|
||||||
const { status, text } = formState;
|
const { status, text } = formState;
|
||||||
|
|
||||||
if (status === 'pending')
|
let stateContent: JSX.Element | false = false;
|
||||||
return (
|
|
||||||
<OverlayWrapper>
|
if (status === 'pending') {
|
||||||
|
stateContent = (
|
||||||
|
<StateContentWrapper>
|
||||||
{LoadingSpinner} <p className="font-medium">Загрузка...</p>
|
{LoadingSpinner} <p className="font-medium">Загрузка...</p>
|
||||||
</OverlayWrapper>
|
</StateContentWrapper>
|
||||||
);
|
);
|
||||||
if (status === 'success')
|
}
|
||||||
return (
|
if (status === 'success') {
|
||||||
<OverlayWrapper>
|
stateContent = (
|
||||||
<CheckCircleIcon className="h-10 w-10 fill-green-500" title="OK" />{' '}
|
<StateContentWrapper>
|
||||||
|
<CheckCircleIcon className="h-10 w-10 fill-green-500" title="OK" />
|
||||||
<p className="font-medium">Данные сохранены</p>
|
<p className="font-medium">Данные сохранены</p>
|
||||||
</OverlayWrapper>
|
</StateContentWrapper>
|
||||||
);
|
|
||||||
if (status === 'error') {
|
|
||||||
return (
|
|
||||||
<OverlayWrapper>
|
|
||||||
<XCircleIcon className="h-10 w-10 fill-red-500" title="Error" />{' '}
|
|
||||||
<p className="font-medium">{text}</p>
|
|
||||||
</OverlayWrapper>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if (status === 'error') {
|
||||||
|
stateContent = (
|
||||||
|
<>
|
||||||
|
<StateContentWrapper>
|
||||||
|
<XCircleIcon className="h-10 w-10 fill-red-500" title="Error" />
|
||||||
|
<p className="font-medium">{text}</p>
|
||||||
|
</StateContentWrapper>{' '}
|
||||||
|
<Button type="button" intent="text" onClick={() => setFormState({ status: 'edit' })}>
|
||||||
|
Закрыть
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stateContent) return false;
|
||||||
|
|
||||||
|
return <OverlayWrapper>{stateContent}</OverlayWrapper>;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,17 +1,16 @@
|
|||||||
'use client';
|
'use client';
|
||||||
import { Buttons } from './Buttons';
|
import * as Common from './Common';
|
||||||
import { FormContext, FormContextProvider } from './context/form-context';
|
import { FormContext, FormContextProvider } from './context/form-context';
|
||||||
import { Elements } from './Elements';
|
import * as Documents from './Documents';
|
||||||
import { Files } from './Files';
|
|
||||||
import { Header } from './Header';
|
import { Header } from './Header';
|
||||||
import { Overlay } from './Overlay';
|
import { Overlay } from './Overlay';
|
||||||
import type { Props } from './types';
|
import type { FormComponentProps } from './types';
|
||||||
import { createUrl } from '@/utils/url';
|
import { createUrl } from '@/utils/url';
|
||||||
|
import { Background, Divider } from '@repo/ui';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { Background, Divider } from 'ui';
|
|
||||||
|
|
||||||
function Content(props: Props) {
|
function Content(props: FormComponentProps) {
|
||||||
const { title } = props;
|
const { title } = props;
|
||||||
const { pageUrlParams } = useContext(FormContext);
|
const { pageUrlParams } = useContext(FormContext);
|
||||||
|
|
||||||
@ -19,16 +18,17 @@ function Content(props: Props) {
|
|||||||
<Background className="relative flex w-full flex-col gap-2 p-5">
|
<Background className="relative flex w-full flex-col gap-2 p-5">
|
||||||
<Overlay />
|
<Overlay />
|
||||||
<Header title={title} link={'/ius' + createUrl({ ...pageUrlParams, route: '/conditions' })} />
|
<Header title={title} link={'/ius' + createUrl({ ...pageUrlParams, route: '/conditions' })} />
|
||||||
<Elements {...props} />
|
<Common.Elements {...props} />
|
||||||
|
<Common.Buttons />
|
||||||
<Divider />
|
<Divider />
|
||||||
<Files {...props} />
|
<Documents.Files {...props} />
|
||||||
|
<Documents.Buttons />
|
||||||
<Divider />
|
<Divider />
|
||||||
<Buttons />
|
|
||||||
</Background>
|
</Background>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function withContext<T extends Props>(Component: FC<T>) {
|
function withContext<T extends FormComponentProps>(Component: FC<T>) {
|
||||||
return (props: T) => {
|
return (props: T) => {
|
||||||
const { pageUrlParams } = props;
|
const { pageUrlParams } = props;
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
|
import type { CombinedDocuments } from '@/api/ius/tools';
|
||||||
import type * as IUS from '@/api/ius/types';
|
import type * as IUS from '@/api/ius/types';
|
||||||
import type { PageUrlParams } from '@/utils/url';
|
import type { PageUrlParams } from '@/utils/url';
|
||||||
|
|
||||||
export type Props = {
|
export type FormComponentProps = {
|
||||||
|
readonly combinedDocuments: CombinedDocuments;
|
||||||
readonly data: IUS.ResponseGetData;
|
readonly data: IUS.ResponseGetData;
|
||||||
readonly documentTypes: IUS.ResponseDocumentTypes;
|
|
||||||
readonly documents: IUS.ResponseDocuments;
|
|
||||||
readonly metaData: IUS.ResponseMetaData;
|
readonly metaData: IUS.ResponseMetaData;
|
||||||
readonly pageUrlParams: PageUrlParams;
|
readonly pageUrlParams: PageUrlParams;
|
||||||
readonly title: string;
|
readonly title: string;
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import { getEnv } from '@/config/env';
|
import { getClientEnv } from '@/config/env';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import logo from 'public/assets/images/logo-primary.svg';
|
import logo from 'public/assets/images/logo-primary.svg';
|
||||||
import logoDev from 'public/assets/images/logo-primary-dev.svg';
|
import logoDev from 'public/assets/images/logo-primary-dev.svg';
|
||||||
|
|
||||||
const env = getEnv();
|
const env = getClientEnv();
|
||||||
|
|
||||||
export function Logo() {
|
export function Logo() {
|
||||||
return <Image priority alt="logo" src={env.USE_DEV_COLORS ? logoDev : logo} height="24" />;
|
return (
|
||||||
|
<Image priority alt="logo" src={env.NEXT_PUBLIC_USE_DEV_COLORS ? logoDev : logo} height="24" />
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import type { MetaObject } from '@/api/ius/types';
|
import type { MetaObject } from '@/api/ius/types';
|
||||||
import { Checkbox, Input, InputNumber, Textarea } from 'ui';
|
import { Checkbox, Input, InputNumber, Textarea } from '@repo/ui';
|
||||||
|
|
||||||
function wrapMap<C, T extends Record<MetaObject['fieldType'], C>>(arg: T) {
|
function wrapMap<C, T extends Record<MetaObject['fieldType'], C>>(arg: T) {
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mapFieldTypeElement = wrapMap({
|
export const mapFieldTypeElement = wrapMap({
|
||||||
|
BIGSTRING: Textarea,
|
||||||
CHECKBOX: Checkbox,
|
CHECKBOX: Checkbox,
|
||||||
DECIMAL: InputNumber,
|
DECIMAL: InputNumber,
|
||||||
INT: InputNumber,
|
INT: InputNumber,
|
||||||
STRING: Input,
|
STRING: Input,
|
||||||
TEXTAREA: Textarea,
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const envSchema = require('./schema/env.js');
|
const { clientEnvSchema, serverEnvSchema } = require('./schema/env');
|
||||||
|
|
||||||
const getEnv = () => envSchema.parse(process.env);
|
const getClientEnv = () => clientEnvSchema.parse(process.env);
|
||||||
|
const getServerEnv = () => serverEnvSchema.parse(process.env);
|
||||||
|
|
||||||
module.exports = { getEnv };
|
module.exports = { getClientEnv, getServerEnv };
|
||||||
|
|||||||
@ -2,7 +2,15 @@ const { z } = require('zod');
|
|||||||
|
|
||||||
const envSchema = z.object({
|
const envSchema = z.object({
|
||||||
URL_IUS_DIRECT: z.string(),
|
URL_IUS_DIRECT: z.string(),
|
||||||
USE_DEV_COLORS: z.string().optional(),
|
NEXT_PUBLIC_USE_DEV_COLORS: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = envSchema;
|
const serverEnvSchema = envSchema.pick({
|
||||||
|
URL_IUS_DIRECT: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const clientEnvSchema = envSchema.pick({
|
||||||
|
NEXT_PUBLIC_USE_DEV_COLORS: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = { envSchema, serverEnvSchema, clientEnvSchema };
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import { getEnv } from './env';
|
import { getServerEnv } from './env';
|
||||||
import proxyUrls from '@/constants/urls';
|
import proxyUrls from '@/constants/urls';
|
||||||
import { isServer } from '@/utils/common';
|
import { isServer } from '@/utils/common';
|
||||||
|
|
||||||
export function getUrls() {
|
export function getUrls() {
|
||||||
if (isServer()) {
|
if (isServer()) {
|
||||||
const env = getEnv();
|
const env = getServerEnv();
|
||||||
const { URL_IUS_DIRECT } = env;
|
const { URL_IUS_DIRECT } = env;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { getEnv } from '../config/env';
|
import { getClientEnv } from '../config/env';
|
||||||
|
|
||||||
export const COLORS_PROD = {
|
export const COLORS_PROD = {
|
||||||
COLOR_DANGER: '#B20004',
|
COLOR_DANGER: '#B20004',
|
||||||
@ -12,5 +12,5 @@ export const COLORS_DEV = {
|
|||||||
COLOR_SECONDARY: '#c54a84',
|
COLOR_SECONDARY: '#c54a84',
|
||||||
COLOR_TERTIARTY: '#FF9112',
|
COLOR_TERTIARTY: '#FF9112',
|
||||||
};
|
};
|
||||||
const env = getEnv();
|
const env = getClientEnv();
|
||||||
export const COLORS = env.USE_DEV_COLORS ? COLORS_DEV : COLORS_PROD;
|
export const COLORS = env.NEXT_PUBLIC_USE_DEV_COLORS ? COLORS_DEV : COLORS_PROD;
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const envSchema = require('./config/schema/env');
|
const { envSchema } = require('./config/schema/env');
|
||||||
const urls = require('./constants/urls');
|
const urls = require('./constants/urls');
|
||||||
|
|
||||||
const env = envSchema.parse(process.env);
|
const env = envSchema.parse(process.env);
|
||||||
|
|
||||||
const favicons = fs.readdirSync('./public/favicon/prod');
|
const favicons = fs.readdirSync('./public/favicon/prod');
|
||||||
const faviconSubPath = env.USE_DEV_COLORS ? '/favicon/dev' : '/favicon/prod';
|
const faviconSubPath = env.NEXT_PUBLIC_USE_DEV_COLORS ? '/favicon/dev' : '/favicon/prod';
|
||||||
function buildFaviconRewrite(source) {
|
function buildFaviconRewrite(source) {
|
||||||
return {
|
return {
|
||||||
destination: String.prototype.concat(faviconSubPath, source),
|
destination: String.prototype.concat(faviconSubPath, source),
|
||||||
@ -24,7 +24,7 @@ const nextConfig = {
|
|||||||
outputFileTracingRoot: path.join(__dirname, '../../'),
|
outputFileTracingRoot: path.join(__dirname, '../../'),
|
||||||
},
|
},
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
transpilePackages: ['ui', 'radash'],
|
transpilePackages: ['@repo/ui', 'radash'],
|
||||||
async rewrites() {
|
async rewrites() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -34,6 +34,7 @@ const nextConfig = {
|
|||||||
...favicons.map((fileName) => buildFaviconRewrite(`/${fileName}`)),
|
...favicons.map((fileName) => buildFaviconRewrite(`/${fileName}`)),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
env,
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = nextConfig;
|
||||||
|
|||||||
@ -10,21 +10,21 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@heroicons/react": "^2.0.18",
|
"@heroicons/react": "^2.0.18",
|
||||||
"next": "^14.0.3",
|
"@repo/tsconfig": "workspace:*",
|
||||||
|
"@repo/ui": "workspace:*",
|
||||||
|
"next": "^14.1.0",
|
||||||
"radash": "^11.0.0",
|
"radash": "^11.0.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"tsconfig": "*",
|
|
||||||
"ui": "*",
|
|
||||||
"wretch": "^2.7.0",
|
"wretch": "^2.7.0",
|
||||||
"zod": "^3.22.4",
|
"zod": "^3.22.4",
|
||||||
"zustand": "^4.4.6"
|
"zustand": "^4.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/forms": "^0.5.6",
|
"@tailwindcss/forms": "^0.5.6",
|
||||||
"@types/node": "^20.9.0",
|
"@types/node": "^20.10.0",
|
||||||
"@types/react": "^18.2.37",
|
"@types/react": "^18.2.39",
|
||||||
"@types/react-dom": "^18.2.15",
|
"@types/react-dom": "^18.2.17",
|
||||||
"@vchikalkin/eslint-config-awesome": "^1.1.5",
|
"@vchikalkin/eslint-config-awesome": "^1.1.5",
|
||||||
"autoprefixer": "^10.4.16",
|
"autoprefixer": "^10.4.16",
|
||||||
"eslint": "^8.53.0",
|
"eslint": "^8.53.0",
|
||||||
|
|||||||
21
apps/web/public/manifest.webmanifest
Normal file
21
apps/web/public/manifest.webmanifest
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"background_color": "#fff",
|
||||||
|
"description": "External | Эволюция",
|
||||||
|
"display": "standalone",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"sizes": "192x192",
|
||||||
|
"src": "/android-chrome-192x192.png",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"sizes": "512x512",
|
||||||
|
"src": "/android-chrome-512x512.png",
|
||||||
|
"type": "image/png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"name": "External | Эволюция",
|
||||||
|
"short_name": "External | Эволюция",
|
||||||
|
"start_url": "/",
|
||||||
|
"theme_color": "#fff"
|
||||||
|
}
|
||||||
@ -15,6 +15,7 @@ type FormState = {
|
|||||||
resetValidation: () => void;
|
resetValidation: () => void;
|
||||||
setValidation: (input: { name: string } & ElementValidation) => void;
|
setValidation: (input: { name: string } & ElementValidation) => void;
|
||||||
setValue: ({ name, value }: { name: string; value: Values[number] }) => void;
|
setValue: ({ name, value }: { name: string; value: Values[number] }) => void;
|
||||||
|
status?: 'init' | 'edited';
|
||||||
validation: Record<string, ElementValidation | undefined>;
|
validation: Record<string, ElementValidation | undefined>;
|
||||||
values: Values;
|
values: Values;
|
||||||
};
|
};
|
||||||
@ -24,10 +25,12 @@ export const useFormStore = create<FormState>((set) => ({
|
|||||||
init: (values) =>
|
init: (values) =>
|
||||||
set(() => ({
|
set(() => ({
|
||||||
defaultValues: values,
|
defaultValues: values,
|
||||||
|
status: 'init',
|
||||||
values,
|
values,
|
||||||
})),
|
})),
|
||||||
reset: () =>
|
reset: () =>
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
|
status: 'init',
|
||||||
validation: {},
|
validation: {},
|
||||||
values: state.defaultValues,
|
values: state.defaultValues,
|
||||||
})),
|
})),
|
||||||
@ -44,6 +47,7 @@ export const useFormStore = create<FormState>((set) => ({
|
|||||||
})),
|
})),
|
||||||
setValue: ({ name, value }) =>
|
setValue: ({ name, value }) =>
|
||||||
set((state) => ({
|
set((state) => ({
|
||||||
|
status: 'edited',
|
||||||
validation: {
|
validation: {
|
||||||
...state.validation,
|
...state.validation,
|
||||||
[name]: undefined,
|
[name]: undefined,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"extends": "tsconfig/nextjs.json",
|
"extends": "@repo/tsconfig/nextjs.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"plugins": [{ "name": "next" }],
|
"plugins": [{ "name": "next" }],
|
||||||
"paths": {
|
"paths": {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type * as t from '@/api/ius/types';
|
import type * as t from '@/api/ius/types';
|
||||||
import { HttpError } from 'ui';
|
import { HttpError } from '@repo/ui';
|
||||||
import type { WretchError } from 'wretch/types';
|
import type { WretchError } from 'wretch/types';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
20
docker-compose.yml
Normal file
20
docker-compose.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
version: '3.3'
|
||||||
|
services:
|
||||||
|
external_client:
|
||||||
|
environment:
|
||||||
|
- URL_IUS_DIRECT=${URL_IUS_DIRECT}
|
||||||
|
- NEXT_PUBLIC_USE_DEV_COLORS=${NEXT_PUBLIC_USE_DEV_COLORS}
|
||||||
|
build:
|
||||||
|
args:
|
||||||
|
- URL_IUS_DIRECT=${URL_IUS_DIRECT}
|
||||||
|
- NEXT_PUBLIC_USE_DEV_COLORS=${NEXT_PUBLIC_USE_DEV_COLORS}
|
||||||
|
context: .
|
||||||
|
dockerfile: ./apps/web/Dockerfile
|
||||||
|
networks:
|
||||||
|
- external_network
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
networks:
|
||||||
|
external_network:
|
||||||
|
external:
|
||||||
|
name: external_network
|
||||||
13
package.json
13
package.json
@ -7,7 +7,7 @@
|
|||||||
"lint:fix": "dotenv -e .env.local turbo run lint:fix",
|
"lint:fix": "dotenv -e .env.local turbo run lint:fix",
|
||||||
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
|
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
|
||||||
"prepare": "husky install",
|
"prepare": "husky install",
|
||||||
"precommit": "yarn format && yarn lint:fix",
|
"precommit": "pnpm format && pnpm lint:fix",
|
||||||
"clean": "turbo run clean"
|
"clean": "turbo run clean"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -17,15 +17,14 @@
|
|||||||
"lint-staged": "^15.0.2",
|
"lint-staged": "^15.0.2",
|
||||||
"prettier": "^3.0.3",
|
"prettier": "^3.0.3",
|
||||||
"prettier-plugin-tailwindcss": "^0.5.6",
|
"prettier-plugin-tailwindcss": "^0.5.6",
|
||||||
"tsconfig": "*",
|
"@repo/tsconfig": "workspace:*",
|
||||||
"turbo": "latest"
|
"turbo": "latest"
|
||||||
},
|
},
|
||||||
"name": "Evo.External.App",
|
"name": "Evo.External.App",
|
||||||
"packageManager": "yarn@1.22.19",
|
"packageManager": "pnpm@8.9.0",
|
||||||
"workspaces": [
|
"engines": {
|
||||||
"apps/*",
|
"node": ">=18"
|
||||||
"packages/*"
|
},
|
||||||
],
|
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{js,jsx,ts,tsx}": [
|
"*.{js,jsx,ts,tsx}": [
|
||||||
"eslint --ignore-pattern **/graphql/* --ext js,jsx,ts,tsx --quiet --fix --"
|
"eslint --ignore-pattern **/graphql/* --ext js,jsx,ts,tsx --quiet --fix --"
|
||||||
|
|||||||
@ -2,20 +2,19 @@
|
|||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
"$schema": "https://json.schemastore.org/tsconfig",
|
||||||
"display": "Default",
|
"display": "Default",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": false,
|
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"declarationMap": true,
|
"declarationMap": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"incremental": false,
|
||||||
"inlineSources": false,
|
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"moduleResolution": "node",
|
"lib": ["es2022", "DOM", "DOM.Iterable"],
|
||||||
"noUnusedLocals": false,
|
"module": "NodeNext",
|
||||||
"noUnusedParameters": false,
|
"moduleDetection": "force",
|
||||||
"preserveWatchOutput": true,
|
"moduleResolution": "NodeNext",
|
||||||
|
"noUncheckedIndexedAccess": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"strictNullChecks": true
|
"target": "ES2022"
|
||||||
},
|
}
|
||||||
"exclude": ["node_modules"]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,18 +4,10 @@
|
|||||||
"extends": "./base.json",
|
"extends": "./base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"plugins": [{ "name": "next" }],
|
"plugins": [{ "name": "next" }],
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"declaration": false,
|
|
||||||
"declarationMap": false,
|
|
||||||
"incremental": true,
|
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"noEmit": true
|
||||||
"module": "esnext",
|
}
|
||||||
"noEmit": true,
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"strict": false,
|
|
||||||
"target": "es5"
|
|
||||||
},
|
|
||||||
"include": ["src", "next-env.d.ts"],
|
|
||||||
"exclude": ["node_modules"]
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "tsconfig",
|
"name": "@repo/tsconfig",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@ -3,9 +3,6 @@
|
|||||||
"display": "React Library",
|
"display": "React Library",
|
||||||
"extends": "./base.json",
|
"extends": "./base.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx"
|
||||||
"lib": ["ES2015", "DOM"],
|
|
||||||
"module": "ESNext",
|
|
||||||
"target": "es6"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,7 @@ const variants = cva(
|
|||||||
'border border-primary text-primary-500 hover:bg-primary-500 hover:text-white',
|
'border border-primary text-primary-500 hover:bg-primary-500 hover:text-white',
|
||||||
secondary:
|
secondary:
|
||||||
'bg-primary-50 text-primary-500 border border-transparent hover:bg-primary-100 hover:text-primary-600',
|
'bg-primary-50 text-primary-500 border border-transparent hover:bg-primary-100 hover:text-primary-600',
|
||||||
|
text: 'bg-none text-primary-500 hover:bg-primary-50',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ export const InputFile = forwardRef<HTMLInputElement, InputProps>((props, ref) =
|
|||||||
type="file"
|
type="file"
|
||||||
className="file:bg-primary-50 file:text-primary-500 hover:file:bg-primary-100 block w-full text-sm
|
className="file:bg-primary-50 file:text-primary-500 hover:file:bg-primary-100 block w-full text-sm
|
||||||
text-slate-500 file:mr-4 file:rounded-sm file:border-0
|
text-slate-500 file:mr-4 file:rounded-sm file:border-0
|
||||||
file:px-4 file:py-2 file:text-sm
|
file:px-4 file:py-2 file:text-sm file:font-semibold
|
||||||
file:font-semibold hover:file:cursor-pointer"
|
hover:file:cursor-pointer disabled:cursor-not-allowed disabled:opacity-30 disabled:file:cursor-not-allowed"
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ui",
|
"name": "@repo/ui",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"main": "./index.tsx",
|
|
||||||
"types": "./index.tsx",
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
@ -10,15 +8,15 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@turbo/gen": "^1.10.16",
|
"@turbo/gen": "^1.10.16",
|
||||||
"@types/node": "^20.8.10",
|
"@types/node": "^20.10.0",
|
||||||
"@types/react": "^18.2.34",
|
"@types/react": "^18.2.39",
|
||||||
"@types/react-dom": "^18.2.14",
|
"@types/react-dom": "^18.2.17",
|
||||||
"@vchikalkin/eslint-config-awesome": "^1.1.5",
|
"@vchikalkin/eslint-config-awesome": "^1.1.5",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.0.0",
|
"clsx": "^2.0.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"tailwind-merge": "^2.0.0",
|
"tailwind-merge": "^2.0.0",
|
||||||
"tsconfig": "*",
|
"@repo/tsconfig": "workspace:*",
|
||||||
"typescript": "^5.2.2"
|
"typescript": "^5.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"extends": "tsconfig/react-library.json",
|
"extends": "@repo/tsconfig/react-library.json",
|
||||||
"include": ["."],
|
"include": ["."],
|
||||||
"exclude": ["dist", "build", "node_modules"]
|
"exclude": ["dist", "build", "node_modules"]
|
||||||
}
|
}
|
||||||
|
|||||||
7671
pnpm-lock.yaml
generated
Normal file
7671
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
3
pnpm-workspace.yaml
Normal file
3
pnpm-workspace.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
packages:
|
||||||
|
- "apps/*"
|
||||||
|
- "packages/*"
|
||||||
@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"extends": "tsconfig/base.json"
|
"extends": "@repo/tsconfig/base.json"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user