You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
934 B
30 lines
934 B
3 years ago
|
export const digitToPersian = (digit) => {
|
||
|
let enNums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
|
||
|
let faNums = ['۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', '۰']
|
||
|
let digitString = digit + '';
|
||
|
let digitArray = digitString.split('');
|
||
|
for (let i in digitArray) {
|
||
|
if (enNums.includes(digitArray[i]))
|
||
|
digitArray[i] = faNums[enNums.indexOf(digitArray[i])]
|
||
|
}
|
||
|
return digitArray.join('')
|
||
|
}
|
||
|
|
||
|
export const digitToEn = (digit) => {
|
||
|
let enNums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
|
||
|
let faNums = ['۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', '۰']
|
||
|
let digitString = digit + '';
|
||
|
let digitArray = digitString.split('');
|
||
|
for (let i in digitArray) {
|
||
|
if (faNums.includes(digitArray[i]))
|
||
|
digitArray[i] = enNums[faNums.indexOf(digitArray[i])]
|
||
|
}
|
||
|
return digitArray.join('')
|
||
|
}
|
||
|
|
||
|
export const waitToFinish = async (setLoading, func) => {
|
||
|
setLoading(true);
|
||
|
await func();
|
||
|
setLoading(false)
|
||
|
}
|