From 71e8d124c60627bc72ce1a0711d196c536db9e1d Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 10 Apr 2024 10:48:33 +0300 Subject: [PATCH] organize components exports --- apps/web/Components/Admin/Layout.tsx | 18 ++++++++++++++++++ apps/web/Components/Admin/index.ts | 2 ++ apps/web/Components/Admin/index.tsx | 1 - apps/web/Components/Calculation/Form/index.jsx | 6 ++---- .../Page.jsx => Calculation/Layout.jsx} | 17 +---------------- .../Output/PaymentsTable/config.ts | 0 .../Output/PaymentsTable/index.jsx | 0 .../{ => Calculation}/Output/Results/config.ts | 0 .../{ => Calculation}/Output/Results/index.jsx | 2 +- .../{ => Calculation}/Output/Validation.jsx | 6 +++--- .../{ => Calculation}/Output/index.jsx | 4 +--- .../Components/Calculation/Settings/index.jsx | 2 +- apps/web/Components/Calculation/index.js | 2 -- apps/web/Components/Calculation/index.ts | 4 ++++ apps/web/pages/admin/cache.jsx | 11 +++++------ apps/web/pages/index.jsx | 10 ++++------ apps/web/pages/unlimited.jsx | 10 ++++------ 17 files changed, 46 insertions(+), 49 deletions(-) create mode 100644 apps/web/Components/Admin/Layout.tsx create mode 100644 apps/web/Components/Admin/index.ts delete mode 100644 apps/web/Components/Admin/index.tsx rename apps/web/Components/{Layout/Page.jsx => Calculation/Layout.jsx} (62%) rename apps/web/Components/{ => Calculation}/Output/PaymentsTable/config.ts (100%) rename apps/web/Components/{ => Calculation}/Output/PaymentsTable/index.jsx (100%) rename apps/web/Components/{ => Calculation}/Output/Results/config.ts (100%) rename apps/web/Components/{ => Calculation}/Output/Results/index.jsx (96%) rename apps/web/Components/{ => Calculation}/Output/Validation.jsx (94%) rename apps/web/Components/{ => Calculation}/Output/index.jsx (96%) delete mode 100644 apps/web/Components/Calculation/index.js create mode 100644 apps/web/Components/Calculation/index.ts diff --git a/apps/web/Components/Admin/Layout.tsx b/apps/web/Components/Admin/Layout.tsx new file mode 100644 index 0000000..1aef008 --- /dev/null +++ b/apps/web/Components/Admin/Layout.tsx @@ -0,0 +1,18 @@ +import { min } from '@/styles/mq'; +import styled from 'styled-components'; +import { Box } from 'ui/grid'; + +export const Layout = styled(Box)` + display: flex; + flex-direction: column; + gap: 10px; + + ${min('laptop')} { + display: grid; + place-items: center; + } + + ${min('desktop-xl')} { + margin: 8px 10% !important; + } +`; diff --git a/apps/web/Components/Admin/index.ts b/apps/web/Components/Admin/index.ts new file mode 100644 index 0000000..b99ea0e --- /dev/null +++ b/apps/web/Components/Admin/index.ts @@ -0,0 +1,2 @@ +export * from './Cache'; +export * from './Layout'; diff --git a/apps/web/Components/Admin/index.tsx b/apps/web/Components/Admin/index.tsx deleted file mode 100644 index 6e79f06..0000000 --- a/apps/web/Components/Admin/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export { CacheQueries } from './Cache'; diff --git a/apps/web/Components/Calculation/Form/index.jsx b/apps/web/Components/Calculation/Form/index.jsx index 5448eee..2fd28b9 100644 --- a/apps/web/Components/Calculation/Form/index.jsx +++ b/apps/web/Components/Calculation/Form/index.jsx @@ -44,13 +44,13 @@ const ComponentWrapper = styled.div` } `; -function Form({ prune }) { +export function Form({ prune }) { return ( {formTabs .filter((tab) => !prune?.includes(tab.id)) - .map(({ id, title, Component }) => ( + .map(({ Component, id, title }) => ( @@ -61,5 +61,3 @@ function Form({ prune }) { ); } - -export default Form; diff --git a/apps/web/Components/Layout/Page.jsx b/apps/web/Components/Calculation/Layout.jsx similarity index 62% rename from apps/web/Components/Layout/Page.jsx rename to apps/web/Components/Calculation/Layout.jsx index fcd4bd6..d52a1cc 100644 --- a/apps/web/Components/Layout/Page.jsx +++ b/apps/web/Components/Calculation/Layout.jsx @@ -2,7 +2,7 @@ import { min } from '@/styles/mq'; import styled from 'styled-components'; import { Box } from 'ui/grid'; -export const Grid = styled(Box)` +export const Layout = styled(Box)` display: flex; flex-direction: column; gap: 10px; @@ -22,18 +22,3 @@ export const Grid = styled(Box)` margin: 8px 10% !important; } `; - -export const AdminGrid = styled(Box)` - display: flex; - flex-direction: column; - gap: 10px; - - ${min('laptop')} { - display: grid; - place-items: center; - } - - ${min('desktop-xl')} { - margin: 8px 10% !important; - } -`; diff --git a/apps/web/Components/Output/PaymentsTable/config.ts b/apps/web/Components/Calculation/Output/PaymentsTable/config.ts similarity index 100% rename from apps/web/Components/Output/PaymentsTable/config.ts rename to apps/web/Components/Calculation/Output/PaymentsTable/config.ts diff --git a/apps/web/Components/Output/PaymentsTable/index.jsx b/apps/web/Components/Calculation/Output/PaymentsTable/index.jsx similarity index 100% rename from apps/web/Components/Output/PaymentsTable/index.jsx rename to apps/web/Components/Calculation/Output/PaymentsTable/index.jsx diff --git a/apps/web/Components/Output/Results/config.ts b/apps/web/Components/Calculation/Output/Results/config.ts similarity index 100% rename from apps/web/Components/Output/Results/config.ts rename to apps/web/Components/Calculation/Output/Results/config.ts diff --git a/apps/web/Components/Output/Results/index.jsx b/apps/web/Components/Calculation/Output/Results/index.jsx similarity index 96% rename from apps/web/Components/Output/Results/index.jsx rename to apps/web/Components/Calculation/Output/Results/index.jsx index 7487274..b9af6c6 100644 --- a/apps/web/Components/Output/Results/index.jsx +++ b/apps/web/Components/Calculation/Output/Results/index.jsx @@ -22,7 +22,7 @@ const Wrapper = styled.div` `; const Results = observer(() => { - const { $results, $process } = useStore(); + const { $process, $results } = useStore(); const resultsValues = toJS($results.values); // eslint-disable-next-line no-negated-condition diff --git a/apps/web/Components/Output/Validation.jsx b/apps/web/Components/Calculation/Output/Validation.jsx similarity index 94% rename from apps/web/Components/Output/Validation.jsx rename to apps/web/Components/Calculation/Output/Validation.jsx index e404ded..239559f 100644 --- a/apps/web/Components/Output/Validation.jsx +++ b/apps/web/Components/Calculation/Output/Validation.jsx @@ -41,7 +41,7 @@ function getElementsErrors({ $calculation, $process }) { }); } -function getPaymentsTableErrors({ $tables, $process }) { +function getPaymentsTableErrors({ $process, $tables }) { const { payments } = $tables; const errors = payments.validation.getErrors(); const title = payments.validation.params.err_title; @@ -58,7 +58,7 @@ function getPaymentsTableErrors({ $tables, $process }) { )); } -function getInsuranceTableErrors({ $tables, $process }) { +function getInsuranceTableErrors({ $process, $tables }) { const { insurance } = $tables; const errors = insurance.validation.getErrors(); const title = insurance.validation.params.err_title; @@ -75,7 +75,7 @@ function getInsuranceTableErrors({ $tables, $process }) { )); } -function getFingapTableErrors({ $tables, $process }) { +function getFingapTableErrors({ $process, $tables }) { const { fingap } = $tables; const errors = fingap.validation.getErrors(); const title = fingap.validation.params.err_title; diff --git a/apps/web/Components/Output/index.jsx b/apps/web/Components/Calculation/Output/index.jsx similarity index 96% rename from apps/web/Components/Output/index.jsx rename to apps/web/Components/Calculation/Output/index.jsx index c39734d..7b80501 100644 --- a/apps/web/Components/Output/index.jsx +++ b/apps/web/Components/Calculation/Output/index.jsx @@ -42,7 +42,7 @@ const Wrapper = styled(Background)` } `; -const Output = observer(() => { +export const Output = observer(() => { const { $results } = useStore(); const [activeKey, setActiveKey] = useState(undefined); const { hasErrors } = useErrors(); @@ -69,5 +69,3 @@ const Output = observer(() => { ); }); - -export default Output; diff --git a/apps/web/Components/Calculation/Settings/index.jsx b/apps/web/Components/Calculation/Settings/index.jsx index 7c140bd..82d8948 100644 --- a/apps/web/Components/Calculation/Settings/index.jsx +++ b/apps/web/Components/Calculation/Settings/index.jsx @@ -17,7 +17,7 @@ const Wrapper = styled(Background)` } `; -export default function Settings() { +export function Settings() { const { $process } = useStore(); const mainRows = $process.has('Unlimited') diff --git a/apps/web/Components/Calculation/index.js b/apps/web/Components/Calculation/index.js deleted file mode 100644 index 591091d..0000000 --- a/apps/web/Components/Calculation/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default as Form } from './Form'; -export { default as Settings } from './Settings'; diff --git a/apps/web/Components/Calculation/index.ts b/apps/web/Components/Calculation/index.ts new file mode 100644 index 0000000..8b8b747 --- /dev/null +++ b/apps/web/Components/Calculation/index.ts @@ -0,0 +1,4 @@ +export * from './Form'; +export * from './Layout'; +export * from './Output'; +export * from './Settings'; diff --git a/apps/web/pages/admin/cache.jsx b/apps/web/pages/admin/cache.jsx index d88dd1b..cee4ffb 100644 --- a/apps/web/pages/admin/cache.jsx +++ b/apps/web/pages/admin/cache.jsx @@ -1,9 +1,8 @@ import { getQueries } from '@/api/cache/query'; import { getUser } from '@/api/user/query'; import initializeApollo from '@/apollo/client'; -import { CacheQueries } from '@/Components/Admin'; +import * as Admin from '@/Components/Admin'; import { Error } from '@/Components/Common/Error'; -import { AdminGrid } from '@/Components/Layout/Page'; import { adminRoles } from '@/config/users'; import * as CRMTypes from '@/graphql/crm.types'; import { getPageTitle } from '@/utils/page'; @@ -12,16 +11,16 @@ import Head from 'next/head'; function Content() { return ( - + {getPageTitle('Управление кэшем')} - - + + ); } -export default function Admin(props) { +export default function Page(props) { if (props.statusCode !== 200) return ; return ; diff --git a/apps/web/pages/index.jsx b/apps/web/pages/index.jsx index 4290c42..bf30e5a 100644 --- a/apps/web/pages/index.jsx +++ b/apps/web/pages/index.jsx @@ -2,8 +2,6 @@ import { getUser } from '@/api/user/query'; import initializeApollo from '@/apollo/client'; import * as Calculation from '@/Components/Calculation'; import { Error } from '@/Components/Common/Error'; -import { Grid } from '@/Components/Layout/Page'; -import Output from '@/Components/Output'; import { defaultRoles } from '@/config/users'; import * as CRMTypes from '@/graphql/crm.types'; import * as hooks from '@/process/hooks'; @@ -18,18 +16,18 @@ function Content() { hooks.useReactions(); return ( - + {getPageTitle()} - - + + ); } -export default function Home(props) { +export default function Page(props) { if (props.statusCode !== 200) return ; return ; diff --git a/apps/web/pages/unlimited.jsx b/apps/web/pages/unlimited.jsx index 98630f8..dc0bbce 100644 --- a/apps/web/pages/unlimited.jsx +++ b/apps/web/pages/unlimited.jsx @@ -1,8 +1,6 @@ import { makeGetServerSideProps } from '.'; import * as Calculation from '@/Components/Calculation'; import { Error } from '@/Components/Common/Error'; -import { Grid } from '@/Components/Layout/Page'; -import Output from '@/Components/Output'; import { unlimitedRoles } from '@/config/users'; import * as hooks from '@/process/hooks'; import { useStore } from '@/stores/hooks'; @@ -20,18 +18,18 @@ function Content() { hooks.useReactions(); return ( - + {getPageTitle('Без ограничений')} - - + + ); } -export default function Unlimited(props) { +export default function Page(props) { if (props.statusCode !== 200) return ; return ;