Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/common/src/LocaleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const getValidationErrorTranslation = (
case PersonalDetailsValidation.PHONE_INVALID:
return "מספר הטלפון אינו תקין";
case PersonalDetailsValidation.PHONE_HAS_NANS:
case PersonalDetailsValidation.ID_HAS_NANS:
return "יש להזין ספרות בלבד";
case PersonalDetailsValidation.REQUIRED_FIELD:
return "שדה חובה";
Expand Down
19 changes: 19 additions & 0 deletions packages/common/src/Validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export enum PersonalDetailsValidation {
VALID_FIELD = "VALID_FIELD",
NAME_TOO_SHORT = "NAME_TOO_SHORT",
FULL_NAME_TOO_LONG = "FULL_NAME_TOO_LONG",
ID_INVALID = "ID_INVALID",
ID_HAS_NANS = "ID_HAS_NANS",
PHONE_INVALID = "PHONE_INVALID",
PHONE_HAS_NANS = "PHONE_HAS_NANS",
REQUIRED_FIELD = "REQUIRED_FIELD",
Expand All @@ -20,6 +22,11 @@ export type LastNameValidation =
| PersonalDetailsValidation.NAME_TOO_SHORT
| PersonalDetailsValidation.FULL_NAME_TOO_LONG;

export type CountryIdNumberValidation =
| PersonalDetailsValidation.VALID_FIELD
| PersonalDetailsValidation.ID_INVALID
| PersonalDetailsValidation.ID_HAS_NANS;

export type PhoneValidation =
| FieldValidation
| PersonalDetailsValidation.PHONE_INVALID
Expand All @@ -46,6 +53,18 @@ export const ValidateLastName = (
return PersonalDetailsValidation.VALID_FIELD;
};

export const ValidateIdNumber = (id: string): CountryIdNumberValidation => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests to cover all cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

const allNumbersValidator = /^[0-9]*$/;
if (!allNumbersValidator.test(id)) {
return PersonalDetailsValidation.ID_HAS_NANS;
}
const formatValidator = /^\d{9}$/;
if (id.length > 0 && !formatValidator.test(id)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to go all the way, you can also check the "check digit" (ספרת ביקורת).
It is not hard to implement, you can find some js implementations online

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return PersonalDetailsValidation.ID_INVALID;
}
return PersonalDetailsValidation.VALID_FIELD;
};

export const ValidatePhone = (phone: string): PhoneValidation => {
if (!phone) return PersonalDetailsValidation.REQUIRED_FIELD;

Expand Down
1 change: 1 addition & 0 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type MinimalDonorDetailsForAppointment = {
lastName: string;
phoneNumber: string;
bloodType: BloodType;
countryIdNumber?: string;
};

//https://docs.google.com/document/d/1Y3ovMRJhdHlJEd4rS3FCgxxY3qdpmk2WLaR45nL8IT8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-4:focus::-ms-input-p
animation-name: mui-auto-fill;
}

.emotion-13 {
.emotion-17 {
display: -webkit-inline-box;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
Expand Down Expand Up @@ -373,66 +373,66 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-4:focus::-ms-input-p
box-shadow: none;
}

.emotion-13::-moz-focus-inner {
.emotion-17::-moz-focus-inner {
border-style: none;
}

.emotion-13.Mui-disabled {
.emotion-17.Mui-disabled {
pointer-events: none;
cursor: default;
}

@media print {
.emotion-13 {
.emotion-17 {
-webkit-print-color-adjust: exact;
color-adjust: exact;
}
}

.emotion-13:hover {
.emotion-17:hover {
-webkit-text-decoration: none;
text-decoration: none;
background-color: rgb(53, 122, 56);
box-shadow: 0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);
}

@media (hover: none) {
.emotion-13:hover {
.emotion-17:hover {
background-color: #4caf51;
}
}

.emotion-13:active {
.emotion-17:active {
box-shadow: 0px 5px 5px -3px rgba(0,0,0,0.2),0px 8px 10px 1px rgba(0,0,0,0.14),0px 3px 14px 2px rgba(0,0,0,0.12);
}

.emotion-13.Mui-focusVisible {
.emotion-17.Mui-focusVisible {
box-shadow: 0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12);
}

.emotion-13.Mui-disabled {
.emotion-17.Mui-disabled {
color: #7E7E7E;
box-shadow: none;
background-color: #dadee0;
}

.emotion-13:hover {
.emotion-17:hover {
box-shadow: none;
}

.emotion-13.Mui-focusVisible {
.emotion-17.Mui-focusVisible {
box-shadow: none;
}

.emotion-13:active {
.emotion-17:active {
box-shadow: none;
}

.emotion-13.Mui-disabled {
.emotion-17.Mui-disabled {
box-shadow: none;
}

.emotion-14 {
.emotion-18 {
display: -webkit-inline-box;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
Expand Down Expand Up @@ -481,53 +481,53 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-4:focus::-ms-input-p
box-shadow: none;
}

.emotion-14::-moz-focus-inner {
.emotion-18::-moz-focus-inner {
border-style: none;
}

.emotion-14.Mui-disabled {
.emotion-18.Mui-disabled {
pointer-events: none;
cursor: default;
}

@media print {
.emotion-14 {
.emotion-18 {
-webkit-print-color-adjust: exact;
color-adjust: exact;
}
}

.emotion-14:hover {
.emotion-18:hover {
-webkit-text-decoration: none;
text-decoration: none;
background-color: rgba(76, 175, 81, 0.04);
border: 1px solid #4caf51;
}

@media (hover: none) {
.emotion-14:hover {
.emotion-18:hover {
background-color: transparent;
}
}

.emotion-14.Mui-disabled {
.emotion-18.Mui-disabled {
color: #7E7E7E;
border: 1px solid #dadee0;
}

.emotion-14:hover {
.emotion-18:hover {
box-shadow: none;
}

.emotion-14.Mui-focusVisible {
.emotion-18.Mui-focusVisible {
box-shadow: none;
}

.emotion-14:active {
.emotion-18:active {
box-shadow: none;
}

.emotion-14.Mui-disabled {
.emotion-18.Mui-disabled {
box-shadow: none;
}

Expand Down Expand Up @@ -690,6 +690,36 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-4:focus::-ms-input-p
/>
</div>

</div>
<div
className="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root input emotion-1"
onKeyPress={[Function]}
>
<label
className="MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-standard MuiFormLabel-root MuiFormLabel-colorPrimary emotion-2"
data-shrink={false}
>
תעודת זהות
</label>
<div
className="MuiInput-root MuiInput-underline MuiInputBase-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl emotion-3"
onClick={[Function]}
>
<input
aria-invalid={false}
autoFocus={false}
className="MuiInput-input MuiInputBase-input emotion-4"
disabled={false}
onAnimationStart={[Function]}
onBlur={[Function]}
onChange={[Function]}
onFocus={[Function]}
required={false}
type="text"
value=""
/>
</div>

</div>
<div>
<div
Expand Down Expand Up @@ -806,7 +836,7 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-4:focus::-ms-input-p
>
<div>
<button
className="MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-disableElevation MuiButton-fullWidth MuiButtonBase-root Mui-disabled button disabledButton emotion-13"
className="MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-disableElevation MuiButton-fullWidth MuiButtonBase-root Mui-disabled button disabledButton emotion-17"
disabled={true}
onBlur={[Function]}
onClick={[Function]}
Expand All @@ -833,7 +863,7 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-4:focus::-ms-input-p
</div>
<div>
<button
className="MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-disableElevation MuiButton-fullWidth MuiButtonBase-root button outlinedButton emotion-14"
className="MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-disableElevation MuiButton-fullWidth MuiButtonBase-root button outlinedButton emotion-18"
disabled={false}
onBlur={[Function]}
onClick={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -958,8 +958,8 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
<label
className="MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-standard MuiFormLabel-root MuiFormLabel-colorPrimary emotion-9"
data-shrink={false}
htmlFor="mui-59"
id="mui-59-label"
htmlFor="mui-60"
id="mui-60-label"
>
החל מתאריך
</label>
Expand All @@ -973,7 +973,7 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
aria-readonly={true}
autoFocus={false}
className="MuiInput-input MuiInputBase-input emotion-11"
id="mui-59"
id="mui-60"
onAnimationStart={[Function]}
onBlur={[Function]}
onChange={[Function]}
Expand All @@ -993,8 +993,8 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
<label
className="MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-standard MuiFormLabel-root MuiFormLabel-colorPrimary emotion-9"
data-shrink={false}
htmlFor="mui-61"
id="mui-61-label"
htmlFor="mui-62"
id="mui-62-label"
>
עד תאריך
</label>
Expand All @@ -1008,7 +1008,7 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
aria-readonly={true}
autoFocus={false}
className="MuiInput-input MuiInputBase-input emotion-11"
id="mui-61"
id="mui-62"
onAnimationStart={[Function]}
onBlur={[Function]}
onChange={[Function]}
Expand Down Expand Up @@ -2267,8 +2267,8 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
<label
className="MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-standard MuiFormLabel-root MuiFormLabel-colorPrimary emotion-9"
data-shrink={false}
htmlFor="mui-63"
id="mui-63-label"
htmlFor="mui-64"
id="mui-64-label"
>
החל מתאריך
</label>
Expand All @@ -2282,7 +2282,7 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
aria-readonly={true}
autoFocus={false}
className="MuiInput-input MuiInputBase-input emotion-11"
id="mui-63"
id="mui-64"
onAnimationStart={[Function]}
onBlur={[Function]}
onChange={[Function]}
Expand All @@ -2302,8 +2302,8 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
<label
className="MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-standard MuiFormLabel-root MuiFormLabel-colorPrimary emotion-9"
data-shrink={false}
htmlFor="mui-65"
id="mui-65-label"
htmlFor="mui-66"
id="mui-66-label"
>
עד תאריך
</label>
Expand All @@ -2317,7 +2317,7 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
aria-readonly={true}
autoFocus={false}
className="MuiInput-input MuiInputBase-input emotion-11"
id="mui-65"
id="mui-66"
onAnimationStart={[Function]}
onBlur={[Function]}
onChange={[Function]}
Expand Down Expand Up @@ -3458,8 +3458,8 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
<label
className="MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-standard MuiFormLabel-root MuiFormLabel-colorPrimary emotion-9"
data-shrink={false}
htmlFor="mui-67"
id="mui-67-label"
htmlFor="mui-68"
id="mui-68-label"
>
החל מתאריך
</label>
Expand All @@ -3473,7 +3473,7 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
aria-readonly={true}
autoFocus={false}
className="MuiInput-input MuiInputBase-input emotion-11"
id="mui-67"
id="mui-68"
onAnimationStart={[Function]}
onBlur={[Function]}
onChange={[Function]}
Expand All @@ -3493,8 +3493,8 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
<label
className="MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-standard MuiFormLabel-root MuiFormLabel-colorPrimary emotion-9"
data-shrink={false}
htmlFor="mui-69"
id="mui-69-label"
htmlFor="mui-70"
id="mui-70-label"
>
עד תאריך
</label>
Expand All @@ -3508,7 +3508,7 @@ label[data-shrink=false]+.MuiInputBase-formControl .emotion-11:focus::-ms-input-
aria-readonly={true}
autoFocus={false}
className="MuiInput-input MuiInputBase-input emotion-11"
id="mui-69"
id="mui-70"
onAnimationStart={[Function]}
onBlur={[Function]}
onChange={[Function]}
Expand Down
Loading