Compare commits

...

10 Commits

Author SHA1 Message Date
vchikalkin
bf18d52a97 pages/index: pass error text to CRMError 2023-01-11 09:24:24 +03:00
vchikalkin
5553166788 [2] fix serve static files 2023-01-10 23:36:47 +03:00
vchikalkin
3554d95656 fix serve static files 2023-01-10 20:54:46 +03:00
vchikalkin
e08174d59f fix run 2023-01-10 20:49:34 +03:00
vchikalkin
cd4d87de91 fix build 2023-01-10 20:15:42 +03:00
vchikalkin
09061c16fa scripts: update graphql-update script 2023-01-10 18:54:18 +03:00
vchikalkin
7968bf7194 project: move env and /scripts to root 2023-01-10 17:35:40 +03:00
vchikalkin
04ecdfc7b7 tests: setup jest 2023-01-10 16:48:12 +03:00
vchikalkin
dd89340477 packages: setup husky 2023-01-10 16:21:14 +03:00
vchikalkin
fb768e164d reconfigure repo with turbo 2023-01-10 14:46:27 +03:00
286 changed files with 9495 additions and 15889 deletions

View File

@ -1,7 +1,3 @@
Dockerfile .git
.dockerignore
node_modules
npm-debug.log
README.md README.md
.next node_modules
.git

View File

@ -5,5 +5,6 @@ yarn.lock
package-lock.json package-lock.json
**/*.test.js **/*.test.js
coverage coverage
mocks .eslintrc.js
graphql **/*.config.js
**/scripts

10
.eslintrc.js Normal file
View File

@ -0,0 +1,10 @@
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ['custom'],
settings: {
next: {
rootDir: ['apps/*/', 'packages/*/'],
},
},
};

View File

@ -1,89 +0,0 @@
{
"root": true,
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"next",
"prettier",
"airbnb",
"airbnb-typescript",
"plugin:@typescript-eslint/recommended",
"plugin:unicorn/recommended"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"parser": "@typescript-eslint/parser",
"plugins": ["react", "prettier", "@typescript-eslint", "unicorn", "testing-library"],
"rules": {
"linebreak-style": ["error", "windows"],
"comma-dangle": "off",
"@typescript-eslint/comma-dangle": ["off"],
"react/react-in-jsx-scope": "off",
"react/jsx-props-no-spreading": "off",
"react/jsx-filename-extension": [2, { "extensions": [".js", ".jsx", ".ts", ".tsx"] }],
"react/forbid-prop-types": "off",
"react/require-default-props": [
"error",
{
"ignoreFunctionalComponents": true
}
],
"import/extensions": "off",
"object-curly-newline": [
"warn",
{
"ObjectExpression": "always",
"ObjectPattern": { "multiline": true },
"ImportDeclaration": "never",
"ExportDeclaration": { "multiline": true, "minProperties": 3 }
}
],
"lines-between-class-members": "off",
"@typescript-eslint/lines-between-class-members": ["off"],
"indent": "off",
"@typescript-eslint/indent": ["off"],
"react/jsx-no-bind": [
"error",
{
"ignoreDOMComponents": false,
"ignoreRefs": false,
"allowArrowFunctions": false,
"allowFunctions": true,
"allowBind": false
}
],
"newline-before-return": "warn",
"@typescript-eslint/consistent-type-imports": "error",
"react/prop-types": "off",
// Airbnb prefers forEach
"unicorn/no-array-for-each": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/no-null": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/no-array-reduce": "off",
"unicorn/prefer-module": "off",
"unicorn/text-encoding-identifier-case": "off",
"unicorn/filename-case": [
"error",
{
"case": "kebabCase",
"ignore": ["^.*.(jsx|tsx)$"]
}
],
"import/no-unresolved": "warn",
"implicit-arrow-linebreak": "warn",
"operator-linebreak": "warn",
"function-paren-newline": "warn"
},
"overrides": [
// Only uses Testing Library lint rules in test files
{
"files": ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
"extends": ["plugin:testing-library/react"]
}
]
}

27
.gitignore vendored
View File

@ -6,15 +6,16 @@ node_modules
.pnp.js .pnp.js
# testing # testing
/coverage coverage
# next.js # next.js
.next/ .next/
out/ out/
# production
build build
# other
dist/
# misc # misc
.DS_Store .DS_Store
*.pem *.pem
@ -26,22 +27,10 @@ yarn-error.log*
.pnpm-debug.log* .pnpm-debug.log*
# local env files # local env files
.env*.local .env.local
.env.development.local
# vercel .env.test.local
.vercel .env.production.local
# typescript
*.tsbuildinfo
# Yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
# turbo # turbo
.turbo .turbo

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh" . "$(dirname -- "$0")/_/husky.sh"
yarn precommit yarn precommit

