@eeplatform/nuxt-layer-common 1.7.45 → 1.7.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/components/EnrollmentForm.vue +36 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @eeplatform/nuxt-layer-common
|
|
2
2
|
|
|
3
|
+
## 1.7.47
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7b536bb: Fix enrollment form, birthdate limit
|
|
8
|
+
|
|
9
|
+
## 1.7.46
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a7df34e: Fix enrollment form birthdate and age validation
|
|
14
|
+
|
|
3
15
|
## 1.7.45
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1463,19 +1463,51 @@ const prop = defineProps({
|
|
|
1463
1463
|
});
|
|
1464
1464
|
const { requiredRule, debounce } = useUtils();
|
|
1465
1465
|
|
|
1466
|
+
const birthdateMask = useMask({ mask: "##-##-####" });
|
|
1467
|
+
|
|
1468
|
+
function parseBirthdate(v: string): Date {
|
|
1469
|
+
const masked = birthdateMask.mask(v);
|
|
1470
|
+
const [month, day, year] = masked.split("-");
|
|
1471
|
+
return new Date(`${year}-${month}-${day}`);
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1466
1474
|
const birthdateRules = [
|
|
1467
1475
|
(v: any) => !!v || "Birthdate is required",
|
|
1468
1476
|
(v: any) => {
|
|
1469
1477
|
if (!v) return true;
|
|
1470
|
-
const date =
|
|
1478
|
+
const date = parseBirthdate(v);
|
|
1471
1479
|
return date.toString() !== "Invalid Date" || "Invalid date";
|
|
1472
1480
|
},
|
|
1473
1481
|
(v: any) => {
|
|
1474
1482
|
if (!v) return true;
|
|
1475
|
-
const date =
|
|
1483
|
+
const date = parseBirthdate(v);
|
|
1476
1484
|
if (date.toString() === "Invalid Date") return true;
|
|
1477
1485
|
return date <= new Date() || "Birthdate cannot be in the future";
|
|
1478
1486
|
},
|
|
1487
|
+
(v: any) => {
|
|
1488
|
+
if (!v) return true;
|
|
1489
|
+
const date = parseBirthdate(v);
|
|
1490
|
+
if (date.toString() === "Invalid Date") return true;
|
|
1491
|
+
const today = new Date();
|
|
1492
|
+
let age = today.getFullYear() - date.getFullYear();
|
|
1493
|
+
const monthDiff = today.getMonth() - date.getMonth();
|
|
1494
|
+
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < date.getDate())) {
|
|
1495
|
+
age--;
|
|
1496
|
+
}
|
|
1497
|
+
return age >= 5 || "Learner must be at least 5 years old (Kindergarten age)";
|
|
1498
|
+
},
|
|
1499
|
+
(v: any) => {
|
|
1500
|
+
if (!v) return true;
|
|
1501
|
+
const date = parseBirthdate(v);
|
|
1502
|
+
if (date.toString() === "Invalid Date") return true;
|
|
1503
|
+
const today = new Date();
|
|
1504
|
+
let age = today.getFullYear() - date.getFullYear();
|
|
1505
|
+
const monthDiff = today.getMonth() - date.getMonth();
|
|
1506
|
+
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < date.getDate())) {
|
|
1507
|
+
age--;
|
|
1508
|
+
}
|
|
1509
|
+
return age <= 80 || "Learner must be at most 80 years old";
|
|
1510
|
+
},
|
|
1479
1511
|
];
|
|
1480
1512
|
|
|
1481
1513
|
const enrollment = defineModel<TLearner>({
|
|
@@ -2564,13 +2596,11 @@ watchEffect(() => {
|
|
|
2564
2596
|
import { useMask } from "vuetify";
|
|
2565
2597
|
|
|
2566
2598
|
watchEffect(() => {
|
|
2567
|
-
const mask = useMask({ mask: "##-##-####" });
|
|
2568
|
-
const date = mask.mask(enrollment.value.learnerInfo.birthDate);
|
|
2569
2599
|
if (
|
|
2570
2600
|
enrollment.value.learnerInfo.birthDate &&
|
|
2571
|
-
|
|
2601
|
+
parseBirthdate(enrollment.value.learnerInfo.birthDate).toString() !== "Invalid Date"
|
|
2572
2602
|
) {
|
|
2573
|
-
const birthDate =
|
|
2603
|
+
const birthDate = parseBirthdate(enrollment.value.learnerInfo.birthDate);
|
|
2574
2604
|
|
|
2575
2605
|
const today = new Date();
|
|
2576
2606
|
let age = today.getFullYear() - birthDate.getFullYear();
|