register , login model complated. plagiraism component complated(essential part of main page is complated )

This commit is contained in:
nabijonovdavronbek619@gmail.com
2026-03-30 20:25:30 +05:00
parent 8906cf6634
commit 8b93952a06
29 changed files with 1475 additions and 205 deletions

View File

@@ -1,38 +1,14 @@
/**
* Format the number (+998 00 111-22-33)
* @param value Number to be formatted
* @returns string +998 00 111-22-33
*/
const formatPhone = (value: string) => {
// Keep only numbers
const digits = value.replace(/\D/g, '');
// Return empty string if data is not available
if (digits.length === 0) {
return '';
}
const prefix = digits.startsWith('998') ? '+998 ' : '+998 ';
let formattedNumber = prefix;
if (digits.length > 3) {
formattedNumber += digits.slice(3, 5);
}
if (digits.length > 5) {
formattedNumber += ' ' + digits.slice(5, 8);
}
if (digits.length > 8) {
formattedNumber += '-' + digits.slice(8, 10);
}
if (digits.length > 10) {
formattedNumber += '-' + digits.slice(10, 12);
}
return formattedNumber.trim();
if (value.length <= 2) return value;
if (value.length <= 5) return `${value.slice(0, 2)} ${value.slice(2)}`;
if (value.length <= 7)
return `${value.slice(0, 2)} ${value.slice(2, 5)} ${value.slice(5)}`;
return `${value.slice(0, 2)} ${value.slice(2, 5)} ${value.slice(
5,
7,
)} ${value.slice(7)}`;
};
export default formatPhone;
const normalizeDigits = (value: string) => value.replace(/\D/g, '').slice(0, 9);
export { formatPhone, normalizeDigits };