View File

@ -1,3 +1,4 @@
.next .next
public public
graphql graphql
node_modules

View File

@ -4,7 +4,7 @@
"bracketSpacing": true, "bracketSpacing": true,
"htmlWhitespaceSensitivity": "ignore", "htmlWhitespaceSensitivity": "ignore",
"insertPragma": false, "insertPragma": false,
"jsxBracketSameLine": false, "bracketSameLine": false,
"jsxSingleQuote": false, "jsxSingleQuote": false,
"printWidth": 100, "printWidth": 100,
"proseWrap": "preserve", "proseWrap": "preserve",

View File

@ -17,5 +17,6 @@
"source.fixAll.eslint": true, "source.fixAll.eslint": true,
"source.fixAll.format": true "source.fixAll.format": true
}, },
"workbench.editor.labelFormat": "short" "workbench.editor.labelFormat": "short",
"eslint.workingDirectories": [{ "directory": "apps/web", "changeProcessCWD": true }]
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,9 +0,0 @@
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: '@yarnpkg/plugin-typescript'
- path: .yarn/plugins/@yarnpkg/plugin-outdated.cjs
spec: 'https://mskelton.dev/yarn-outdated/v3'
yarnPath: .yarn/releases/yarn-3.3.0.cjs

View File

@ -1,12 +0,0 @@
{
"name": "tools",
"version": "0.0.0",
"main": "./index.tsx",
"types": "./index.tsx",
"license": "MIT",
"dependencies": {
"mobx": "^6.7.0",
"radash": "^10.3.0",
"ui": "*"
}
}

View File

@ -1,4 +0,0 @@
/* eslint-disable unicorn/filename-case */
export { ConfigProvider } from 'antd';
export { default as ru_RU } from 'antd/lib/locale/ru_RU';

View File

@ -1,20 +0,0 @@
{
"name": "ui",
"version": "0.0.0",
"main": "./index.tsx",
"types": "./index.tsx",
"license": "MIT",
"devDependencies": {
"@types/react": "18.0.20",
"@types/rebass": "^4.0.10",
"@types/styled-components": "^5"
},
"dependencies": {
"@ant-design/icons": "^4.8.0",
"antd": "4.24.5",
"react": "^18.2.0",
"rebass": "^4.0.7",
"styled-components": "^5.3.6",
"use-debounce": "^9.0.2"
}
}

View File

@ -1,7 +0,0 @@
import { breakpoints } from './mq';
const theme = {
breakpoints,
};
export default theme;

View File

@ -1,56 +0,0 @@
# Install dependencies only when needed
FROM node:16-alpine AS deps
# 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
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
# If using npm with a `package-lock.json` comment out above and use below instead
# COPY package.json package-lock.json ./
# RUN npm ci
# Rebuild the source code only when needed
FROM node:16-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
RUN yarn build
# If using npm comment out above and use below instead
# RUN npm run build
# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT 3000
CMD ["node", "server.js"]

View File

