diff --git a/pages/admin/rc/[rcid]/proforma/[proformaid]/step2.tsx b/pages/admin/rc/[rcid]/proforma/[proformaid]/step2.tsx index b2c6076..9b91985 100644 --- a/pages/admin/rc/[rcid]/proforma/[proformaid]/step2.tsx +++ b/pages/admin/rc/[rcid]/proforma/[proformaid]/step2.tsx @@ -66,8 +66,9 @@ function Step2() { const temp = func[branchName as keyof typeof func]; const idx = func[branchName as keyof typeof func][keyword as keyof typeof temp]; - if (idx !== -1) { - newStr = `${newStr.substring(0, idx)}1${newStr.substring(idx + 1)}`; + let idn = parseInt(idx, 10); + if (idn !== -1) { + newStr = `${newStr.substring(0, idn)}1${newStr.substring(idn + 1)}`; } }); setStr(newStr); @@ -77,10 +78,11 @@ function Step2() { const temp = func[branch as keyof typeof func]; const idx = func[branch as keyof typeof func][keyword as keyof typeof temp]; let newStr = str; - if (str[idx] === "1") { - newStr = `${newStr.substring(0, idx)}0${newStr.substring(idx + 1)}`; + let idn = parseInt(idx, 10); + if (str[idn] === "1") { + newStr = `${newStr.substring(0, idn)}0${newStr.substring(idn + 1)}`; } else { - newStr = `${newStr.substring(0, idx)}1${newStr.substring(idx + 1)}`; + newStr = `${newStr.substring(0, idn)}1${newStr.substring(idn + 1)}`; } setStr(newStr); }; @@ -127,7 +129,7 @@ function Step2() { {keyword} handleCheck(branch, keyword)} /> diff --git a/pages/company/rc/[rcid]/proforma/[proformaid]/step2.tsx b/pages/company/rc/[rcid]/proforma/[proformaid]/step2.tsx index c3cfdb5..4fc1a5e 100644 --- a/pages/company/rc/[rcid]/proforma/[proformaid]/step2.tsx +++ b/pages/company/rc/[rcid]/proforma/[proformaid]/step2.tsx @@ -64,8 +64,9 @@ function Step2() { const temp = func[branchName as keyof typeof func]; const idx = func[branchName as keyof typeof func][keyword as keyof typeof temp]; - if (idx !== -1) { - newStr = `${newStr.substring(0, idx)}1${newStr.substring(idx + 1)}`; + let idn = parseInt(idx, 10); + if (idn !== -1) { + newStr = `${newStr.substring(0, idn)}1${newStr.substring(idn + 1)}`; } }); setStr(newStr); @@ -75,10 +76,11 @@ function Step2() { const temp = func[branch as keyof typeof func]; const idx = func[branch as keyof typeof func][keyword as keyof typeof temp]; let newStr = str; - if (str[idx] === "1") { - newStr = `${newStr.substring(0, idx)}0${newStr.substring(idx + 1)}`; + let idn = parseInt(idx, 10); + if (str[idn] === "1") { + newStr = `${newStr.substring(0, idn)}0${newStr.substring(idn + 1)}`; } else { - newStr = `${newStr.substring(0, idx)}1${newStr.substring(idx + 1)}`; + newStr = `${newStr.substring(0, idn)}1${newStr.substring(idn + 1)}`; } setStr(newStr); }; @@ -125,7 +127,7 @@ function Step2() { {keyword} handleCheck(branch, keyword)} />