@eeplatform/nuxt-layer-common 1.2.10 → 1.3.0

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.
@@ -2,7 +2,7 @@
2
2
  <v-card width="100%">
3
3
  <v-toolbar>
4
4
  <v-row no-gutters class="fill-height px-6" align="center">
5
- <span class="font-weight-bold text-h5"> Bulk Upload Schools </span>
5
+ <span class="font-weight-bold text-h5"> School Bulk Upload </span>
6
6
  </v-row>
7
7
  </v-toolbar>
8
8
  <v-card-text style="max-height: 100vh; overflow-y: auto">
@@ -46,25 +46,6 @@
46
46
  </v-row>
47
47
  </v-col>
48
48
 
49
- <v-col cols="12" class="mt-4">
50
- <v-row no-gutters>
51
- <v-col cols="12">
52
- <v-btn
53
- variant="outlined"
54
- color="primary"
55
- class="text-none"
56
- size="large"
57
- block
58
- prepend-icon="mdi-download"
59
- @click="downloadTemplate"
60
- :disabled="disable"
61
- >
62
- Download Template
63
- </v-btn>
64
- </v-col>
65
- </v-row>
66
- </v-col>
67
-
68
49
  <v-col cols="12" class="mt-2">
69
50
  <v-divider></v-divider>
70
51
  </v-col>
@@ -128,9 +109,7 @@
128
109
  <v-alert type="info" variant="tonal" class="text-caption">
129
110
  <strong>File Requirements:</strong><br />
130
111
  • Supported formats: CSV, Excel (.xlsx, .xls)<br />
131
- • Required columns: schoolName, schoolId, district<br />
132
112
  • Maximum file size: 16MB<br />
133
- • Download the template above for the correct format
134
113
  </v-alert>
135
114
  </v-col>
136
115
 
@@ -149,14 +128,15 @@
149
128
  </v-form>
150
129
  </v-card-text>
151
130
 
152
- <v-toolbar>
153
- <v-row class="px-6">
131
+ <v-toolbar density="compact">
132
+ <v-row no-gutters>
154
133
  <v-col cols="6">
155
134
  <v-btn
135
+ tile
156
136
  block
157
137
  variant="text"
158
138
  class="text-none"
159
- size="large"
139
+ size="48"
160
140
  @click="cancel"
161
141
  :disabled="disable"
162
142
  >
@@ -166,11 +146,12 @@
166
146
 
167
147
  <v-col cols="6">
168
148
  <v-btn
149
+ tile
169
150
  block
170
151
  variant="flat"
171
152
  color="black"
172
153
  class="text-none"
173
- size="large"
154
+ size="48"
174
155
  :disabled="!isFormValid || disable"
175
156
  @click="submit"
176
157
  :loading="disable"
@@ -306,30 +287,6 @@ function formatFileSize(bytes: number): string {
306
287
  return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
307
288
  }
308
289
 