@ -1,34 +1,65 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). # Turborepo Docker starter
## Getting Started This is an official Docker starter Turborepo.
First, run the development server: ## What's inside?
```bash This turborepo uses [Yarn](https://classic.yarnpkg.com/lang/en/) as a package manager. It includes the following packages/apps:
npm run dev
# or ### Apps and Packages
yarn dev
- `web`: a [Next.js](https://nextjs.org/) app
- `api`: an [Express](https://expressjs.com/) server
- `ui`: ui: a React component library
- `eslint-config-custom`: `eslint` configurations for client side applications (includes `eslint-config-next` and `eslint-config-prettier`)
- `eslint-config-custom-server`: `eslint` configurations for server side applications (includes `eslint-config-next` and `eslint-config-prettier`)
- `scripts`: Jest configurations
- `logger`: Isomorphic logger (a small wrapper around console.log)
- `tsconfig`: tsconfig.json;s used throughout the monorepo
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
## Using this example
Run the following command:
```sh
npx degit vercel/turbo/examples/with-docker with-docker
cd with-docker
yarn install
git init . && git add . && git commit -m "Init"
``` ```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. ### Docker
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. This repo is configured to be built with Docker, and Docker compose. To build all apps in this repo:
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. ```
# Create a network, which allows containers to communicate
# with each other, by using their container name as a hostname
docker network create app_network
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. # Build prod using new BuildKit engine
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -f docker-compose.yml build --parallel
## Learn More # Start prod in detached mode
docker-compose -f docker-compose.yml up -d
```
To learn more about Next.js, take a look at the following resources: Open http://localhost:3000.
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. To shutdown all running containers:
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! ```
# Stop all running containers
docker kill $(docker ps -q) && docker rm $(docker ps -a -q)
```
## Deploy on Vercel ### Utilities
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. This Turborepo has some additional tools already setup for you:
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. - [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Jest](https://jestjs.io) test runner for all things JavaScript
- [Prettier](https://prettier.io) for code formatting

View File

@ -1,10 +0,0 @@
/* eslint-disable import/prefer-default-export */
import type { User } from './types';
export function love(user: User) {
const superUsers: string[] = JSON.parse(process.env.USERS_SUPER || '');
// eslint-disable-next-line no-param-reassign
if (superUsers?.includes(user.username)) user.displayName += '🧡';
return user;
}

View File

@ -1,12 +0,0 @@
/** @type {import('apollo').ApolloConfig} */
module.exports = {
client: {
service: {
name: 'crmgraphql',
url: process.env.URL_CRM_GRAPHQL_DIRECT,
localSchemaFile: './graphql/crm.schema.graphql',
},
excludes: ['graphql/**/*'],
includes: ['pages/**/*', 'process/**/*', 'Components/**/*'],
},
};

5
apps/web/.eslintignore Normal file
View File

@ -0,0 +1,5 @@
.next
public
*.config.js
mocks
graphql

8
apps/web/.eslintrc.js Normal file
View File

@ -0,0 +1,8 @@
module.exports = {
root: true,
extends: ['custom'],
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
};

View File

@ -2,9 +2,9 @@ import { toJS } from 'mobx';
import { observer } from 'mobx-react-lite'; import { observer } from 'mobx-react-lite';
import { useStore } from 'stores/hooks'; import { useStore } from 'stores/hooks';
import styled from 'styled-components'; import styled from 'styled-components';
import { Flex } from 'ui';
import Alert from 'ui/elements/Alert'; import Alert from 'ui/elements/Alert';
import Table from 'ui/elements/Table'; import Table from 'ui/elements/Table';
import { Flex } from 'ui/grid';
import { columns } from './config'; import { columns } from './config';
const Grid = styled(Flex)` const Grid = styled(Flex)`

View File

@ -1,9 +1,9 @@
import { observer } from 'mobx-react-lite'; import { observer } from 'mobx-react-lite';
import { useStore } from 'stores/hooks'; import { useStore } from 'stores/hooks';
import styled from 'styled-components'; import styled from 'styled-components';
import { Flex } from 'ui';
import Alert from 'ui/elements/Alert'; import Alert from 'ui/elements/Alert';
import Table from 'ui/elements/Table'; import Table from 'ui/elements/Table';
import { Flex } from 'ui/grid';
import { columns } from './config'; import { columns } from './config';
const Grid = styled(Flex)` const Grid = styled(Flex)`

View File

@ -1,4 +1,4 @@
import { Flex } from 'ui/grid'; import { Flex } from 'ui';
import renderFormRows from '../../lib/render-rows'; import renderFormRows from '../../lib/render-rows';
import { id, rows, title } from './config'; import { id, rows, title } from './config';
import FinGAPTable from './FinGAPTable'; import FinGAPTable from './FinGAPTable';

View File

@ -1,6 +1,6 @@
import { observer } from 'mobx-react-lite'; import { observer } from 'mobx-react-lite';
import { useStore } from 'stores/hooks'; import { useStore } from 'stores/hooks';
import { Flex } from 'ui/grid'; import { Flex } from 'ui';
import elementsRender from '../../config/elements-render'; import elementsRender from '../../config/elements-render';
import { elements } from './config'; import { elements } from './config';
@ -17,8 +17,9 @@ function PaymentsParams() {
const graphType = $calculation.element('radioGraphType').getValue(); const graphType = $calculation.element('radioGraphType').getValue();
switch (graphType) { switch (graphType) {
case 100_000_000: case 100_000_000: {
return null; return null;
}
case 100_000_001: { case 100_000_001: {
return <Flex flexDirection="column">{selectSeasonType}</Flex>; return <Flex flexDirection="column">{selectSeasonType}</Flex>;
} }
@ -37,8 +38,9 @@ function PaymentsParams() {
return null; return null;
} }
default: default: {
break; break;
}
} }
} }

View File

