process: move init hooks to /hooks dir
This commit is contained in:
parent
5e9e897535
commit
c347095ded
@ -1,5 +1,5 @@
|
||||
import type { Elements } from '../config/map/actions';
|
||||
import { useProcessContext } from '@/process/hooks';
|
||||
import { useProcessContext } from '@/process/hooks/common';
|
||||
import { useStatus } from '@/stores/calculation/statuses/hooks';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import type { ComponentType } from 'react';
|
||||
@ -21,7 +21,8 @@ export default function buildAction<T>(
|
||||
return (
|
||||
<Component
|
||||
action={() =>
|
||||
import(`process/${processName}/action`).then((module) => module.action(context))}
|
||||
import(`process/${processName}/action`).then((module) => module.action(context))
|
||||
}
|
||||
status={status}
|
||||
{...props}
|
||||
/>
|
||||
|
||||
@ -3,9 +3,9 @@ import initializeApollo from '@/apollo/client';
|
||||
import * as Calculation from '@/Components/Calculation';
|
||||
import { Error } from '@/Components/Common/Error';
|
||||
import Output from '@/Components/Output';
|
||||
import { useReactions } from '@/process/hooks';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import * as init from '@/process/init';
|
||||
import { useInsuranceData, useMainData, useReactions } from '@/process/hooks';
|
||||
import { getInitialData } from '@/process/hooks/init';
|
||||
import { min } from '@/styles/mq';
|
||||
import { dehydrate, QueryClient } from '@tanstack/react-query';
|
||||
import Head from 'next/head';
|
||||
@ -37,8 +37,8 @@ const Grid = styled(Box)`
|
||||
`;
|
||||
|
||||
function Home(props) {
|
||||
init.useMainData();
|
||||
init.useInsuranceData();
|
||||
useMainData();
|
||||
useInsuranceData();
|
||||
useReactions();
|
||||
|
||||
if (props.statusCode !== 200) return <Error {...props} />;
|
||||
@ -86,7 +86,7 @@ export const getServerSideProps = async ({ req }) => {
|
||||
props: { statusCode: 403 },
|
||||
};
|
||||
}
|
||||
const { values, options } = await init.getInitialData(apolloClient, user);
|
||||
const { values, options } = await getInitialData(apolloClient, user);
|
||||
|
||||
return {
|
||||
props: {
|
||||
|
||||
@ -1,2 +1,3 @@
|
||||
export * from './common';
|
||||
export * from './init';
|
||||
export * from './reactions';
|
||||
|
||||
@ -20,7 +20,7 @@ import * as subsidyImportProgram from '@/process/subsidy-import-program';
|
||||
import * as supplierAgent from '@/process/supplier-agent';
|
||||
import * as usedPl from '@/process/used-pl';
|
||||
|
||||
export type Config = {
|
||||
type Config = {
|
||||
prune: string[];
|
||||
};
|
||||
|
||||
@ -28,7 +28,7 @@ function useProcess({ reactions }: Process, config?: Config) {
|
||||
const context = useProcessContext();
|
||||
|
||||
Object.keys(reactions).forEach((name) => {
|
||||
if (config?.prune?.length && !config?.prune.includes(name)) {
|
||||
if (!config?.prune.includes(name)) {
|
||||
const injector = reactions[name];
|
||||
injector(context);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user