diff --git a/package-lock.json b/package-lock.json index ceefccf..5d3bb92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@testing-library/react": "12.1.2", "@testing-library/user-event": "13.5.0", "axios": "^0.26.0", + "node": "^14.15.1", "node-sass": "^7.0.1", "react": "^17.0.2", "react-dom": "^17.0.2", @@ -11725,6 +11726,26 @@ "tslib": "^2.0.3" } }, + "node_modules/node": { + "version": "14.15.1", + "resolved": "https://registry.npmjs.org/node/-/node-14.15.1.tgz", + "integrity": "sha512-BeTf2muiTEC7o3w0sUJ83GHORQ+FLNZCouQUM3VJk3LKf1keQ6ldghELrOo6nBUNZBBS5I++pgDSYPhHWcpp8w==", + "hasInstallScript": true, + "dependencies": { + "node-bin-setup": "^1.0.0" + }, + "bin": { + "node": "bin/node" + }, + "engines": { + "npm": ">=5.0.0" + } + }, + "node_modules/node-bin-setup": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/node-bin-setup/-/node-bin-setup-1.1.3.tgz", + "integrity": "sha512-opgw9iSCAzT2+6wJOETCpeRYAQxSopqQ2z+N6BXwIMsQQ7Zj5M8MaafQY8JMlolRR6R1UXg2WmhKp0p9lSOivg==" + }, "node_modules/node-forge": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.2.1.tgz", @@ -25879,6 +25900,19 @@ "tslib": "^2.0.3" } }, + "node": { + "version": "14.15.1", + "resolved": "https://registry.npmjs.org/node/-/node-14.15.1.tgz", + "integrity": "sha512-BeTf2muiTEC7o3w0sUJ83GHORQ+FLNZCouQUM3VJk3LKf1keQ6ldghELrOo6nBUNZBBS5I++pgDSYPhHWcpp8w==", + "requires": { + "node-bin-setup": "^1.0.0" + } + }, + "node-bin-setup": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/node-bin-setup/-/node-bin-setup-1.1.3.tgz", + "integrity": "sha512-opgw9iSCAzT2+6wJOETCpeRYAQxSopqQ2z+N6BXwIMsQQ7Zj5M8MaafQY8JMlolRR6R1UXg2WmhKp0p9lSOivg==" + }, "node-forge": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.2.1.tgz", diff --git a/package.json b/package.json index 2e171d5..bc9762d 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "@testing-library/react": "12.1.2", "@testing-library/user-event": "13.5.0", "axios": "^0.26.0", + "node": "^14.15.1", "node-sass": "^7.0.1", "react": "^17.0.2", "react-dom": "^17.0.2", diff --git a/src/components/CardStages/CardStage3.js b/src/components/CardStages/CardStage3.js index 1eb0670..afa2678 100644 --- a/src/components/CardStages/CardStage3.js +++ b/src/components/CardStages/CardStage3.js @@ -34,18 +34,45 @@ const CardStage3 = ({ setStage, data, setData }) => { useEffect(() => { if ( - inputValid.region && - inputValid.affiliate && - inputValid.date && - inputValid.time && - inputValid.code + inputValid.region === branch.regions.TKM[6] || + inputValid.region === branch.regions.RUS[6] || + inputValid.region === branch.regions.ENG[6] ) { - setBtnEnabled(true); + if ( + inputValid.region && + inputValid.date && + inputValid.time && + inputValid.code + ) { + setBtnEnabled(true); + } else { + setBtnEnabled(false); + } } else { - setBtnEnabled(false); + if ( + inputValid.region && + inputValid.affiliate && + inputValid.date && + inputValid.time && + inputValid.code + ) { + setBtnEnabled(true); + } else { + setBtnEnabled(false); + } } }, [inputValid]); + useEffect(() => { + if ( + inputValid.region === branch.regions.TKM[6] || + inputValid.region === branch.regions.RUS[6] || + inputValid.region === branch.regions.ENG[6] + ) { + setInputValid({ ...inputValid, affiliate: null }); + } + }, [inputValid.region]); + return (
@@ -107,156 +134,162 @@ const CardStage3 = ({ setStage, data, setData }) => { defaultValue={inputValid.region} /> -
- - { - setInputValid({ ...inputValid, affiliate: state }); - if (state && inputLocal.region) { - let index; - if (inputLocal.region === "Aşgabat şäheri") { - if (locale === "РУС") { - index = branch["Ashgabat"].RUS.findIndex( - (e) => e === state - ); - } else if (locale === "ENG") { - index = branch["Ashgabat"].ENG.findIndex( - (e) => e === state - ); - } - } else if (inputLocal.region === "Daşoguz") { - if (locale === "РУС") { - index = branch["Dashoguz"].RUS.findIndex( - (e) => e === state - ); - } else if (locale === "ENG") { - index = branch["Dashoguz"].ENG.findIndex( - (e) => e === state - ); - } - } else { - if (locale === "РУС") { - index = branch[inputLocal.region].RUS.findIndex( - (e) => e === state - ); - } else if (locale === "ENG") { - index = branch[inputLocal.region].ENG.findIndex( - (e) => e === state - ); - } - } - if (index === -1) { - setInputLocal({ ...inputLocal, affiliate: state }); - } else { + {inputValid.region !== branch.regions.TKM[6] && + inputValid.region !== branch.regions.RUS[6] && + inputValid.region !== branch.regions.ENG[6] ? ( +
+ + { + setInputValid({ ...inputValid, affiliate: state }); + if (state && inputLocal.region) { + let index; if (inputLocal.region === "Aşgabat şäheri") { - setInputLocal({ - ...inputLocal, - affiliate: branch["Ashgabat"].TKM[index], - }); + if (locale === "РУС") { + index = branch["Ashgabat"].RUS.findIndex( + (e) => e === state + ); + } else if (locale === "ENG") { + index = branch["Ashgabat"].ENG.findIndex( + (e) => e === state + ); + } } else if (inputLocal.region === "Daşoguz") { - setInputLocal({ - ...inputLocal, - affiliate: branch["Dashoguz"].TKM[index], - }); + if (locale === "РУС") { + index = branch["Dashoguz"].RUS.findIndex( + (e) => e === state + ); + } else if (locale === "ENG") { + index = branch["Dashoguz"].ENG.findIndex( + (e) => e === state + ); + } } else { - setInputLocal({ - ...inputLocal, - affiliate: branch[inputLocal.region].TKM[index], - }); + if (locale === "РУС") { + index = branch[inputLocal.region].RUS.findIndex( + (e) => e === state + ); + } else if (locale === "ENG") { + index = branch[inputLocal.region].ENG.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} - /> -
+ }} + eTarget={true} + defaultValue={inputValid.affiliate} + /> +
+ ) : null} +
-
- - + + -
+ customId={"affiliate"} + blockName={"card-3-select"} + elName={"card-3-select-el"} + name={"affiliate"} + placeholder={ + locale === "TKM" + ? "Şahamçany saýlaň" + : locale === "РУС" + ? "Выберите филиал" + : locale === "ENG" + ? "Choose branch" + : "Şahamçany saýlaň" + } + stateSetter={(state) => { + setInputValid({ ...inputValid, affiliate: state }); + if (state && inputLocal.region) { + let index; + if (inputLocal.region === "Aşgabat şäheri") { + if (locale === "РУС") { + index = branch["Ashgabat"].RUS.findIndex( + (e) => e === state + ); + } else if (locale === "ENG") { + index = branch["Ashgabat"].ENG.findIndex( + (e) => e === state + ); + } + } else if (inputLocal.region === "Daşoguz") { + if (locale === "РУС") { + index = branch["Dashoguz"].RUS.findIndex( + (e) => e === state + ); + } else if (locale === "ENG") { + index = branch["Dashoguz"].ENG.findIndex( + (e) => e === state + ); + } + } else { + if (locale === "РУС") { + index = branch[inputLocal.region].RUS.findIndex( + (e) => e === state + ); + } else if (locale === "ENG") { + index = branch[inputLocal.region].ENG.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} + /> + + ) : null}