From 7dc48daf3ffb3aac417d55f8f07df3564b4fce97 Mon Sep 17 00:00:00 2001 From: VividTruthKeeper Date: Fri, 6 May 2022 01:22:42 +0500 Subject: [PATCH] type, region, branch localized added --- src/components/CardStages/CardStage3.js | 2 +- src/components/CardStages/CardStage6.js | 4 +- src/components/CreditStages/CreditStage4.js | 76 ++++++++++++++++++--- src/components/CreditStages/CreditStage6.js | 6 +- 4 files changed, 73 insertions(+), 15 deletions(-) diff --git a/src/components/CardStages/CardStage3.js b/src/components/CardStages/CardStage3.js index d301bb7..f43c3d3 100644 --- a/src/components/CardStages/CardStage3.js +++ b/src/components/CardStages/CardStage3.js @@ -301,7 +301,7 @@ const CardStage3 = ({ setStage, data, setData }) => { region: inputLocal.region, region_localized: inputValid.region, branch: inputLocal.affiliate, - branch_localized: inputLocal.affiliate, + branch_localized: inputValid.affiliate, date_arrival_bank: inputValid.date, selected_time: inputValid.time, the_codeword: inputValid.code, diff --git a/src/components/CardStages/CardStage6.js b/src/components/CardStages/CardStage6.js index c1b76aa..4c10bf5 100644 --- a/src/components/CardStages/CardStage6.js +++ b/src/components/CardStages/CardStage6.js @@ -93,11 +93,11 @@ const CardStage6 = ({
  • {locale === "TKM" ? "Welaýat" : "Регион"}:

    -

    {data.region ? data.region : "-"}

    +

    {data.region_localized ? data.region_localized : "-"}

  • {locale === "TKM" ? "Filial" : "Филиал"}:

    -

    {data.branch ? data.branch : "-"}

    +

    {data.branch_localized ? data.branch_localized : "-"}

  • diff --git a/src/components/CreditStages/CreditStage4.js b/src/components/CreditStages/CreditStage4.js index b6c651e..0842850 100644 --- a/src/components/CreditStages/CreditStage4.js +++ b/src/components/CreditStages/CreditStage4.js @@ -18,6 +18,11 @@ const CreditStage4 = ({ setStage, data, setData }) => { salary: data.salary ? data.salary : null, position: data.position ? data.position : null, experience: data.exp ? data.exp : null, + region: data.region_localized ? data.region_localized : null, + affiliate: data.branch_localized ? data.branch_localized : null, + }); + + const [inputLocal, setInputLocal] = useState({ region: data.region ? data.region : null, affiliate: data.branch ? data.branch : null, }); @@ -121,9 +126,22 @@ const CreditStage4 = ({ setStage, data, setData }) => { placeholder={ locale === "TKM" ? "Welaýaty saýlaň" : "Выберите регион" } - stateSetter={(state) => - setInputValid({ ...inputValid, region: state }) - } + stateSetter={(state) => { + setInputValid({ ...inputValid, region: state }); + if (state) { + const index = branch.regions.RUS.findIndex( + (e) => e === state + ); + if (index === -1) { + setInputLocal({ ...inputLocal, region: state }); + } else { + setInputLocal({ + ...inputLocal, + region: branch.regions.TKM[index], + }); + } + } + }} eTarget={true} defaultValue={inputValid.region} /> @@ -170,15 +188,53 @@ const CreditStage4 = ({ setStage, data, setData }) => { customId={"affiliate"} blockName={"card-3-select"} elName={"card-3-select-el"} + defaultValue={inputValid.affiliate} name={"affiliate"} placeholder={ locale === "TKM" ? "Filialy saýlaň" : "Выберите филиал" } - stateSetter={(state) => - setInputValid({ ...inputValid, affiliate: state }) - } + stateSetter={(state) => { + setInputValid({ ...inputValid, affiliate: state }); + if (state && inputLocal.region) { + console.log(inputLocal.region); + let index; + if (inputLocal.region === "Aşgabat şäheri") { + index = branch["Ashgabat"].RUS.findIndex( + (e) => e === state + ); + } else if (inputLocal.region === "Daşoguz") { + index = branch["Dashoguz"].RUS.findIndex( + (e) => e === state + ); + } else { + index = branch[inputLocal.region].RUS.findIndex( + (e) => e === state + ); + } + + if (index === -1) { + setInputLocal({ ...inputLocal, affiliate: state }); + } else { + if (inputLocal.region === "Aşgabat şäheri") { + setInputLocal({ + ...inputLocal, + affiliate: branch["Ashgabat"].TKM[index], + }); + } else if (inputLocal.region === "Daşoguz") { + setInputLocal({ + ...inputLocal, + affiliate: branch["Dashoguz"].TKM[index], + }); + } else { + setInputLocal({ + ...inputLocal, + affiliate: branch[inputLocal.region].TKM[index], + }); + } + } + } + }} eTarget={true} - defaultValue={inputValid.affiliate} /> @@ -212,11 +268,13 @@ const CreditStage4 = ({ setStage, data, setData }) => { setData({ ...data, workplace: inputValid.workplace, - region: inputValid.region, + region: inputLocal.region, + region_localized: inputValid.region, + branch: inputLocal.affiliate, + branch_localized: inputValid.affiliate, exp: inputValid.experience, position: inputValid.position, salary: inputValid.salary, - branch: inputValid.affiliate, }); }} > diff --git a/src/components/CreditStages/CreditStage6.js b/src/components/CreditStages/CreditStage6.js index 35fb868..8d46f9d 100644 --- a/src/components/CreditStages/CreditStage6.js +++ b/src/components/CreditStages/CreditStage6.js @@ -29,7 +29,7 @@ const CreditStage6 = ({ const token = localStorage.getItem("userToken"); const postUrl = destination + "/online_credit"; const getUrl = destination + "/me"; - + console.log(data); return (

    @@ -84,11 +84,11 @@ const CreditStage6 = ({
  • {locale === "TKM" ? "Welaýat" : "Регион"}:

    -

    {data.region ? data.region : "-"}

    +

    {data.region_localized ? data.region_localized : "-"}

  • {locale === "TKM" ? "Filial" : "Филиал"}:

    -

    {data.branch ? data.branch : "-"}

    +

    {data.branch_localized ? data.branch_localized : "-"}

  • {locale === "TKM" ? "Iş ýeri" : "Место работы"}: