Merge branch 'dev' into staging
This commit is contained in:
commit
694c5c5f86
@ -76,6 +76,30 @@ export default class UserFolderHeader extends React.Component<IProps, IState> {
|
|||||||
private formatPhoneNumber(phoneNumber: string): string {
|
private formatPhoneNumber(phoneNumber: string): string {
|
||||||
if (!phoneNumber) return "";
|
if (!phoneNumber) return "";
|
||||||
phoneNumber = phoneNumber.replace(/ /g, "");
|
phoneNumber = phoneNumber.replace(/ /g, "");
|
||||||
|
phoneNumber = phoneNumber.replace("+33", "0");
|
||||||
|
|
||||||
|
if (phoneNumber.length !== 10) {
|
||||||
|
// split the last 9 digits
|
||||||
|
const lastNineDigits = phoneNumber.slice(-9);
|
||||||
|
|
||||||
|
// get the country code
|
||||||
|
const countryCode = phoneNumber.slice(0, -9);
|
||||||
|
|
||||||
|
// isolate the first digit
|
||||||
|
const firstDigit = lastNineDigits.slice(0, 1);
|
||||||
|
|
||||||
|
// isolate the 8 other ones
|
||||||
|
const lastEightDigits = lastNineDigits.slice(1);
|
||||||
|
|
||||||
|
// make a space every two digits on the last eights
|
||||||
|
const output = lastEightDigits.split("").map((char, index) => {
|
||||||
|
if (index % 2) return char + " ";
|
||||||
|
return char;
|
||||||
|
});
|
||||||
|
// format the phone number
|
||||||
|
phoneNumber = countryCode + " " + firstDigit + " " + output.join("");
|
||||||
|
return phoneNumber;
|
||||||
|
}
|
||||||
const output = phoneNumber.split("").map((char, index) => {
|
const output = phoneNumber.split("").map((char, index) => {
|
||||||
if (index % 2) return char + " ";
|
if (index % 2) return char + " ";
|
||||||
return char;
|
return char;
|
||||||
|
@ -163,7 +163,7 @@ export default function CollaboratorInformations(props: IProps) {
|
|||||||
<Typography typo={ITypo.NAV_INPUT_16} color={ITypoColor.GREY}>
|
<Typography typo={ITypo.NAV_INPUT_16} color={ITypoColor.GREY}>
|
||||||
Numéro de téléphone
|
Numéro de téléphone
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography typo={ITypo.P_18}>{userSelected?.contact?.phone_number}</Typography>
|
<Typography typo={ITypo.P_18}>{userSelected?.contact?.cell_phone_number}</Typography>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes["user-infos-row"]}>
|
<div className={classes["user-infos-row"]}>
|
||||||
<Typography typo={ITypo.NAV_INPUT_16} color={ITypoColor.GREY}>
|
<Typography typo={ITypo.NAV_INPUT_16} color={ITypoColor.GREY}>
|
||||||
|
@ -229,6 +229,16 @@ class AddClientToFolderClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
if (this.state.selectedOption === "new_customer") {
|
if (this.state.selectedOption === "new_customer") {
|
||||||
try {
|
try {
|
||||||
|
// remove every space from the phone number
|
||||||
|
values["cell_phone_number"] = values["cell_phone_number"].replace(/\s/g, "");
|
||||||
|
if (values["cell_phone_number"] && values["cell_phone_number"].length === 10) {
|
||||||
|
// get the first digit of the phone number
|
||||||
|
const firstDigit = values["cell_phone_number"].charAt(0);
|
||||||
|
// if the first digit is a 0 replace it by +33
|
||||||
|
if (firstDigit === "0") {
|
||||||
|
values["cell_phone_number"] = "+33" + values["cell_phone_number"].substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
const contactToCreate = Contact.hydrate<Customer>(values);
|
const contactToCreate = Contact.hydrate<Customer>(values);
|
||||||
await contactToCreate.validateOrReject?.({ groups: ["createCustomer"], forbidUnknownValues: false });
|
await contactToCreate.validateOrReject?.({ groups: ["createCustomer"], forbidUnknownValues: false });
|
||||||
} catch (validationErrors) {
|
} catch (validationErrors) {
|
||||||
|
@ -176,6 +176,17 @@ class UpdateClientClass extends BasePage<IPropsClass, IState> {
|
|||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
if (!values["cell_phone_number"]) return;
|
||||||
|
// remove every space from the phone number
|
||||||
|
values["cell_phone_number"] = values["cell_phone_number"].replace(/\s/g, "");
|
||||||
|
if (values["cell_phone_number"] && values["cell_phone_number"].length === 10) {
|
||||||
|
// get the first digit of the phone number
|
||||||
|
const firstDigit = values["cell_phone_number"].charAt(0);
|
||||||
|
// if the first digit is a 0 replace it by +33
|
||||||
|
if (firstDigit === "0") {
|
||||||
|
values["cell_phone_number"] = "+33" + values["cell_phone_number"].substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
const contact = Contact.hydrate<Contact>({
|
const contact = Contact.hydrate<Contact>({
|
||||||
first_name: values["first_name"],
|
first_name: values["first_name"],
|
||||||
last_name: values["last_name"],
|
last_name: values["last_name"],
|
||||||
|
@ -61,7 +61,7 @@ export default class MyAccount extends Base<IProps, IState> {
|
|||||||
<TextField
|
<TextField
|
||||||
name="phone"
|
name="phone"
|
||||||
placeholder="Numéro de téléphone"
|
placeholder="Numéro de téléphone"
|
||||||
defaultValue={this.state.user?.contact?.phone_number as string}
|
defaultValue={this.state.user?.contact?.cell_phone_number as string}
|
||||||
disabled
|
disabled
|
||||||
canCopy
|
canCopy
|
||||||
/>
|
/>
|
||||||
|
@ -238,7 +238,7 @@ export default function UserInformations(props: IProps) {
|
|||||||
<Typography typo={ITypo.NAV_INPUT_16} color={ITypoColor.GREY}>
|
<Typography typo={ITypo.NAV_INPUT_16} color={ITypoColor.GREY}>
|
||||||
Numéro de téléphone
|
Numéro de téléphone
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography typo={ITypo.P_18}>{userSelected?.contact?.phone_number}</Typography>
|
<Typography typo={ITypo.P_18}>{userSelected?.contact?.cell_phone_number}</Typography>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes["user-infos-row"]}>
|
<div className={classes["user-infos-row"]}>
|
||||||
<Typography typo={ITypo.NAV_INPUT_16} color={ITypoColor.GREY}>
|
<Typography typo={ITypo.NAV_INPUT_16} color={ITypoColor.GREY}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user