@ -2,10 +2,10 @@ import { computed } from 'mobx';
import { observer } from 'mobx-react-lite'; import { observer } from 'mobx-react-lite';
import { useStore } from 'stores/hooks'; import { useStore } from 'stores/hooks';
import styled from 'styled-components'; import styled from 'styled-components';
import { min } from 'styles/mq';
import Alert from 'ui/elements/Alert'; import Alert from 'ui/elements/Alert';
import Table from 'ui/elements/Table'; import Table from 'ui/elements/Table';
import { Box, Flex } from 'ui/grid'; import { Box, Flex } from 'ui/grid';
import { min } from 'ui/mq';
import { columns } from './config'; import { columns } from './config';
const Grid = styled(Flex)` const Grid = styled(Flex)`

View File

@ -1,7 +1,7 @@
import Background from 'Components/Layout/Background';
import styled from 'styled-components'; import styled from 'styled-components';
import Background from 'ui/elements/layout/Background'; import { min } from 'styles/mq';
import Tabs from 'ui/elements/layout/Tabs'; import Tabs from 'ui/elements/layout/Tabs';
import { min } from 'ui/mq';
import AddProduct from './AddProduct'; import AddProduct from './AddProduct';
import CreateKP from './CreateKP'; import CreateKP from './CreateKP';
import Insurance from './Insurance'; import Insurance from './Insurance';

View File

@ -1,6 +1,6 @@
import Background from 'Components/Layout/Background';
import styled from 'styled-components'; import styled from 'styled-components';
import Background from 'ui/elements/layout/Background'; import { min } from 'styles/mq';
import { min } from 'ui/mq';
import renderFormRows from '../lib/render-rows'; import renderFormRows from '../lib/render-rows';
import { rows } from './config'; import { rows } from './config';

View File

@ -1,7 +1,7 @@
import { MAX_FRANCHISE, MAX_LEASING_PERIOD } from 'constants/values'; import { MAX_FRANCHISE, MAX_LEASING_PERIOD } from 'constants/values';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { formatter, formatterExtra, parser } from 'tools/number'; import { formatter, formatterExtra, parser } from 'tools/number';
import DownloadOutlined from 'ui/elements/icons/DownloadOutlined'; import { DownloadOutlined } from 'ui/elements/icons';
import CurrencyAddon from '../addons/currency-addon'; import CurrencyAddon from '../addons/currency-addon';
import type { ElementsProps } from './elements-components'; import type { ElementsProps } from './elements-components';

View File

@ -183,12 +183,15 @@ const overrideRender: Partial<Record<keyof typeof map, RenderProps>> = {
const graphType = $calculation.element('radioGraphType').getValue(); const graphType = $calculation.element('radioGraphType').getValue();
switch (graphType) { switch (graphType) {
case 100_000_001: case 100_000_001: {
return <span>Тип дегрессии</span>; return <span>Тип дегрессии</span>;
case 100_000_003: }
case 100_000_003: {
return <span>Тип сезонности</span>; return <span>Тип сезонности</span>;
default: }
default: {
return <span>{titles.selectSeasonType}</span>; return <span>{titles.selectSeasonType}</span>;
}
} }
}); });

View File

