insurance-table: some code improvements
rename finGAP => fingap
This commit is contained in:
parent
351949ff23
commit
7b83dbb248
@ -5,12 +5,12 @@ import { columns } from './config';
|
||||
|
||||
const FinGAPTable = observer(() => {
|
||||
const { $tables } = useStore();
|
||||
const { finGAP } = $tables;
|
||||
const { fingap } = $tables;
|
||||
|
||||
return (
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={finGAP.risks}
|
||||
dataSource={fingap.risks}
|
||||
rowSelection={{
|
||||
type: 'checkbox',
|
||||
onChange: (_, selectedRows) => {
|
||||
@ -21,7 +21,7 @@ const FinGAPTable = observer(() => {
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
finGAP.setSelectedKeys(selectedKeys);
|
||||
fingap.setSelectedKeys(selectedKeys);
|
||||
},
|
||||
}}
|
||||
pagination={false}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import type { BaseOption, Status } from 'Elements/types';
|
||||
|
||||
export type Keys = 'osago' | 'kasko' | 'finGAP';
|
||||
export type Keys = 'osago' | 'kasko' | 'fingap';
|
||||
|
||||
export type RowValues = {
|
||||
key: Keys;
|
||||
@ -17,6 +17,4 @@ export type RowOptions = {
|
||||
[ValueName in Values]?: BaseOption<RowValues[ValueName]>[];
|
||||
};
|
||||
|
||||
export type RowStatuses = Record<Values, Status> & {
|
||||
key: Keys;
|
||||
};
|
||||
export type RowStatuses = Record<Values, Status>;
|
||||
|
||||
@ -46,7 +46,7 @@ export const defaultOptions: Record<Insurance.Keys, Insurance.RowOptions> = {
|
||||
},
|
||||
],
|
||||
},
|
||||
finGAP: {
|
||||
fingap: {
|
||||
insured: [
|
||||
{
|
||||
label: 'ЛП',
|
||||
@ -88,7 +88,7 @@ export const defaultValues: Insurance.RowValues[] = [
|
||||
insTerm: null,
|
||||
},
|
||||
{
|
||||
key: 'finGAP',
|
||||
key: 'fingap',
|
||||
policyType: 'Safe Finance',
|
||||
insuranceCompany: null,
|
||||
insured: 100_000_000,
|
||||
@ -97,29 +97,26 @@ export const defaultValues: Insurance.RowValues[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const defaultStatuses: Insurance.RowStatuses[] = [
|
||||
{
|
||||
key: 'osago',
|
||||
export const defaultStatuses: Record<Insurance.Keys, Insurance.RowStatuses> = {
|
||||
osago: {
|
||||
insTerm: 'Disabled',
|
||||
insCost: 'Default',
|
||||
insuranceCompany: 'Default',
|
||||
insured: 'Default',
|
||||
policyType: 'Default',
|
||||
},
|
||||
{
|
||||
key: 'kasko',
|
||||
kasko: {
|
||||
insTerm: 'Disabled',
|
||||
insCost: 'Default',
|
||||
insuranceCompany: 'Default',
|
||||
insured: 'Default',
|
||||
policyType: 'Default',
|
||||
},
|
||||
{
|
||||
key: 'finGAP',
|
||||
fingap: {
|
||||
insCost: 'Disabled',
|
||||
insuranceCompany: 'Default',
|
||||
insured: 'Default',
|
||||
insTerm: 'Default',
|
||||
policyType: 'Default',
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
4
process/init/__generated__/GetInsuranceData.ts
generated
4
process/init/__generated__/GetInsuranceData.ts
generated
@ -19,7 +19,7 @@ export interface GetInsuranceData_kasko {
|
||||
label: string | null;
|
||||
}
|
||||
|
||||
export interface GetInsuranceData_finGAP {
|
||||
export interface GetInsuranceData_fingap {
|
||||
__typename: "account";
|
||||
value: any | null;
|
||||
label: string | null;
|
||||
@ -37,7 +37,7 @@ export interface GetInsuranceData {
|
||||
/**
|
||||
* Контрагенты. statecode по умолчанию 0
|
||||
*/
|
||||
finGAP: (GetInsuranceData_finGAP | null)[] | null;
|
||||
fingap: (GetInsuranceData_fingap | null)[] | null;
|
||||
}
|
||||
|
||||
export interface GetInsuranceDataVariables {
|
||||
|
||||
@ -51,7 +51,7 @@ const QUERY_GET_INSURANCE_DATA = gql`
|
||||
label: name
|
||||
}
|
||||
|
||||
finGAP: accounts(
|
||||
fingap: accounts(
|
||||
evo_account_type: $evo_account_type
|
||||
evo_type_ins_policy: [100000002]
|
||||
statecode: 0
|
||||
@ -78,7 +78,7 @@ export async function getCRMData(apolloClient: ApolloClient<NormalizedCache>, us
|
||||
});
|
||||
|
||||
const {
|
||||
data: { kasko, osago, finGAP },
|
||||
data: { kasko, osago, fingap },
|
||||
} = await apolloClient.query<GetInsuranceData>({
|
||||
query: QUERY_GET_INSURANCE_DATA,
|
||||
});
|
||||
@ -90,8 +90,8 @@ export async function getCRMData(apolloClient: ApolloClient<NormalizedCache>, us
|
||||
kasko: {
|
||||
insuranceCompany: normalizeOptions(kasko),
|
||||
},
|
||||
finGAP: {
|
||||
insuranceCompany: normalizeOptions(finGAP),
|
||||
fingap: {
|
||||
insuranceCompany: normalizeOptions(fingap),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -6,11 +6,11 @@ import PaymentsTable from './payments';
|
||||
export default class TablesStore {
|
||||
payments: PaymentsTable;
|
||||
insurance: InsuranceTable;
|
||||
finGAP: FinGAPTable;
|
||||
fingap: FinGAPTable;
|
||||
|
||||
constructor(rootStore: RootStore) {
|
||||
this.payments = new PaymentsTable(rootStore);
|
||||
this.insurance = new InsuranceTable(rootStore);
|
||||
this.finGAP = new FinGAPTable(rootStore);
|
||||
this.fingap = new FinGAPTable(rootStore);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import Validation from '../validation';
|
||||
export interface InsuranceTableData {
|
||||
values?: Insurance.RowValues[];
|
||||
options?: Record<Insurance.Keys, Insurance.RowOptions>;
|
||||
statuses?: Insurance.RowStatuses[];
|
||||
statuses?: Record<Insurance.Keys, Insurance.RowStatuses>;
|
||||
}
|
||||
|
||||
export default class InsuranceTable {
|
||||
@ -17,7 +17,7 @@ export default class InsuranceTable {
|
||||
validation: Validation;
|
||||
values: Insurance.RowValues[] = insuranceTableConfig.defaultValues;
|
||||
options: Record<Insurance.Keys, Insurance.RowOptions> = insuranceTableConfig.defaultOptions;
|
||||
statuses: Insurance.RowStatuses[] = insuranceTableConfig.defaultStatuses;
|
||||
statuses: Record<Insurance.Keys, Insurance.RowStatuses> = insuranceTableConfig.defaultStatuses;
|
||||
|
||||
constructor(rootStore: RootStore) {
|
||||
this.root = rootStore;
|
||||
@ -61,17 +61,11 @@ export default class InsuranceTable {
|
||||
};
|
||||
|
||||
getRowStatuses(key: Insurance.Keys) {
|
||||
const rowIndex = this.values.findIndex((x) => x.key === key);
|
||||
|
||||
return this.statuses[rowIndex];
|
||||
return this.statuses[key];
|
||||
}
|
||||
|
||||
setRowStatuses = (key: Insurance.Keys, rowStatuses: Insurance.RowStatuses) => {
|
||||
const rowIndex = this.values.findIndex((x) => x.key === key);
|
||||
|
||||
if (rowIndex >= 0) {
|
||||
mergeWith(this.statuses[rowIndex], rowStatuses);
|
||||
}
|
||||
mergeWith(this.statuses[key], rowStatuses);
|
||||
};
|
||||
|
||||
reset = () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user