309
- function downloadTemplate() {
310
- // Create CSV template with the expected format
311
- const headers = ["schoolName", "schoolId", "district"];
312
- const sampleData = ["Sample Elementary School", "ELEM001", "District 1"];
313
-
314
- const csvContent = [
315
- headers.join(","),
316
- sampleData.map((field) => `"${field}"`).join(","),
317
- ].join("\n");
318
-
319
- // Create and download file
320
- const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
321
- const link = document.createElement("a");
322
- const url = URL.createObjectURL(blob);
323
-
324
- link.setAttribute("href", url);
325
- link.setAttribute("download", "school-bulk-upload-template.csv");
326
- link.style.visibility = "hidden";
327
-
328
- document.body.appendChild(link);
329
- link.click();
330
- document.body.removeChild(link);
331
- }
332
-
333
290
  async function submit() {
334
291
  disable.value = true;
335
292
  try {
@@ -83,7 +83,7 @@
83
83
  :style="`max-height: ${
84
84
  canCreate || canUpload
85
85
  ? 'calc(100vh - (240px))'
86
- : 'calc(100vh - (180px))'
86
+ : 'calc(100vh - (195px))'
87
87
  } `"
88
88
  >
89
89
  <template #item.createdAt="{ value }">
@@ -309,11 +309,11 @@ const prop = defineProps({
309
309
  },
310
310
  canCreate: {
311
311
  type: Boolean,
312
- default: true,
312
+ default: false,
313
313
  },
314
314
  canUpload: {
315
315
  type: Boolean,
316
- default: true,
316
+ default: false,
317
317
  },
318
318
  canUpdate: {
319
319
  type: Boolean,
@@ -0,0 +1,40 @@
1
+ export default function useOffice() {
2
+ function add(value: TOffice) {
3
+ return useNuxtApp().$api<Record<string, any>>("/api/offices", {
4
+ method: "POST",
5
+ body: value,
6
+ });
7
+ }
8
+
9
+ async function getAll({
10
+ page = 1,
11
+ search = "",
12
+ limit = 10,
13
+ type = "",
14
+ status = "active",
15
+ } = {}) {
16
+ return useNuxtApp().$api<Record<string, any>>("/api/offices", {
17
+ method: "GET",
18
+ query: { page, limit, search, type, status },
19
+ });
20
+ }
21
+
22
+ function updateById(id: string) {
23
+ return useNuxtApp().$api<Record<string, any>>(`/api/offices/${id}`, {
24
+ method: "PUT",
25
+ });
26
+ }
27
+
28
+ function deleteById(id: string) {
29
+ return useNuxtApp().$api<Record<string, any>>(`/api/offices/${id}`, {
30
+ method: "DELETE",
31
+ });
32
+ }
33
+
34
+ return {
35
+ add,
36
+ getAll,
37
+ updateById,
38
+ deleteById,
39
+ };
40
+ }
@@ -0,0 +1,52 @@
1
+ export default function usePlantilla() {
2
+ function addPlantilla(plantilla: TPlantilla) {
3
+ return useNuxtApp().$api<{ message: string }>("/api/plantillas", {
4
+ method: "POST",
5
+ body: plantilla,
6
+ });
7
+ }
8
+
9
+ function getAll({
10
+ page = 1,
11
+ status = "active",
12
+ search = "",
13
+ org = "",
14
+ app = "admin",
15
+ } = {}) {
16
+ return useNuxtApp().$api<Record<string, any>>("/api/plantillas", {
17
+ method: "GET",
18
+ query: { page, status, search, org, app },
19
+ });
20
+ }
21
+
22
+ function bulkAdd(file: File | null, region: string, division: string) {
23
+ if (!file) {
24
+ throw new Error("File not found.");
25
+ }
26
+
27
+ const formData = new FormData();
28
+ formData.append("file", file);
29
+ formData.append("region", region);
30
+ formData.append("division", division);
31
+
32
+ return useNuxtApp().$api<{
33
+ message: string;
34
+ details: {
35
+ successful: number;
36
+ failed: number;
37
+ total: number;
38
+ totalSizeMB: number;
39
+ errors: string[];
40
+ };
41
+ }>("/api/plantillas/bulk", {
42
+ method: "POST",
43
+ body: formData,
44
+ });
45
+ }
46
+
47
+ return {
48
+ addPlantilla,
49
+ getAll,
50
+ bulkAdd,
51
+ };
52
+ }
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.2.10",
5
+ "version": "1.3.0",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"
package/plugins/API.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export default defineNuxtPlugin(() => {
2
2
  const { cookieConfig } = useRuntimeConfig().public;
3
+ const { redirect } = useLocal();
3
4
 
4
5
  const api = $fetch.create({
5
6
  baseURL: "/",
@@ -10,6 +11,17 @@ export default defineNuxtPlugin(() => {
10
11
  const sid = useCookie("sid", cookieConfig).value ?? "";
11
12
  options.headers.set("authorization", sid);
12
13
  },
14
+ onResponse({ response }) {
15
+ if (response.status === 401) {
16
+ // Clear cookie
17
+ let sid = useCookie("sid", cookieConfig).value;
18
+ if (sid) {
19
+ sid = null;
20
+ const { APP_MAIN } = useRuntimeConfig().public;
21
+ redirect(APP_MAIN, "logout");
22
+ }
23
+ }
24
+ },
13
25
  });
14
26
 
15
27
  // Expose to useNuxtApp().$api
@@ -0,0 +1,12 @@
1
+ declare type TOffice = {
2
+ _id?: string;
3
+ code: string;
4
+ name: string;
5
+ type: string;
6
+ parent?: string;
7
+ path: string;
8
+ status?: string;
9
+ createdAt?: string;
10
+ updatedAt?: string;
11
+ deletedAt?: string;
12
+ };
@@ -0,0 +1,29 @@
1
+ declare type TPlantilla = {
2
+ _id?: string;
3
+ itemNumber: string;
4
+ positionTitle: string;
5
+ salaryGrade: number;
6
+ step: number;
7
+ school?: string;
8
+ schoolName?: string;
9
+ office?: string;
10
+ officeName?: string;
11
+ region?: string;
12
+ regionName?: string;
13
+ division?: string;
14
+ divisionName?: string;
15
+ effectivityDate?: string;
16
+ incumbentName?: string;
17
+ basicAnnualSalary?: number;
18
+ basicMonthlySalary?: number;
19
+ positionCategory?: string;
20
+ yearCreated?: string;
21
+ appointmentDate?: string;
22
+ lastPromotionDate?: string;
23
+ eligibility?: string;
24
+ actualDeployment?: string;
25
+ status?: string;
26
+ createdBy?: string;
27
+ createdAt?: string;
28
+ updatedAt?: string;
29
+ };