@goweekdays/layer-common 1.6.3 → 1.6.5

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
  # @goweekdays/layer-common
2
2
 
3
+ ## 1.6.5
4
+
5
+ ### Patch Changes
6
+
7
+ - a733401: Add new component
8
+
9
+ ## 1.6.4
10
+
11
+ ### Patch Changes
12
+
13
+ - 552b4e8: Add customer composable, types and proxy
14
+
3
15
  ## 1.6.3
4
16
 
5
17
  ### Patch Changes
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <v-text-field
3
+ type="text"
4
+ :model-value="model"
5
+ @update:model-value="onInput"
6
+ v-bind="$attrs"
7
+ >
8
+ <template v-for="(_, name) in $slots" #[name]="slotProps">
9
+ <slot :name="name" v-bind="slotProps" />
10
+ </template>
11
+ </v-text-field>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ const model = defineModel<string>({ default: "" });
16
+
17
+ const { toSnakeUpperCase } = useUtils();
18
+
19
+ function onInput(val: string) {
20
+ model.value = toSnakeUpperCase(val);
21
+ }
22
+ </script>
@@ -0,0 +1,72 @@
1
+ export default function useCustomer() {
2
+ const customer = ref<TCustomer>({
3
+ _id: "",
4
+ firstName: "",
5
+ lastName: "",
6
+ middleName: "",
7
+ email: "",
8
+ contractNumber: "",
9
+ phoneNumber: "",
10
+ address: {
11
+ street: "",
12
+ cityMunicipality: "",
13
+ postalCode: "",
14
+ country: "",
15
+ },
16
+ org: "",
17
+ });
18
+
19
+ const api = useNuxtApp().$api.create({
20
+ baseURL: "/api/customers/org",
21
+ });
22
+
23
+ function add(org: string, value: Omit<TCustomer, "org">) {
24
+ return api(`/${org}`, {
25
+ method: "POST",
26
+ body: value,
27
+ });
28
+ }
29
+
30
+ function getAll(
31
+ org: string,
32
+ { page = 1, limit = 10, search = "", status = "active" } = {}
33
+ ) {
34
+ return api<Record<string, any>>(`/${org}`, {
35
+ method: "GET",
36
+ params: {
37
+ page,
38
+ limit,
39
+ search,
40
+ status,
41
+ },
42
+ });
43
+ }
44
+
45
+ function getById(org: string, id: string) {
46
+ return api<TCustomer>(`/${org}/id/${id}`, {
47
+ method: "GET",
48
+ });
49
+ }
50
+
51
+ function updateById(org: string, id: string, value: Partial<TCustomer>) {
52
+ return api(`/${org}/id/${id}`, {
53
+ method: "PATCH",
54
+ body: value,
55
+ });
56
+ }
57
+
58
+ function deleteById(org: string, id: string) {
59
+ return api(`/${org}/id/${id}`, {
60
+ method: "DELETE",
61
+ });
62
+ }
63
+
64
+ return {
65
+ customer,
66
+ add,
67
+ getAll,
68
+ getById,
69
+ updateById,
70
+ deleteById,
71
+ };
72
+ }
@@ -502,6 +502,10 @@ export default function useUtils() {
502
502
  },
503
503
  ];
504
504
 
505
+ function toSnakeUpperCase(value: string) {
506
+ return value.replace(/\s+/g, "_").toUpperCase();
507
+ }
508
+
505
509
  function generateYears(
506
510
  generation = 0,
507
511
  mode = "past",
@@ -559,5 +563,6 @@ export default function useUtils() {
559
563
  copyToClipboard,
560
564
  months,
561
565
  generateYears,
566
+ toSnakeUpperCase,
562
567
  };
563
568
  }
package/nuxt.config.ts CHANGED
@@ -86,6 +86,7 @@ export default defineNuxtConfig({
86
86
  },
87
87
  "/api/job/posts/**": { proxy: `${process.env.API_CORE}/api/job/posts/**` },
88
88
  "/api/finance/**": { proxy: `${process.env.API_CORE}/api/finance/**` },
89
+ "/api/customers/**": { proxy: `${process.env.API_CORE}/api/customers/**` },
89
90
  },
90
91
 
91
92
  vite: {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@goweekdays/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "1.6.3",
5
+ "version": "1.6.5",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"
@@ -0,0 +1,18 @@
1
+ declare type TCustomer = {
2
+ _id?: string;
3
+ firstName: string;
4
+ lastName: string;
5
+ middleName?: string;
6
+ email?: string;
7
+ contractNumber?: string;
8
+ phoneNumber?: string;
9
+ address?: {
10
+ street: string;
11
+ cityMunicipality: string;
12
+ postalCode: string;
13
+ country: string;
14
+ };
15
+ org?: string;
16
+ createdAt?: string;
17
+ updatedAt?: string;
18
+ };