@eeplatform/nuxt-layer-common 1.7.45 → 1.7.46
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 +6 -0
- package/components/EnrollmentForm.vue +24 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1463,19 +1463,39 @@ 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
|
+
},
|
|
1479
1499
|
];
|
|
1480
1500
|
|
|
1481
1501
|
const enrollment = defineModel<TLearner>({
|
|
@@ -2564,13 +2584,11 @@ watchEffect(() => {
|
|
|
2564
2584
|
import { useMask } from "vuetify";
|
|
2565
2585
|
|
|
2566
2586
|
watchEffect(() => {
|
|
2567
|
-
const mask = useMask({ mask: "##-##-####" });
|
|
2568
|
-
const date = mask.mask(enrollment.value.learnerInfo.birthDate);
|
|
2569
2587
|
if (
|
|
2570
2588
|
enrollment.value.learnerInfo.birthDate &&
|
|
2571
|
-
|
|
2589
|
+
parseBirthdate(enrollment.value.learnerInfo.birthDate).toString() !== "Invalid Date"
|
|
2572
2590
|
) {
|
|
2573
|
-
const birthDate =
|
|
2591
|
+
const birthDate = parseBirthdate(enrollment.value.learnerInfo.birthDate);
|
|
2574
2592
|
|
|
2575
2593
|
const today = new Date();
|
|
2576
2594
|
let age = today.getFullYear() - birthDate.getFullYear();
|