stores/hydate: pass default data in page
This commit is contained in:
parent
f485ba9659
commit
b72afae4c7
@ -3,6 +3,7 @@ import { useApolloClient } from '@apollo/client';
|
||||
import initializeApollo from 'apollo/client';
|
||||
import * as Calculation from 'Components/Calculation';
|
||||
import Output from 'Components/Output';
|
||||
import defaultOptions from 'config/default-options';
|
||||
import type { GetServerSideProps } from 'next';
|
||||
import Head from 'next/head';
|
||||
import calculateValidationReactions from 'process/calculate/reactions/validation';
|
||||
@ -72,13 +73,13 @@ export const getServerSideProps: GetServerSideProps = async ({ req }) => {
|
||||
});
|
||||
|
||||
const apolloClient = initializeApollo();
|
||||
const { options } = await getCRMData(apolloClient, user);
|
||||
const { options: crmOptions } = await getCRMData(apolloClient, user);
|
||||
|
||||
return {
|
||||
props: {
|
||||
user,
|
||||
calculation: {
|
||||
options,
|
||||
options: { ...crmOptions, ...defaultOptions },
|
||||
},
|
||||
|
||||
initialApolloState: apolloClient.cache.extract(),
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
/* eslint-disable object-curly-newline */
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
import defaultOptions from 'config/default-options';
|
||||
import { createContext } from 'react';
|
||||
import RootStore from './root';
|
||||
|
||||
@ -18,9 +17,7 @@ export function initializeStore(initialData) {
|
||||
_store.$user.hydrate(user);
|
||||
if (calculation?.values) _store.$calculation.$values.hydrate(calculation.values);
|
||||
if (calculation?.statuses) _store.$calculation.$status.hydrate(calculation.statuses);
|
||||
if (calculation?.options) {
|
||||
_store.$calculation.$options.hydrate({ ...defaultOptions, ...calculation.options });
|
||||
}
|
||||
if (calculation?.options) _store.$calculation.$options.hydrate(calculation.options);
|
||||
|
||||
if (tables?.insurance) {
|
||||
_store.$tables.insurance.hydrate({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user