change fields component & handle edit, delete, add data and save & change functional page doctor
This commit is contained in:
+30
-7
@@ -123,17 +123,15 @@ export const formatPhoneNumber = (input) => {
|
||||
};
|
||||
|
||||
export function validatePhoneNumber(input) {
|
||||
const digits = input.replace(/\D/g, "");
|
||||
|
||||
if (!digits) {
|
||||
if (!input) {
|
||||
return { valid: false, text: "شماره موبایل نمیتواند خالی باشد." };
|
||||
}
|
||||
|
||||
if (digits.length !== 9) {
|
||||
if (input.length !== 11) {
|
||||
return { valid: false, text: "شماره موبایل باید دقیقا 11 رقم باشد." };
|
||||
}
|
||||
|
||||
const isValid = /^[1-9]\d{8}$/.test(digits);
|
||||
const isValid = /^09\d{9}$/.test(input);
|
||||
if (!isValid) {
|
||||
return { valid: false, text: "شماره موبایل نامعتبر است." };
|
||||
}
|
||||
@@ -185,8 +183,6 @@ export function getCleanNumberValue(value, defaultValue = 0) {
|
||||
return isNaN(number) ? defaultValue : number;
|
||||
}
|
||||
|
||||
export const changeNumToDefault = (num) => `09${num.replace(/\D/g, "")}`;
|
||||
|
||||
export function hasDataChanged(previousData, newData) {
|
||||
const oldDataString = JSON.stringify(
|
||||
previousData,
|
||||
@@ -201,3 +197,30 @@ export const getParsedUserInfo = () => {
|
||||
const parsedUserInfo = user && JSON.parse(user);
|
||||
return parsedUserInfo;
|
||||
};
|
||||
|
||||
export const handleTimeExpiresToken = (expires_in) => {
|
||||
const accessTokenExpires = new Date();
|
||||
accessTokenExpires.setSeconds(accessTokenExpires.getSeconds() + expires_in);
|
||||
const refreshTokenExpires = new Date();
|
||||
refreshTokenExpires.setDate(refreshTokenExpires.getDate() + 30);
|
||||
|
||||
return {
|
||||
accessTokenExpires,
|
||||
refreshTokenExpires,
|
||||
};
|
||||
};
|
||||
|
||||
export const removeAdditionalKeysDashboard = (information) => {
|
||||
const {
|
||||
national_code,
|
||||
changed,
|
||||
created,
|
||||
id,
|
||||
status,
|
||||
prev_data,
|
||||
uuid,
|
||||
...usedKays
|
||||
} = information;
|
||||
|
||||
return usedKays;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user