pukaad-ui-lib 1.318.0 → 1.319.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.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
3
  "configKey": "pukaadUI",
4
- "version": "1.318.0",
4
+ "version": "1.319.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -21,6 +21,7 @@
21
21
  :fetch-fn="fetchApprovedPlaces"
22
22
  value-key="business_name"
23
23
  label-key="business_name"
24
+ @select="onSelectSuggestedPlace"
24
25
  />
25
26
  <InputLocalizedName
26
27
  name="localizedNames"
@@ -148,6 +149,7 @@
148
149
 
149
150
  <script setup>
150
151
  import { computed, onMounted, watch, reactive, ref } from "vue";
152
+ import { useNuxtApp } from "nuxt/app";
151
153
  import { useApi } from "#pukaad-ui/runtime/composables/useApi";
152
154
  import SuggestPlaceMap from "./suggest-place-map.vue";
153
155
  import InputLocalizedName from "../../input/input-localized-name.vue";
@@ -156,6 +158,7 @@ const props = defineProps({
156
158
  fixedProvinceId: { type: Number, required: false }
157
159
  });
158
160
  const api = useApi();
161
+ const { $alert } = useNuxtApp();
159
162
  const _model = defineModel({ type: Object, ...{ default: () => ({}) } });
160
163
  const modelValue = reactive({
161
164
  address: {},
@@ -224,6 +227,60 @@ const fetchApprovedPlaces = async (page, pageSize, search) => {
224
227
  meta: { total_pages: res.meta?.total_pages ?? 1 }
225
228
  };
226
229
  };
230
+ const lastCheckedDuplicateName = ref("");
231
+ let duplicateCheckTimer = null;
232
+ const showDuplicateAlert = async (item) => {
233
+ const result = await $alert.show({
234
+ type: "warning",
235
+ title: "\u0E21\u0E35\u0E2A\u0E16\u0E32\u0E19\u0E17\u0E35\u0E48\u0E19\u0E35\u0E49\u0E43\u0E19\u0E23\u0E30\u0E1A\u0E1A\u0E41\u0E25\u0E49\u0E27",
236
+ description: `"${item.business_name}" \u0E21\u0E35\u0E2D\u0E22\u0E39\u0E48\u0E41\u0E25\u0E49\u0E27\u0E17\u0E35\u0E48 ${item.address?.full_address ?? ""}`,
237
+ confirmText: "\u0E14\u0E39\u0E2A\u0E16\u0E32\u0E19\u0E17\u0E35\u0E48\u0E19\u0E35\u0E49",
238
+ cancelText: "\u0E1B\u0E34\u0E14",
239
+ showCancelBtn: true
240
+ });
241
+ if (result.isConfirmed && item.id) {
242
+ window.open(`/place/${item.id}`, "_blank");
243
+ }
244
+ };
245
+ const onSelectSuggestedPlace = async (item) => {
246
+ if (props.state === "backoffice") return;
247
+ await showDuplicateAlert(item);
248
+ };
249
+ const checkDuplicate = async () => {
250
+ if (props.state === "backoffice") return;
251
+ if (!isAddressCompleted.value) return;
252
+ const name = modelValue.businessName?.trim();
253
+ if (!name || name === lastCheckedDuplicateName.value) return;
254
+ try {
255
+ const base = listEndpointMap[props.state] ?? "/personal/suggest-places";
256
+ const res = await api(base, {
257
+ query: {
258
+ q: name,
259
+ status: "PENDING,APPROVED",
260
+ page: 1,
261
+ page_size: 10,
262
+ amphur_id: modelValue.address?.amphur_id,
263
+ tambon_id: modelValue.address?.tambon_id
264
+ }
265
+ });
266
+ const match = (res.data ?? []).find(
267
+ (p) => p.business_name.trim().toLowerCase() === name.toLowerCase() && p.address?.tambon_id === modelValue.address?.tambon_id
268
+ );
269
+ if (match) {
270
+ lastCheckedDuplicateName.value = name;
271
+ await showDuplicateAlert(match);
272
+ }
273
+ } catch {
274
+ }
275
+ };
276
+ watch(
277
+ () => [modelValue.businessName, modelValue.address?.tambon_id],
278
+ ([name]) => {
279
+ if (!name || !isAddressCompleted.value || props.state === "backoffice") return;
280
+ if (duplicateCheckTimer) clearTimeout(duplicateCheckTimer);
281
+ duplicateCheckTimer = setTimeout(checkDuplicate, 600);
282
+ }
283
+ );
227
284
  const categoryOptions = ref([]);
228
285
  onMounted(async () => {
229
286
  try {
@@ -64,15 +64,15 @@ declare const __VLS_export: import("vue").DefineComponent<ImageCropperProps, {
64
64
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ImageCropperProps> & Readonly<{}>, {
65
65
  src: string;
66
66
  center: boolean;
67
+ background: boolean;
68
+ modal: boolean;
67
69
  responsive: boolean;
68
70
  restore: boolean;
69
71
  checkCrossOrigin: boolean;
70
72
  checkOrientation: boolean;
71
73
  crossorigin: "" | "anonymous" | "use-credentials";
72
- modal: boolean;
73
74
  guides: boolean;
74
75
  highlight: boolean;
75
- background: boolean;
76
76
  autoCrop: boolean;
77
77
  movable: boolean;
78
78
  rotatable: boolean;
@@ -64,15 +64,15 @@ declare const __VLS_export: import("vue").DefineComponent<ImageCropperProps, {
64
64
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ImageCropperProps> & Readonly<{}>, {
65
65
  src: string;
66
66
  center: boolean;
67
+ background: boolean;
68
+ modal: boolean;
67
69
  responsive: boolean;
68
70
  restore: boolean;
69
71
  checkCrossOrigin: boolean;
70
72
  checkOrientation: boolean;
71
73
  crossorigin: "" | "anonymous" | "use-credentials";
72
- modal: boolean;
73
74
  guides: boolean;
74
75
  highlight: boolean;
75
- background: boolean;
76
76
  autoCrop: boolean;
77
77
  movable: boolean;
78
78
  rotatable: boolean;
@@ -49,11 +49,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
49
49
  label: string;
50
50
  name: string;
51
51
  required: boolean;
52
- gap: string;
53
52
  placeholder: string;
54
53
  labelDetail: string;
55
54
  placeholderDetail: string;
56
55
  requiredDetail: boolean;
56
+ gap: string;
57
57
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
58
58
  declare const _default: typeof __VLS_export;
59
59
  export default _default;
@@ -49,11 +49,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
49
49
  label: string;
50
50
  name: string;
51
51
  required: boolean;
52
- gap: string;
53
52
  placeholder: string;
54
53
  labelDetail: string;
55
54
  placeholderDetail: string;
56
55
  requiredDetail: boolean;
56
+ gap: string;
57
57
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
58
58
  declare const _default: typeof __VLS_export;
59
59
  export default _default;
@@ -35,8 +35,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
35
35
  fullHeight: boolean;
36
36
  fullWidth: boolean;
37
37
  limit: number;
38
- accept: string;
39
38
  disabledErrorMessage: boolean;
39
+ accept: string;
40
40
  labelIcon: string;
41
41
  disabledDrop: boolean;
42
42
  column: boolean;
@@ -35,8 +35,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
35
35
  fullHeight: boolean;
36
36
  fullWidth: boolean;
37
37
  limit: number;
38
- accept: string;
39
38
  disabledErrorMessage: boolean;
39
+ accept: string;
40
40
  labelIcon: string;
41
41
  disabledDrop: boolean;
42
42
  column: boolean;
@@ -22,8 +22,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
22
22
  }>, {
23
23
  id: string;
24
24
  name: string;
25
- disabledForgotPassword: boolean;
26
25
  new: boolean;
26
+ disabledForgotPassword: boolean;
27
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
28
  declare const _default: typeof __VLS_export;
29
29
  export default _default;
@@ -22,8 +22,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
22
22
  }>, {
23
23
  id: string;
24
24
  name: string;
25
- disabledForgotPassword: boolean;
26
25
  new: boolean;
26
+ disabledForgotPassword: boolean;
27
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
28
  declare const _default: typeof __VLS_export;
29
29
  export default _default;
@@ -24,8 +24,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
24
24
  }) => any) | undefined;
25
25
  }>, {
26
26
  title: string;
27
- confirmText: string;
28
27
  disabledForgotPassword: boolean;
28
+ confirmText: string;
29
29
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
30
  declare const _default: typeof __VLS_export;
31
31
  export default _default;
@@ -24,8 +24,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
24
24
  }) => any) | undefined;
25
25
  }>, {
26
26
  title: string;
27
- confirmText: string;
28
27
  disabledForgotPassword: boolean;
28
+ confirmText: string;
29
29
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
30
  declare const _default: typeof __VLS_export;
31
31
  export default _default;
@@ -32,8 +32,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
32
32
  }>, {
33
33
  title: string;
34
34
  mode: "login" | "secure";
35
- confirmText: string;
36
35
  disabledForgotPassword: boolean;
36
+ confirmText: string;
37
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
38
  declare const _default: typeof __VLS_export;
39
39
  export default _default;
@@ -32,8 +32,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
32
32
  }>, {
33
33
  title: string;
34
34
  mode: "login" | "secure";
35
- confirmText: string;
36
35
  disabledForgotPassword: boolean;
36
+ confirmText: string;
37
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
38
  declare const _default: typeof __VLS_export;
39
39
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.318.0",
3
+ "version": "1.319.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",