diff --git a/.eslintignore b/.eslintignore index faae669..7bc1f8c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,4 +6,5 @@ package-lock.json **/*.test.js coverage mocks -graphql \ No newline at end of file +graphql +**/__generated__ \ No newline at end of file diff --git a/Elements/types.ts b/Elements/types.ts index e9d4e0f..e8d8cd3 100644 --- a/Elements/types.ts +++ b/Elements/types.ts @@ -8,7 +8,7 @@ export type BaseElementProps = { help?: string; }; -export type BaseOption = { +export type BaseOption = { label: string; - value: T; + value: any; }; diff --git a/__generated__/globalTypes.ts b/__generated__/globalTypes.ts new file mode 100644 index 0000000..8d9b7dd --- /dev/null +++ b/__generated__/globalTypes.ts @@ -0,0 +1,12 @@ +/* tslint:disable */ +/* eslint-disable */ +// @generated +// This file was automatically generated and should not be edited. + +//============================================================== +// START Enums and Input Objects +//============================================================== + +//============================================================== +// END Enums and Input Objects +//============================================================== diff --git a/apollo.config.js b/apollo.config.js index a21b545..13473cf 100644 --- a/apollo.config.js +++ b/apollo.config.js @@ -3,8 +3,10 @@ module.exports = { client: { service: { name: 'crmgraphql', + // url: process.env.URL_CRM_GRAPHQL_DIRECT, localSchemaFile: './graphql/crm.schema.graphql', }, excludes: ['graphql/**/*'], + includes: ['pages/**/*', 'process/**/*'], }, }; diff --git a/graphql/crm.schema.graphql b/graphql/crm.schema.graphql index de67fe8..40b5fb4 100644 --- a/graphql/crm.schema.graphql +++ b/graphql/crm.schema.graphql @@ -50,12 +50,13 @@ type Query { account(accountid: Uuid!): account """Контрагенты. statecode по умолчанию 0""" - accounts(evo_accnumber: String, evo_account_type: [Int!], evo_broker_accountid: Uuid, evo_fin_department_accountid: Uuid, evo_id_elt: String, evo_inn: String, evo_kpp: String, evo_legal_form: Int, evo_type_ins_policy: [Int!], ownerid: Uuid, owner_domainname: String, statecode: Int): [account] + accounts(evo_accnumber: String, evo_account_type: [Int!], evo_agency_agreementid: Uuid, evo_broker_accountid: Uuid, evo_fin_department_accountid: Uuid, evo_id_elt: String, evo_inn: String, evo_inn_param: StringParamInput, evo_kpp: String, evo_kpp_param: StringParamInput, evo_legal_form: Int, evo_type_ins_policy: [Int!], ownerid: Uuid, owner_domainname: String, statecode: Int): [account] """Брокер. statecode по умолчанию 0""" broker_agents(ownnerid: Uuid!, statecode: Int): [account] contacts(parentcustomerid: Uuid, statecode: Int): [contact] email(activityid: Uuid!): email + entity_schemas(logical_name: String): [entity_schema] evo_addcontract(evo_addcontractid: Uuid!): evo_addcontract evo_addproduct(evo_addproductid: Uuid!): evo_addproduct evo_addproduct_type(evo_addproduct_typeid: Uuid!): evo_addproduct_type @@ -66,16 +67,19 @@ type Query { evo_bank_detailses(evo_accountid: Uuid, orderby: OrderByInput, statecode: Int = 0): [evo_bank_details] evo_baseproduct(evo_baseproductid: Uuid!): evo_baseproduct evo_baseproducts(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_relation: [Int!], statecode: Int): [evo_baseproduct] + evo_brand(evo_brandid: Uuid!): evo_brand evo_brands(evo_vehicle_type: [Int!], statecode: Int): [evo_brand] evo_businessunits(statecode: Int): [evo_businessunit] evo_client_risks(statecode: Int): [evo_client_risk] evo_client_types(statecode: Int): [evo_client_type] evo_coefficients(evo_client_riskid: Uuid, evo_client_typeid: Uuid, evo_corfficient_type: Int, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_job_titleid: Uuid, evo_max_period_param: DecimalParamInput, evo_min_period_param: DecimalParamInput, statecode: Int): [evo_coefficient] evo_contract(evo_contractid: Uuid!): evo_contract - evo_contracts(evo_name: String, statecode: Int): [evo_contract] + evo_contracts(evo_accountid: Uuid, evo_name: String, statecode: Int): [evo_contract] evo_countries(evo_code_numeric: String): [evo_countryGraphQL] evo_country(evo_countryid: Uuid!): evo_countryGraphQL evo_currencychanges(evo_coursedate_param: DateParamInput, evo_ref_transactioncurrency: Uuid, statecode: Int): [evo_currencychange] + evo_debtwork_contract(debtworkContractId: Uuid!): evo_debtwork_contract + evo_debtwork_contracts(evo_accountid: Uuid, evo_statuscodeid: Uuid, statecode: Int): [evo_debtwork_contract] evo_equipments(evo_modelid: Uuid, statecode: Int): [evo_equipment] evo_external_supplier_codes(evo_id: String, statecode: Int): [evo_external_supplier_code] evo_external_system_request(evo_external_system_requestid: Uuid!): evo_external_system_request @@ -111,6 +115,7 @@ type Query { evo_sot_coefficient_types(statecode: Int): [evo_sot_coefficient_type] evo_statuscode(evo_id: String, evo_statuscodeid: Uuid): evo_statuscode evo_statuscodes(statecode: Int): [evo_statuscode] + evo_subject_incidents(statecode: Int): [evo_subject_incident] evo_subsidies(evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, statecode: Int): [evo_subsidy] evo_tarif(evo_tarifid: Uuid!): evo_tarif evo_tarifs(evo_balance_holder: [Int!], evo_baseproductid: Uuid, evo_datefrom_param: DateParamInput, evo_dateto_param: DateParamInput, evo_graphtype_exception: [Int!], evo_ins_type: [Int!], evo_max_first_payment_param: DecimalParamInput, evo_max_last_payment_param: DecimalParamInput, evo_max_period_param: DecimalParamInput, evo_min_first_payment_param: DecimalParamInput, evo_min_last_payment_param: DecimalParamInput, evo_min_period_param: DecimalParamInput, evo_used: Boolean, statecode: Int): [evo_tarif] @@ -118,7 +123,10 @@ type Query { """Города. statecode по умолчанию 0""" evo_towns(evo_regionid: Uuid, statecode: Int): [evo_town] + evo_typedocpackages(statecode: Int): [evo_typedocpackage] evo_vehicle_body_type(evo_vehicle_body_typeid: Uuid!): evo_vehicle_body_typeGraphQL + incident(incidentid: Uuid!): incidentGraphQL + incidents(customerid: Uuid, orderby: OrderByInput, statecode: Int): [incidentGraphQL] """ Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName @@ -154,7 +162,137 @@ type Query { } type Mutation { - by(domainName: String): MutationBy + by(systemuserid: Uuid): MutationBy +} + +type entity_schema { + entity_id: String + entity_set_name: String + icon_large_name: String + icon_medium_name: String + icon_small_name: String + logical_name: String + object_type_code: Int! + picklists: [picklist] +} + +scalar Uuid + +input StringParamInput { + eq: String +} + +input DateParamInput { + eq: DateTime + gt: DateTime + gte: DateTime + lt: DateTime + lte: DateTime +} + +input DecimalParamInput { + eq: Decimal + gt: Decimal + gte: Decimal + lt: Decimal + lte: Decimal +} + +input ConditionInput { + conditions: [ConditionInput] + filters: [FilterInput] + logicoperation: LogicOperation! +} + +input GuidParamInput { + eq: Uuid + has: Boolean + in: [Uuid!] +} + +"""The built-in `Decimal` scalar type.""" +scalar Decimal + +input OrderByInput { + fieldName: String + sortingType: SortingType! +} + +type evo_debtwork_contract { + createdon: DateTime + evo_accountid: Uuid + evo_accountidData: account + evo_contractid: Uuid + evo_contractidData: evo_contract + evo_date_change_statuscode: DateTime + evo_db_region_com: String + evo_debtwork_contractid: Uuid + evo_debt_restruct_description: String + evo_documents: [evo_document] + evo_economic_security_com: String + evo_erroneous_pay_contractname: String + evo_inspection_done: Boolean + evo_inspection_impossible: Boolean + evo_inspection_impossible_reason: String + evo_inspection_link_report: String + evo_inspection_systemuserid: Uuid + evo_inspection_systemuseridData: systemuser + evo_insurance_case_dateend: DateTime + evo_leasingobjectid: Uuid + evo_leasingobjectidData: evo_leasingobject + evo_name: String + evo_non_payment_count: Decimal + evo_opportunityid: Uuid + evo_plan_date_transfer_pay: DateTime + evo_redemption_com: String + evo_redemption_type: [Int!] + evo_result_debt_restruct: Boolean + evo_result_error_payment: Boolean + evo_result_inspection: Boolean + evo_result_insurance_case: Boolean + evo_result_redemption: Boolean + evo_result_termination: Boolean + evo_result_wait_payment: Boolean + evo_result_withdrawal: Boolean + evo_statuscodeid: Uuid + evo_statuscodeidData: evo_statuscode + evo_statuscode_reason: String + evo_storage: String + evo_termination_add_registry: Int + evo_termination_com: String + evo_termination_com_lawyer: String + evo_termination_lawyer_systemuserid: Uuid + evo_termination_lawyer_systemuseridData: systemuser + evo_termination_reason_terms: Int + evo_termination_reason_terms_doc: String + evo_termination_reason_terms_text: String + evo_termination_send_notice: Boolean + evo_termination_send_notice_date: DateTime + evo_termination_send_notice_repeat: Boolean + evo_termination_solution: Int + evo_termination_status_work: Int + evo_termination_suspended_until: DateTime + evo_termination_unique_notice: Boolean + evo_withdrawal_businessunitid: Uuid + evo_withdrawal_businessunitidData: businessunit + evo_withdrawal_done: Boolean + evo_withdrawal_impossible: Boolean + evo_withdrawal_impossible_reason: String + evo_withdrawal_issue_agreed: Int + evo_withdrawal_issue_done: Int + evo_withdrawal_issue_done_date: DateTime + evo_withdrawal_parking_addressid: Uuid + evo_withdrawal_parking_addressidData: evo_address + evo_withdrawal_plan_date: DateTime + evo_withdrawal_systemuserid: Uuid + evo_withdrawal_systemuseridData: systemuser + link: String + modifiedon: DateTime + ownerid: Uuid + ownerid_systemuser: Uuid + ownerid_systemuserData: systemuser + ownerid_team: Uuid + toObjectString: String } type account { @@ -171,6 +309,7 @@ type account { evo_address_legal_string: String evo_address_postalid: Uuid evo_address_postalidData: evo_address + evo_agency_agreementid: Uuid evo_bank_detailses(statecode: Int): [evo_bank_details] evo_branch_count: String evo_branch_type: Int @@ -184,6 +323,7 @@ type account { evo_dadatdalog: String evo_dealer_responsible_systemuserid: Uuid evo_div_12month: Boolean + evo_documents(evo_documenttypeid_param: GuidParamInput, latestversion: Boolean = true): [evo_document] evo_economic_security_systemuserid: Uuid evo_employee_count: Int evo_fingap_number_rules: Int @@ -231,6 +371,7 @@ type account { evo_subsidies(statecode: Int): [evo_subsidy] evo_tax_system: Int evo_type_ins_policy: [Int!] + link: String modifiedon: DateTime name: String ownerid: Uuid @@ -244,43 +385,6 @@ type account { toObjectString: String } -scalar Uuid - -input DateParamInput { - eq: DateTime - gt: DateTime - gte: DateTime - lt: DateTime - lte: DateTime -} - -input DecimalParamInput { - eq: Decimal - gt: Decimal - gte: Decimal - lt: Decimal - lte: Decimal -} - -input ConditionInput { - conditions: [ConditionInput] - filters: [FilterInput] - logicoperation: LogicOperation! -} - -input GuidParamInput { - eq: Uuid - has: Boolean -} - -"""The built-in `Decimal` scalar type.""" -scalar Decimal - -input OrderByInput { - fieldName: String - sortingType: SortingType! -} - type contact { birthdate: DateTime contactid: Uuid @@ -289,17 +393,23 @@ type contact { emailaddress2: String emailaddress3: String evo_consent_date: DateTime + evo_docdate: DateTime + evo_docnumber: String evo_fact_addressid: Uuid evo_fact_addressidname: String evo_fullname: String evo_functiontype: [Int!] + evo_functiontypenames: [String] evo_inn: String evo_name_dative: String evo_name_genitive: String evo_no_middle_name: Boolean evo_reg_addressid: Uuid evo_share_capital: Decimal + evo_signer_rule: Boolean evo_signer_rule_basis: Int + evo_signer_rule_basisname: String + evo_signer_rule_basis_add: String firstname: String fullname: String gendercode: Int @@ -383,7 +493,12 @@ type evo_addproduct_type { type evo_baseproduct { createdon: DateTime evo_baseproductid: Uuid + evo_baseproducts(statecode: Int): [evo_baseproduct] evo_brands(statecode: Int): [evo_brand] + evo_calculation_method: [Int!] + evo_coefficients(statecode: Int): [evo_coefficient] + evo_cut_irr_with_bonus: Boolean + evo_cut_proportion_bonus_director: Boolean evo_datefrom: DateTime evo_dateto: DateTime evo_id: String @@ -391,6 +506,7 @@ type evo_baseproduct { evo_name: String evo_relation: [Int!] evo_sale_without_nds: Boolean + evo_scoring_available: Boolean modifiedon: DateTime statecode: Int systemusers(statecode: Int): [systemuser] @@ -427,6 +543,7 @@ type evo_insurance_period { evo_age_drivers: Int evo_base_reward_factor: Decimal evo_base_reward_rub: Decimal + evo_change_insurer_accountid: Uuid evo_close: Boolean evo_comment: String evo_contractid: Uuid @@ -522,6 +639,7 @@ type evo_external_supplier_code { createdon: DateTime evo_accountid: Uuid evo_accountidData: account + evo_available_lead_failure_reason: [Int!] evo_external_supplier_codeid: Uuid evo_id: String evo_manager_systemuserid: Uuid @@ -547,6 +665,7 @@ type evo_statuscode { evo_id: String evo_name: String evo_statuscodeid: Uuid + link: String modifiedon: DateTime toObjectString: String } @@ -567,6 +686,7 @@ type evo_leasingobject { evo_color: String evo_contractid: Uuid evo_create_contract_purchase: Boolean + evo_date_withdrawal: DateTime evo_delivery_time: Int evo_driving_axle: String evo_ecological_class: Int @@ -620,6 +740,7 @@ type evo_leasingobject { evo_vehicle_type_tax: Int evo_vin: String evo_year: Int + link: String modifiedon: DateTime statecode: Int toObjectString: String @@ -632,12 +753,14 @@ type evo_reward_condition { evo_agency_agreementidData: evo_agency_agreement evo_agent_accountid: Uuid evo_brandid: Uuid + evo_calc_reward_rules: Int evo_client_type: Int evo_condition_type: Int evo_datefrom: DateTime evo_dateto: DateTime evo_deactivated: Boolean evo_double_agent_accountid: Uuid + evo_min_reward_summ: Decimal evo_name: String evo_reduce_reward: Boolean evo_reward_conditionid: Uuid @@ -727,6 +850,8 @@ type opportunity { evo_approvallogs: [evo_approvallog] evo_businessunitid: Uuid evo_businessunitidData: businessunit + evo_check_type: [Int!] + evo_check_type_fact: [Int!] evo_client_riskid: Uuid evo_client_riskidData: evo_client_risk evo_comment_description: String @@ -767,6 +892,9 @@ type opportunity { evo_programsolution: Int evo_report_year: Int evo_sfm_comment: [Int!] + evo_solution_average_cost: Int + evo_solution_average_cost_com: String + evo_solution_db: Int evo_statuscodeid: Uuid evo_statuscodeidData: evo_statuscode evo_statuscode_reason: String @@ -800,7 +928,9 @@ type quote { evo_acquisition_costs: Decimal evo_addproduct_types: [evo_addproduct_type] evo_add_bonus_summ: Decimal + evo_add_director_bonus: Decimal evo_add_equipment: Boolean + evo_add_region_director_bonus: Decimal evo_agent_accountid: Uuid evo_agent_reward_conditionid: Uuid evo_agent_reward_summ: Decimal @@ -828,6 +958,7 @@ type quote { evo_check_ins_result: Int evo_client_riskid: Uuid evo_client_typeid: Uuid + evo_coefficien_bonus_reducttion: Decimal evo_comission_perc: Decimal evo_comission_rub: Decimal evo_contact_name: String @@ -866,6 +997,7 @@ type quote { evo_engine_type: Int evo_engine_volume: Decimal evo_equipmentid: Uuid + evo_equip_price: Decimal evo_equity_capital: Decimal evo_exp_drivers: Int evo_fingap_accountid: Uuid @@ -994,6 +1126,8 @@ type quote { evo_price_wthout_discount_nds_sup_currency: Decimal evo_product_risks: [evo_product_risk] evo_programsolution: Int + evo_program_import_subsidyid: Uuid + evo_program_import_subsidy_sum: Decimal evo_pts_type: Int evo_purchases_participation: Boolean evo_quotename: String @@ -1004,6 +1138,8 @@ type quote { evo_recalc_quoteid: Uuid evo_redemption_graph: Boolean evo_regionid: Uuid + evo_region_director_bonus: Decimal + evo_region_director_fingap_bonus: Decimal evo_region_director_nsib_bonus: Decimal evo_registration: Boolean evo_registration_quote: Boolean @@ -1235,6 +1371,7 @@ type evo_impairment_group { type transactioncurrency { createdon: DateTime currencyname: String + currencysymbol: String isocurrencycode: String modifiedon: DateTime statecode: Int @@ -1272,11 +1409,13 @@ type evo_request_payment { evo_corresponding_account: String evo_director_decision: Int evo_director_systemuserid: Uuid + evo_evobank_detailsid: Uuid evo_final_accept: Int evo_finegibddid: Uuid evo_finegibddidData: evo_finegibdd evo_id: String evo_inn: String + evo_insurance_addcontractid: Uuid evo_insurance_periodid: Uuid evo_insurance_policyid: Uuid evo_insurance_policyidData: evo_insurance_policy @@ -1325,6 +1464,8 @@ type evo_contract { evo_acquisition_costs: Decimal evo_act_date: DateTime evo_add_bonus_summ: Decimal + evo_add_director_bonus: Decimal + evo_add_region_director_bonus: Decimal evo_agent_accountid: Uuid evo_agent_reward: Decimal evo_agent_reward_conditionid: Uuid @@ -1348,8 +1489,10 @@ type evo_contract { evo_check_scan_result: Int evo_claim_pledge_agreementid: Uuid evo_client_type: Int + evo_coefficien_bonus_reducttion: Decimal evo_contractid: Uuid evo_contract_status_1c: Int + evo_contract_status_1cname: String evo_contract_status_change_date_in_crm: DateTime evo_contract_status_date_1c: DateTime evo_dateend: DateTime @@ -1371,6 +1514,7 @@ type evo_contract { evo_debt_penalty_fee: Decimal evo_debt_total: Decimal evo_delay_days_count: Int + evo_delay_period: DateTime evo_director_bonus: Decimal evo_director_fingap_bonus: Decimal evo_director_nsib_bonus: Decimal @@ -1390,6 +1534,7 @@ type evo_contract { evo_economic_with_nds_actual: Decimal evo_end_date_of_pledge_claim: DateTime evo_end_date_of_pledge_leasobject: DateTime + evo_equip_price: Decimal evo_expinput_actual_date: DateTime evo_fedres_xml_date: DateTime evo_finegibdds: [evo_finegibdd] @@ -1435,6 +1580,7 @@ type evo_contract { evo_name: String evo_nds_in_price_supplier_currency: Decimal evo_nds_perc: Decimal + evo_nearest_payment_num: String evo_net_irr: Decimal evo_niatinception_msfo: Decimal evo_niatinception_msfo_actual: Decimal @@ -1455,12 +1601,16 @@ type evo_contract { evo_price_without_discount: Decimal evo_price_without_discount_supplier_currency: Decimal evo_price_wthout_discount_nds_sup_currency: Decimal + evo_program_import_subsidyid: Uuid + evo_program_import_subsidy_sum: Decimal evo_purchases_participation: Boolean evo_quoteid: Uuid evo_rate: Decimal evo_rateid: Uuid evo_reason_change_account: Int evo_ref_opportunityid: Uuid + evo_region_director_bonus: Decimal + evo_region_director_fingap_bonus: Decimal evo_region_director_nsib_bonus: Decimal evo_registration_addproductid: Uuid evo_registration_addproductidData: evo_addproduct @@ -1494,6 +1644,7 @@ type evo_contract { evo_telematics_equipment_addproductidData: evo_addproduct evo_telematics_service_addproductid: Uuid evo_termreason: Int + evo_termreasonname: String evo_tracking_addproductid: Uuid evo_tracking_addproductidData: evo_addproduct evo_tracking_addproduct_typeid: Uuid @@ -1505,6 +1656,7 @@ type evo_contract { evo_uncritical_scan: Boolean evo_vehicle_tax_period: Decimal evo_vehicle_tax_year: Decimal + link: String modifiedon: DateTime ownerid: Uuid toObjectString: String @@ -1581,6 +1733,7 @@ type evo_vehicle_body_typeGraphQL { type evo_coefficient { createdon: DateTime + evo_baseproducts(statecode: Int): [evo_baseproduct] evo_businessunitid: Uuid evo_businessunits(statecode: Int): [evo_businessunit] evo_client_riskid: Uuid @@ -1645,6 +1798,7 @@ type evo_tarif { evo_baseproductid: Uuid evo_client_risks(statecode: Int): [evo_client_risk] evo_client_types(statecode: Int): [evo_client_type] + evo_cut_irr_with_bonus_coefficient: Decimal evo_datefrom: DateTime evo_dateto: DateTime evo_delivery_time: [Int!] @@ -1654,6 +1808,7 @@ type evo_tarif { evo_irr: Decimal evo_irr_plan: Decimal evo_leasingobject_types(statecode: Int): [evo_leasingobject_type] + evo_margin_min: Float evo_max_first_payment: Decimal evo_max_irr: Decimal evo_max_last_payment: Decimal @@ -1798,6 +1953,7 @@ type systemuser { fullname: String jobtitle: String lastname: String + link: String middlename: String mobilephone: String modifiedon: DateTime @@ -1868,6 +2024,7 @@ type evo_agency_agreement { evo_agency_agreement_number: String evo_agency_agreement_type: Int evo_agent_accountid: Uuid + evo_agent_accountidData: account evo_bank_detailsid: Uuid evo_boss_comment: String evo_boss_decision: Int @@ -1878,10 +2035,13 @@ type evo_agency_agreement { evo_date_change_statuscode: DateTime evo_director_comment: String evo_director_decision: Int + evo_leasingobject_price: Int evo_name: String evo_number: Int evo_region_director_comment: String evo_region_director_decision: Int + evo_required_reward: Boolean + evo_reward_without_other_agent: Boolean evo_signer_systemuserid: Uuid evo_statuscodeid: Uuid evo_storage: String @@ -1911,6 +2071,8 @@ type evo_addcontract { evo_activdate_insurance: DateTime evo_addcontractid: Uuid evo_add_bonus_summ: Decimal + evo_add_director_bonus: Decimal + evo_add_region_director_bonus: Decimal evo_agent_reward_summ: Decimal evo_age_drivers: Int evo_age_drivers_new: Int @@ -1929,6 +2091,7 @@ type evo_addcontract { evo_businessunitid: Uuid evo_calculation_method: Int evo_calculator_type: Int + evo_calc_checks_disable: Boolean evo_calc_profit: Decimal evo_category: Int evo_category_new: Int @@ -2004,6 +2167,8 @@ type evo_addcontract { evo_engine_type_new: Int evo_engine_volume: Decimal evo_engine_volume_new: Decimal + evo_equip_price: Decimal + evo_equip_price_new: Decimal evo_exp_drivers: Int evo_exp_drivers_new: Int evo_fin_department_reward_conditionid: Uuid @@ -2065,6 +2230,8 @@ type evo_addcontract { evo_net_irr: Decimal evo_niatinception_msfo: Decimal evo_ni_at_inception: Decimal + evo_not_require_signing: Boolean + evo_not_require_signing_send_date: DateTime evo_npvni_msfo: Decimal evo_npvni_msfo_final: Decimal evo_ns_bonus_summ: Decimal @@ -2114,16 +2281,20 @@ type evo_addcontract { evo_price_without_disc_supplier_currency_new: Decimal evo_price_wthout_disc_nds_sup_currency: Decimal evo_price_wthout_disc_nds_sup_currency_new: Decimal + evo_program_import_subsidy_sum: Decimal + evo_program_import_subsidy_sum_new: Decimal evo_prop_type: String evo_prop_type_new: String evo_pts_change: Boolean evo_pts_type: Int evo_pts_type_new: Int evo_quoteid: Uuid + evo_reasons_calc: [Int!] evo_recalculate_demand: Boolean evo_refuse_reason: Int evo_regionid: Uuid evo_regionid_new: Uuid + evo_region_director_bonus: Decimal evo_registration: Int evo_registration_addproduct_typeid: Uuid evo_registration_addproduct_typeid_new: Uuid @@ -2196,6 +2367,7 @@ type email { evo_accountid: Uuid modifiedon: DateTime regardingobjectid_account: Uuid + regardingobjectid_evo_addcontract: Uuid regardingobjectid_evo_contract: Uuid regardingobjectid_evo_insurance_period: Uuid regardingobjectid_evo_insurance_policy: Uuid @@ -2217,6 +2389,7 @@ type evo_bank_details { evo_bank_detailsid: Uuid evo_contactid: Uuid evo_corresponding_account: String + evo_datefrom: DateTime evo_kbk: String evo_name: String evo_payment_account: String @@ -2244,19 +2417,77 @@ type template { toObjectString: String } +type evo_typedocpackage { + createdon: DateTime + evo_account: Boolean + evo_addcontract: Boolean + evo_agency_agreement: Boolean + evo_contract: Boolean + evo_debtwork_contract: Boolean + evo_finegibdd: Boolean + evo_id: String + evo_incident: Boolean + evo_insurance_period: Boolean + evo_name: String + evo_opportunity: Boolean + evo_programsolution: [Int!] + evo_request_payment: Boolean + evo_typedocpackageid: Uuid + modifiedon: DateTime + toObjectString: String +} + +type evo_subject_incident { + createdon: DateTime + evo_group: Int + evo_groupname: String + evo_name: String + evo_subjectid: Uuid + evo_subject_incidentid: Uuid + evo_type_incident: Int + evo_type_incidentname: String + link: String + modifiedon: DateTime + toObjectString: String +} + +type incidentGraphQL { + createdon: DateTime + customerid: Uuid + customerid_account: Uuid + customerid_contact: Uuid + description: String + evo_fast_advice: Boolean + evo_plan_execut_date: DateTime + evo_statuscodeid: Uuid + evo_statuscodeidData: evo_statuscode + evo_storage: String + evo_subject_incidentid: Uuid + evo_subject_incidentidData: evo_subject_incident + evo_taken_work_date: DateTime + evo_typedocpackageid: Uuid + incidentid: Uuid + link: String + modifiedon: DateTime + ownerid: Uuid + owneridData: systemuser + subjectid: Uuid + ticketnumber: String + title: String + toObjectString: String +} + type MutationBy { + associateBankDetailsAndAgencyAgreement_(evo_agency_agreementid: Uuid!, evo_bank_detailsid: Uuid!): Entity createEntity(data: EntityDataInput): Uuid! + createIncident_(contracts: [Uuid!], customerid_account: Uuid, description: String, evo_fast_advice: Boolean, evo_subject_incidentid: Uuid, subjectid: Uuid, title: String): Entity + updateAccount_(accountid: Uuid!, evo_agency_agreementid: Uuid): Entity updateEntity(data: EntityDataInput): Boolean! } -type team { - createdon: DateTime - evo_baseproducts(statecode: Int): [evo_baseproduct] - evo_identity_documents: [evo_identity_document] - modifiedon: DateTime +type picklist { name: String - teamid: Uuid - toObjectString: String + values: [picklist_value] } """The `DateTime` scalar represents an ISO-8601 compliant date time type.""" @@ -2280,6 +2511,56 @@ enum SortingType { ASC } +type businessunit { + businessunitid: Uuid + createdon: DateTime + evo_addressid: Uuid + evo_boss_systemuserid: Uuid + evo_director_systemuserid: Uuid + evo_region_director_systgemuserid: Uuid + evo_region_director_systgemuseridname: String + modifiedon: DateTime + name: String + toObjectString: String +} + +type evo_document { + createdon: DateTime + evo_accountid: Uuid + evo_changed_record_systemuserid: Uuid + evo_changed_record_systemuseridData: systemuser + evo_comment_original: String + evo_comment_previous: String + evo_comment_scan: String + evo_documentid: Uuid + evo_documenttypeid: Uuid + evo_documenttypeidData: evo_documenttype + evo_doc_number: String + evo_init_entity_id: String + evo_init_entity_name: String + evo_name: String + evo_original_correct: Boolean + evo_original_received: Boolean + evo_scan_correct: Boolean + evo_url: String + evo_validity_date: DateTime + evo_version: Int + modifiedon: DateTime + statecode: Int + statuscode: Int + toObjectString: String +} + +type team { + createdon: DateTime + evo_baseproducts(statecode: Int): [evo_baseproduct] + evo_identity_documents: [evo_identity_document] + modifiedon: DateTime + name: String + teamid: Uuid + toObjectString: String +} + type evo_insurance_policy { createdon: DateTime evo_accountid: Uuid @@ -2320,19 +2601,6 @@ type evo_addproductnumber { toObjectString: String } -type businessunit { - businessunitid: Uuid - createdon: DateTime - evo_addressid: Uuid - evo_boss_systemuserid: Uuid - evo_director_systemuserid: Uuid - evo_region_director_systgemuserid: Uuid - evo_region_director_systgemuseridname: String - modifiedon: DateTime - name: String - toObjectString: String -} - type evo_approvallog { createdon: DateTime evo_addcontractid: Uuid @@ -2342,6 +2610,7 @@ type evo_approvallog { evo_incidentid: Uuid evo_insurance_policyid: Uuid evo_leadid: Uuid + evo_logid: Uuid evo_opportunityid: Uuid evo_predate_change_statuscode: DateTime evo_prestatuscodeid: Uuid @@ -2354,68 +2623,6 @@ type evo_approvallog { toObjectString: String } -type evo_debtwork_contract { - createdon: DateTime - evo_accountid: Uuid - evo_contractid: Uuid - evo_date_change_statuscode: DateTime - evo_db_region_com: String - evo_debtwork_contractid: Uuid - evo_debt_restruct_description: String - evo_economic_security_com: String - evo_erroneous_pay_contractname: String - evo_inspection_done: Boolean - evo_inspection_impossible: Boolean - evo_inspection_impossible_reason: String - evo_inspection_link_report: String - evo_inspection_systemuserid: Uuid - evo_insurance_case_dateend: DateTime - evo_leasingobjectid: Uuid - evo_non_payment_count: Decimal - evo_opportunityid: Uuid - evo_plan_date_transfer_pay: DateTime - evo_redemption_com: String - evo_redemption_type: [Int!] - evo_result_debt_restruct: Boolean - evo_result_error_payment: Boolean - evo_result_inspection: Boolean - evo_result_insurance_case: Boolean - evo_result_redemption: Boolean - evo_result_termination: Boolean - evo_result_wait_payment: Boolean - evo_result_withdrawal: Boolean - evo_statuscodeid: Uuid - evo_statuscodeidData: evo_statuscode - evo_statuscode_reason: String - evo_storage: String - evo_termination_add_registry: Int - evo_termination_com: String - evo_termination_com_lawyer: String - evo_termination_lawyer_systemuserid: Uuid - evo_termination_reason_terms: Int - evo_termination_reason_terms_doc: String - evo_termination_reason_terms_text: String - evo_termination_send_notice: Boolean - evo_termination_send_notice_date: DateTime - evo_termination_send_notice_repeat: Boolean - evo_termination_solution: Int - evo_termination_status_work: Int - evo_termination_suspended_until: DateTime - evo_termination_unique_notice: Boolean - evo_withdrawal_businessunitid: Uuid - evo_withdrawal_done: Boolean - evo_withdrawal_impossible: Boolean - evo_withdrawal_impossible_reason: String - evo_withdrawal_issue_agreed: Int - evo_withdrawal_issue_done: Int - evo_withdrawal_parking_addressid: Uuid - evo_withdrawal_plan_date: DateTime - evo_withdrawal_systemuserid: Uuid - modifiedon: DateTime - ownerid: Uuid - toObjectString: String -} - type tisa_phonecallprocessing { createdon: DateTime modifiedon: DateTime @@ -2427,6 +2634,7 @@ type tisa_phonecallprocessing { type role { createdon: DateTime + evo_documenttypes: [evo_documenttype] modifiedon: DateTime name: String roleid: Uuid @@ -2452,6 +2660,18 @@ input EntityDataInput { logicalName: String } +type Entity { + entity_id: Uuid! + logical_name: String +} + +type picklist_value { + color: String + label: String + order: Int! + value: Int! +} + enum FilterOperation { ISNULL EQUAL @@ -2463,6 +2683,24 @@ enum FilterOperation { LESSOREQUALTHEN } +type evo_documenttype { + createdon: DateTime + evo_comment: String + evo_documenttypeid: Uuid + evo_draftdoc: Boolean + evo_edit_namedoc: Boolean + evo_fill_docname: Boolean + evo_id: String + evo_name: String + evo_name_save_file: String + evo_place_upload_doc: [Int!] + evo_storagedoc: Int + evo_typedocpackages: [evo_typedocpackage] + evo_validitydoc: Int + modifiedon: DateTime + toObjectString: String +} + input EntityFieldInput { activitypartiesvalue: [activitypartyInput] boolvalue: Boolean diff --git a/package.json b/package.json index 3e0fbfa..19d964a 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "prettier": "prettier --write .", "precommit": "yarn prettier && yarn lint:fix", "graphql:codegen": "apollo client:codegen --target typescript", - "graphql:schema": "apollo client:download-schema graphql/crm.schema.graphql", + "graphql:schema": "dotenv -e .env.local apollo client:download-schema graphql/crm.schema.graphql", "prepare": "husky install" }, "dependencies": { @@ -47,6 +47,7 @@ "@typescript-eslint/eslint-plugin": "^5.26.0", "@typescript-eslint/parser": "^5.22.0", "apollo": "^2.33.10", + "dotenv-cli": "^6.0.0", "eslint": "8.13.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-typescript": "^17.0.0", diff --git a/pages/__generated__/GetOwnerData.ts b/pages/__generated__/GetOwnerData.ts new file mode 100644 index 0000000..fb93e8a --- /dev/null +++ b/pages/__generated__/GetOwnerData.ts @@ -0,0 +1,32 @@ +/* tslint:disable */ +/* eslint-disable */ +// @generated +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL query operation: GetOwnerData +// ==================================================== + +export interface GetOwnerData_leads { + __typename: 'lead'; + fullname: string | null; + leadid: any | null; +} + +export interface GetOwnerData_opportunities { + __typename: 'opportunity'; + name: string | null; + opportunityid: any | null; +} + +export interface GetOwnerData { + /** + * Интересы. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName + */ + leads: (GetOwnerData_leads | null)[] | null; + opportunities: (GetOwnerData_opportunities | null)[] | null; +} + +export interface GetOwnerDataVariables { + domainname?: string | null; +} diff --git a/pages/index.tsx b/pages/index.tsx index e4e4464..9108a51 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,13 +1,18 @@ +import { gql } from '@apollo/client'; import initializeApollo from 'apollo/client'; import * as Calculation from 'Components/Calculation'; import Output from 'Components/Output'; import type { GetServerSideProps } from 'next'; import Head from 'next/head'; import { fetchUser } from 'services/user'; +import { getDomainName } from 'services/user/tools'; +import { useStore } from 'stores/hooks'; import styled from 'styled-components'; +import { convertEntitiesToOptions } from 'tools/entity'; import type { BasePageProps } from 'types/page'; import { Box } from 'UIKit/grid'; import { min } from 'UIKit/mq'; +import type { GetOwnerData, GetOwnerDataVariables } from './__generated__/GetOwnerData'; const Grid = styled(Box)` display: flex; @@ -30,7 +35,16 @@ const Grid = styled(Box)` } `; -function Home() { +function Home({ data }: PageProps) { + const leads = data.leads ? convertEntitiesToOptions(data.leads) : []; + const opportunities = data.opportunities ? convertEntitiesToOptions(data.opportunities) : []; + + const { $calculation } = useStore(); + $calculation.$options.setOptions({ + selectLead: leads, + selectOpportunity: opportunities, + }); + return ( @@ -43,7 +57,7 @@ function Home() { ); } -type PageProps = BasePageProps; +type PageProps = BasePageProps & { data: GetOwnerData }; export const getServerSideProps: GetServerSideProps = async (ctx) => { const user = await fetchUser({ @@ -56,9 +70,30 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => const apolloClient = initializeApollo(); + const { data: ownerData } = await apolloClient.query({ + query: gql` + query GetOwnerData($domainname: String) { + leads(owner_domainname: $domainname) { + fullname + leadid + } + opportunities { + name + opportunityid + } + } + `, + variables: { + domainname: getDomainName(user), + }, + }); + return { props: { user, + data: { + ...ownerData, + }, initialApolloState: apolloClient.cache.extract(), }, }; diff --git a/services/user/index.ts b/services/user/index.ts index d466528..246850c 100644 --- a/services/user/index.ts +++ b/services/user/index.ts @@ -1,16 +1,9 @@ /* eslint-disable import/prefer-default-export */ import type { AxiosRequestConfig } from 'axios'; import axios from 'axios'; +import { love } from './tools'; import type { User } from './types'; -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; -} - export async function fetchUser(config: AxiosRequestConfig) { const user = await axios .get(process.env.URL_GET_USER || '', config) diff --git a/services/user/tools.ts b/services/user/tools.ts new file mode 100644 index 0000000..3d86dc9 --- /dev/null +++ b/services/user/tools.ts @@ -0,0 +1,15 @@ +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; +} + +export function getDomainName(user: User) { + const { username, domain } = user; + + return `${domain}\\${username}`; +} diff --git a/stores/calculation/options/index.ts b/stores/calculation/options/index.ts index 4148e28..6275be7 100644 --- a/stores/calculation/options/index.ts +++ b/stores/calculation/options/index.ts @@ -59,8 +59,8 @@ export default class OptionsStore { return filter ? options && filter(options) : options; } - setOption = (elementName: Elements, option: BaseOption[]) => { - this.options[elementName] = option; + setElementOptions = (elementName: Elements, options: BaseOption[]) => { + this.options[elementName] = options; }; resetOption = (elementName: Elements) => { @@ -80,7 +80,7 @@ export default class OptionsStore { } (Object.keys(options) as Elements[]).forEach((elementName) => { - this.setOption(elementName, options[elementName]!); + this.setElementOptions(elementName, options[elementName]!); }); }; diff --git a/stores/user.ts b/stores/user.ts index 552077b..02d64cc 100644 --- a/stores/user.ts +++ b/stores/user.ts @@ -1,5 +1,6 @@ /* eslint-disable import/no-cycle */ import { makeAutoObservable } from 'mobx'; +import { getDomainName } from 'services/user/tools'; import type { User } from 'services/user/types'; import type RootStore from './root'; @@ -15,13 +16,7 @@ export default class UserStore { hydrate = (user: User) => { this.user = user; }; - getDomainName() { - if (this.user) { - const { username, domain } = this.user; - - return `${domain}\\${username}`; - } - - return ''; + get domainName() { + return this.user && getDomainName(this.user); } } diff --git a/tools/entity.ts b/tools/entity.ts new file mode 100644 index 0000000..ff9a739 --- /dev/null +++ b/tools/entity.ts @@ -0,0 +1,31 @@ +/* eslint-disable import/prefer-default-export */ + +import type { BaseOption } from 'Elements/types'; + +const propsMap = { + lead: { + name: 'fullname', + value: 'leadid', + }, + opportunity: { + name: 'name', + value: 'opportunityid', + }, +}; + +type PropsMap = typeof propsMap; + +function getEntityName(entities: any[]): keyof PropsMap { + // eslint-disable-next-line no-underscore-dangle + return entities.at(0)?.__typename; +} + +export function convertEntitiesToOptions(entities: any[]): BaseOption[] { + const entityName = getEntityName(entities); + const map = propsMap[entityName]; + + return entities.map((entity) => ({ + label: entity[map.name], + value: entity[map.value], + })); +} diff --git a/yarn.lock b/yarn.lock index d7ed818..f5ed3e5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2431,6 +2431,26 @@ dot-case@^3.0.4: no-case "^3.0.4" tslib "^2.0.3" +dotenv-cli@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/dotenv-cli/-/dotenv-cli-6.0.0.tgz#8a30cbc59d0a8aaa166b2fee0a9a55e23a1223ab" + integrity sha512-qXlCOi3UMDhCWFKe0yq5sg3X+pJAz+RQDiFN38AMSbUrnY3uZshSfDJUAge951OS7J9gwLZGfsBlWRSOYz/TRg== + dependencies: + cross-spawn "^7.0.3" + dotenv "^16.0.0" + dotenv-expand "^8.0.1" + minimist "^1.2.5" + +dotenv-expand@^8.0.1: + version "8.0.3" + resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-8.0.3.tgz#29016757455bcc748469c83a19b36aaf2b83dd6e" + integrity sha512-SErOMvge0ZUyWd5B0NXMQlDkN+8r+HhVUsxgOO7IoPDOdDRD2JjExpN6y3KnFR66jsJMwSn1pqIivhU5rcJiNg== + +dotenv@^16.0.0: + version "16.0.1" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.1.tgz#8f8f9d94876c35dac989876a5d3a82a267fdce1d" + integrity sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ== + dotenv@^8.0.0: version "8.6.0" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b" @@ -4142,7 +4162,7 @@ minimatch@~3.0.2: dependencies: brace-expansion "^1.1.7" -minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.6: +minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5, minimist@^1.2.6: version "1.2.6" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==