@eeplatform/nuxt-layer-common 1.7.54 → 1.7.56

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eeplatform/nuxt-layer-common
2
2
 
3
+ ## 1.7.56
4
+
5
+ ### Patch Changes
6
+
7
+ - df8f3cf: Fix enrollment form
8
+
9
+ ## 1.7.55
10
+
11
+ ### Patch Changes
12
+
13
+ - ce622a8: Fix enrollment form
14
+
3
15
  ## 1.7.54
4
16
 
5
17
  ### Patch Changes
@@ -1530,12 +1530,31 @@ const enrollment = defineModel<TLearner>({
1530
1530
 
1531
1531
  const { cookieConfig } = useRuntimeConfig().public;
1532
1532
 
1533
- if (prop.school) {
1534
- setTimeout(() => {
1533
+ const { getById: getSchoolById } = useSchool();
1534
+
1535
+ if (prop.schoolId) {
1536
+ setTimeout(async () => {
1535
1537
  enrollment.value.schoolId = prop.schoolId ?? "school";
1536
1538
  }, 1000);
1537
1539
  }
1538
1540
 
1541
+ if (prop.school && !prop.selfService) {
1542
+ setTimeout(async () => {
1543
+ try {
1544
+ const school = await getSchoolById(prop.school ?? "school");
1545
+ if (school) {
1546
+ enrollment.value.school = school._id;
1547
+ enrollment.value.region = school.region;
1548
+ enrollment.value.province = school.province;
1549
+ enrollment.value.cityMunicipality = school.cityMunicipality;
1550
+ enrollment.value.schoolName = school.name;
1551
+ }
1552
+ } catch (error) {
1553
+ console.error("Error setting school ID:", error);
1554
+ }
1555
+ }, 1000);
1556
+ }
1557
+
1539
1558
  enrollment.value.createdBy = useCookie("user", cookieConfig).value ?? "";
1540
1559
 
1541
1560
  function validZipCode(value: string) {
@@ -2244,8 +2263,11 @@ watch(selectedSchool, (val) => {
2244
2263
 
2245
2264
  const school = schools.value.find((s) => s.id === val);
2246
2265
 
2247
- if (school?.name) {
2266
+ if (school) {
2248
2267
  enrollment.value.school = school?._id ?? "";
2268
+ }
2269
+
2270
+ if (school?.name) {
2249
2271
  enrollment.value.schoolName = school?.name;
2250
2272
  }
2251
2273
 
@@ -29,46 +29,6 @@
29
29
  </span>
30
30
  </v-col>
31
31
 
32
- <v-col v-if="isSelfService" cols="12">
33
- <InputLabel title="Region" />
34
- <v-autocomplete
35
- v-model="step1.answer.region"
36
- :items="regions"
37
- item-title="name"
38
- item-value="code"
39
- :loading="regionStatus"
40
- :disabled="regionStatus"
41
- ></v-autocomplete>
42
- </v-col>
43
-
44
- <v-col v-if="isSelfService" cols="12">
45
- <InputLabel title="Province" />
46
- <v-autocomplete
47
- v-model="step1.answer.province"
48
- :items="step1Provinces"
49
- item-title="name"
50
- item-value="code"
51
- :return-object="false"
52
- :loading="step1ProvincesStatus"
53
- :disabled="step1ProvincesStatus || !step1.answer.region"
54
- ></v-autocomplete>
55
- </v-col>
56
-
57
- <v-col v-if="isSelfService" cols="12">
58
- <InputLabel title="City/Municipality" />
59
- <v-autocomplete
60
- v-model="step1.answer.cityMunicipality"
61
- :items="step1CitiesMunicipalities"
62
- item-title="name"
63
- item-value="code"
64
- :loading="step1CitiesMunicipalitiesStatus"
65
- :disabled="
66
- step1CitiesMunicipalitiesStatus ||
67
- !step1.answer.province
68
- "
69
- ></v-autocomplete>
70
- </v-col>
71
-
72
32
  <v-col cols="12">
73
33
  <InputLabel title="School" required />
74
34
  <v-combobox
@@ -110,6 +70,49 @@
110
70
  </v-combobox>
111
71
  </v-col>
112
72
 
73
+ <v-col v-if="isSelfService" cols="12">
74
+ <InputLabel title="Region" />
75
+ <v-autocomplete
76
+ v-model="step1.answer.region"
77
+ :items="regions"
78
+ item-title="name"
79
+ item-value="code"
80
+ :loading="regionStatus"
81
+ :disabled="regionStatus"
82
+ clearable
83
+ ></v-autocomplete>
84
+ </v-col>
85
+
86
+ <v-col v-if="isSelfService" cols="12">
87
+ <InputLabel title="Province" />
88
+ <v-autocomplete
89
+ v-model="step1.answer.province"
90
+ :items="step1Provinces"
91
+ item-title="name"
92
+ item-value="code"
93
+ :return-object="false"
94
+ :loading="step1ProvincesStatus"
95
+ :disabled="step1ProvincesStatus || !step1.answer.region"
96
+ clearable
97
+ ></v-autocomplete>
98
+ </v-col>
99
+
100
+ <v-col v-if="isSelfService" cols="12">
101
+ <InputLabel title="City/Municipality" />
102
+ <v-autocomplete
103
+ v-model="step1.answer.cityMunicipality"
104
+ :items="step1CitiesMunicipalities"
105
+ item-title="name"
106
+ item-value="code"
107
+ :loading="step1CitiesMunicipalitiesStatus"
108
+ :disabled="
109
+ step1CitiesMunicipalitiesStatus ||
110
+ !step1.answer.province
111
+ "
112
+ clearable
113
+ ></v-autocomplete>
114
+ </v-col>
115
+
113
116
  <v-col cols="12" class="mt-4">
114
117
  <v-btn
115
118
  class="text-none px-4"
@@ -269,10 +272,39 @@ watchEffect(() => {
269
272
  }
270
273
  });
271
274
 
275
+ // Auto-fill region/province/city when a school is selected
276
+ const isAutoFillingFromSchool = ref(false);
277
+
278
+ watch(
279
+ () => step1.value.answer.schoolId,
280
+ (newSchoolId) => {
281
+ if (!newSchoolId) return;
282
+ const school = schools.value.find((s) => s.id === newSchoolId);
283
+ if (!school) return;
284
+
285
+ isAutoFillingFromSchool.value = true;
286
+ step1.value.answer.school = school._id ?? "";
287
+ step1.value.answer.schoolName = school.name;
288
+ step1.value.answer.cityMunicipality = school.cityMunicipalityPSGC ?? "";
289
+ step1.value.answer.province = school.cityMunicipalityPSGC
290
+ ? school.cityMunicipalityPSGC.slice(0, 5) + "00000"
291
+ : "";
292
+ step1.value.answer.region = school.cityMunicipalityPSGC
293
+ ? school.cityMunicipalityPSGC.slice(0, 2) + "00000000"
294
+ : "";
295
+ step1.value.answer.regionName = school.regionName ?? "";
296
+
297
+ nextTick(() => {
298
+ isAutoFillingFromSchool.value = false;
299
+ });
300
+ }
301
+ );
302
+
272
303
  // Clear cascade: region -> province -> city
273
304
  watch(
274
305
  () => step1.value.answer.region,
275
306
  () => {
307
+ if (isAutoFillingFromSchool.value) return;
276
308
  step1.value.answer.province = "";
277
309
  step1.value.answer.cityMunicipality = "";
278
310
  step1.value.answer.schoolId = "";
@@ -282,6 +314,7 @@ watch(
282
314
  watch(
283
315
  () => step1.value.answer.province,
284
316
  () => {
317
+ if (isAutoFillingFromSchool.value) return;
285
318
  step1.value.answer.cityMunicipality = "";
286
319
  step1.value.answer.schoolId = "";
287
320
  }
@@ -290,6 +323,7 @@ watch(
290
323
  watch(
291
324
  () => step1.value.answer.cityMunicipality,
292
325
  () => {
326
+ if (isAutoFillingFromSchool.value) return;
293
327
  step1.value.answer.schoolId = "";
294
328
  }
295
329
  );
@@ -6,8 +6,6 @@ export default defineNuxtRouteMiddleware(async (to) => {
6
6
  const APP = useRuntimeConfig().public.APP;
7
7
  const org = (to.params.org as string) ?? "";
8
8
 
9
- console.log(APP);
10
-
11
9
  const { loggedInUser } = useLocalAuth();
12
10
 
13
11
  const { getByApp } = useMember();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@eeplatform/nuxt-layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "1.7.54",
5
+ "version": "1.7.56",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"
@@ -15,7 +15,7 @@ export default defineNuxtPlugin(() => {
15
15
  const userId = computed(() => useCookie("user").value ?? "");
16
16
 
17
17
  const { data: userMemberData, error: userMemberError } = useLazyAsyncData(
18
- "get-member-by-id",
18
+ `get-member-by-id-${userId.value}-${APP}-${org}`,
19
19
  () => getByUserType(userId.value, APP, org),
20
20
  { watch: [userId] }
21
21
  );
@@ -37,7 +37,7 @@ export default defineNuxtPlugin(() => {
37
37
  const roleId = computed(() => userMemberData.value?.role ?? "");
38
38
 
39
39
  const { data: getRoleByIdReq } = useLazyAsyncData(
40
- "get-role-by-id",
40
+ `get-role-by-id-${roleId.value}`,
41
41
  () => getById(roleId.value),
42
42
  { watch: [roleId], immediate: false }
43
43
  );