@ -8,6 +8,13 @@ function handleRetry() {
const RetryButton = <Button action={handleRetry} text="Попробовать еще раз" />; const RetryButton = <Button action={handleRetry} text="Попробовать еще раз" />;
export function CRMError() { export function CRMError({ error }) {
return <Result status="500" title="500" subTitle="Ошибка соединения с CRM" extra={RetryButton} />; return (
<Result
status="500"
title="CRM не отвечает. Попробуйте позже."
subTitle={`${error || ''}`}
extra={RetryButton}
/>
);
} }

View File

@ -1,8 +1,8 @@
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { getUser } from 'api/user/query'; import { getUser } from 'api/user/query';
import styled from 'styled-components'; import styled from 'styled-components';
import { Flex } from 'ui/grid'; import { min } from 'styles/mq';
import { min } from 'ui/mq'; import { Flex } from 'ui';
const UserText = styled.span` const UserText = styled.span`
margin: 0; margin: 0;

View File

@ -1,6 +1,6 @@
import styled from 'styled-components'; import styled from 'styled-components';
import { Box } from '../../grid'; import { min } from 'styles/mq';
import { min } from '../../mq'; import { Box } from 'ui/grid';
const Background = styled(Box)` const Background = styled(Box)`
background: #fff; background: #fff;

View File

@ -1,7 +1,7 @@
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { Flex } from 'ui/grid'; import { min } from 'styles/mq';
import { min } from 'ui/mq'; import { Flex } from 'ui';
const ElementTitle = styled.label` const ElementTitle = styled.label`
color: rgba(0, 0, 0, 0.75); color: rgba(0, 0, 0, 0.75);

View File

@ -1,7 +1,7 @@
/* eslint-disable import/no-unresolved */ /* eslint-disable import/no-unresolved */
import styled from 'styled-components'; import styled from 'styled-components';
import { Flex } from 'ui/grid'; import { min } from 'styles/mq';
import { min } from 'ui/mq'; import { Flex } from 'ui';
import Auth from './Auth'; import Auth from './Auth';
import Logo from './Logo'; import Logo from './Logo';

View File

@ -1,8 +1,8 @@
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 styled from 'styled-components'; import styled from 'styled-components';
import { Flex } from 'ui/grid'; import { min } from 'styles/mq';
import { min } from 'ui/mq'; import { Flex } from 'ui';
import styles from './Logo.module.css'; import styles from './Logo.module.css';
const ImageWrapper = styled.div` const ImageWrapper = styled.div`

View File

@ -1,6 +1,6 @@
/* eslint-disable react/prop-types */ /* eslint-disable react/prop-types */
/* eslint-disable import/no-unresolved */ /* eslint-disable import/no-unresolved */
import { Flex } from 'ui/grid'; import { Flex } from 'ui';
import Header from './Header'; import Header from './Header';
export default function Layout({ children }) { export default function Layout({ children }) {

View File

@ -3,9 +3,9 @@ import { toJS } from 'mobx';
import { observer } from 'mobx-react-lite'; import { observer } from 'mobx-react-lite';
import { useStore } from 'stores/hooks'; import { useStore } from 'stores/hooks';
import styled from 'styled-components'; import styled from 'styled-components';
import { min } from 'styles/mq';
import Text from 'ui/elements/Text'; import Text from 'ui/elements/Text';
import { Box } from 'ui/grid'; import { Box } from 'ui/grid';
import { min } from 'ui/mq';
import { formatters, id, title, titles } from './config'; import { formatters, id, title, titles } from './config';
const Grid = styled(Box)` const Grid = styled(Box)`

View File

@ -1,7 +1,7 @@
import Background from 'Components/Layout/Background';
import styled from 'styled-components'; import styled from 'styled-components';
import Background from 'ui/elements/layout/Background'; import { min } from 'styles/mq';
import Tabs from 'ui/elements/layout/Tabs'; import Tabs from 'ui/elements/layout/Tabs';
import { min } from 'ui/mq';
import PaymentsTable from './PaymentsTable'; import PaymentsTable from './PaymentsTable';
import Results from './Results'; import Results from './Results';
import Validation from './Validation'; import Validation from './Validation';

50
apps/web/Dockerfile Normal file
View File

@ -0,0 +1,50 @@
# This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update both files!
FROM node:alpine AS builder
# 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 update
# Set working directory
WORKDIR /app
RUN yarn global add turbo
RUN yarn global add dotenv-cli
COPY . .
RUN turbo prune --scope=web --docker
# Add lockfile and package.json's of isolated subworkspace
FROM node:alpine AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app
# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
RUN yarn install
# Build the project
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json
COPY .env .env
RUN yarn dotenv -e .env turbo run build --filter=web...
FROM node:alpine AS runner
WORKDIR /app
# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs
COPY --from=installer /app/apps/web/next.config.js .
COPY --from=installer /app/apps/web/package.json .
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
CMD node apps/web/server.js

30
apps/web/README.md Normal file
View File

@ -0,0 +1,30 @@
## Getting Started
First, run the development server:
```bash
yarn dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn/foundations/about-nextjs) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_source=github.com&utm_medium=referral&utm_campaign=turborepo-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

View File

@ -0,0 +1,15 @@
/* eslint-disable import/prefer-default-export */
import { publicRuntimeConfigSchema } from 'config/schema/runtime-config';
import getConfig from 'next/config';
import type { User } from './types';
const { publicRuntimeConfig } = getConfig();
const { USERS_SUPER } = publicRuntimeConfigSchema.parse(publicRuntimeConfig);
export function love(user: User) {
const superUsers: string[] = JSON.parse(USERS_SUPER);
// eslint-disable-next-line no-param-reassign
if (superUsers?.includes(user.username)) user.displayName += '🧡';
return user;
}

11
apps/web/apollo.config.js Normal file
View File

@ -0,0 +1,11 @@
/** @type {import('apollo').ApolloConfig} */
module.exports = {
client: {
service: {
name: 'crmgraphql',
localSchemaFile: `${__dirname}/graphql/crm.schema.graphql`,
},
excludes: ['**/graphql/**/*'],
includes: ['**/pages/**/*', '**/process/**/*', '**/Components/**/*'],
},
};

Some files were not shown because too many files have changed in this diff Show More