Merge branch 'dev' into staging

This commit is contained in:
Maxime Lalo 2023-12-04 15:49:50 +01:00
commit 694c5c5f86
6 changed files with 49 additions and 4 deletions

View File

@ -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;

View File

@ -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}>

View File

@ -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) {

View File

@ -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"],

View File

@ -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
/> />

View File

@ -173,7 +173,7 @@ export default function UserInformations(props: IProps) {
const liveVote = await LiveVotes.getInstance().post(vote); const liveVote = await LiveVotes.getInstance().post(vote);
if (liveVote.appointment.votes?.length === 3) { if (liveVote.appointment.votes?.length === 3) {
if(superAdminModalType === "add") { if (superAdminModalType === "add") {
Toasts.getInstance().open({ Toasts.getInstance().open({
title: `Le titre de super-administrateur a été attribué à ${userSelected.contact?.first_name} ${userSelected.contact?.last_name} `, title: `Le titre de super-administrateur a été attribué à ${userSelected.contact?.first_name} ${userSelected.contact?.last_name} `,
}); });
@ -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}>