pukaad-ui-lib 1.141.0 → 1.142.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.141.0",
4
+ "version": "1.142.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -36,9 +36,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
36
36
  id: string;
37
37
  name: string;
38
38
  description: string;
39
+ limit: number;
39
40
  options: AutocompleteOption[] | string[] | number[];
40
41
  placeholder: string;
41
- limit: number;
42
42
  disabledErrorMessage: boolean;
43
43
  disabledBorder: boolean;
44
44
  showCounter: boolean;
@@ -36,9 +36,9 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
36
36
  id: string;
37
37
  name: string;
38
38
  description: string;
39
+ limit: number;
39
40
  options: AutocompleteOption[] | string[] | number[];
40
41
  placeholder: string;
41
- limit: number;
42
42
  disabledErrorMessage: boolean;
43
43
  disabledBorder: boolean;
44
44
  showCounter: boolean;
@@ -26,8 +26,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
26
26
  }>, {
27
27
  name: string;
28
28
  state: "user" | "admin";
29
- placeholder: string;
30
29
  limit: number;
30
+ placeholder: string;
31
31
  ignore: string[];
32
32
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
33
  declare const _default: typeof __VLS_export;
@@ -26,8 +26,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
26
26
  }>, {
27
27
  name: string;
28
28
  state: "user" | "admin";
29
- placeholder: string;
30
29
  limit: number;
30
+ placeholder: string;
31
31
  ignore: string[];
32
32
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
33
  declare const _default: typeof __VLS_export;
@@ -1,5 +1,7 @@
1
+ import type { ModalProfileEditDetail } from "@/types/components/modal/modal-profile-edit";
1
2
  interface Props {
2
3
  state?: "profile" | "business";
4
+ profileDetail?: ModalProfileEditDetail;
3
5
  }
4
6
  type __VLS_Props = Props;
5
7
  type __VLS_ModelProps = {
@@ -12,6 +14,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
12
14
  "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
13
15
  }>, {
14
16
  state: "profile" | "business";
17
+ profileDetail: ModalProfileEditDetail;
15
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
19
  declare const _default: typeof __VLS_export;
17
20
  export default _default;
@@ -87,9 +87,10 @@
87
87
  type="submit"
88
88
  color="primary"
89
89
  full-width
90
- :disabled="!meta.valid"
90
+ :disabled="!meta.valid || isLoading"
91
91
  >
92
- บันทึก
92
+ <span v-if="isLoading">กำลังบันทึก...</span>
93
+ <span v-else>บันทึก</span>
93
94
  </Button>
94
95
  </Form>
95
96
  </template>
@@ -159,8 +160,18 @@
159
160
 
160
161
  <script setup>
161
162
  import { ref, watch, onMounted } from "vue";
163
+ import { useNuxtApp } from "nuxt/app";
164
+ import { useApi } from "../../composables/useApi";
165
+ const { $toast } = useNuxtApp();
166
+ const api = useApi();
162
167
  const props = defineProps({
163
- state: { type: String, required: false, default: "profile" }
168
+ state: { type: String, required: false, default: "profile" },
169
+ profileDetail: { type: Object, required: false, default: () => ({
170
+ profileName: "-",
171
+ basicId: "-",
172
+ premiumId: "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14",
173
+ category: "-"
174
+ }) }
164
175
  });
165
176
  const modelValue = defineModel({ type: Boolean, ...{
166
177
  default: false
@@ -173,6 +184,7 @@ const namePremiumID = ref();
173
184
  const isOpenDropdown = ref(false);
174
185
  const profileCategory = ref();
175
186
  const profileCategoryItems = ref([]);
187
+ const isLoading = ref(false);
176
188
  const isEmoji = (v) => {
177
189
  const emojiRegex = /[\u{1F600}-\u{1F64F}]|[\u{1F300}-\u{1F5FF}]|[\u{1F680}-\u{1F6FF}]|[\u{1F1E0}-\u{1F1FF}]|[\u{2600}-\u{26FF}]|[\u{2700}-\u{27BF}]/gu;
178
190
  return emojiRegex.test(v);
@@ -229,9 +241,28 @@ const handleMenuClick = (menu) => {
229
241
  menu.action();
230
242
  }
231
243
  };
232
- const saveProfileName = () => {
233
- console.log(profileName.value);
234
- step.value = "menu";
244
+ const saveProfileName = async () => {
245
+ if (!profileName.value) return;
246
+ isLoading.value = true;
247
+ try {
248
+ const res = await api("/profiles/me", {
249
+ method: "PUT",
250
+ body: {
251
+ profile_name: profileName.value
252
+ }
253
+ });
254
+ if (res.code === 200) {
255
+ $toast.success(res.message || "\u0E2D\u0E31\u0E1B\u0E40\u0E14\u0E15\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C\u0E2A\u0E33\u0E40\u0E23\u0E47\u0E08");
256
+ step.value = "menu";
257
+ } else {
258
+ throw new Error(res.message || "\u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E2D\u0E31\u0E1B\u0E40\u0E14\u0E15\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C\u0E44\u0E14\u0E49");
259
+ }
260
+ } catch (error) {
261
+ console.error("Update profile error:", error);
262
+ $toast.error(error.message || "\u0E40\u0E01\u0E34\u0E14\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14\u0E43\u0E19\u0E01\u0E32\u0E23\u0E2D\u0E31\u0E1B\u0E40\u0E14\u0E15\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C");
263
+ } finally {
264
+ isLoading.value = false;
265
+ }
235
266
  };
236
267
  const goToHelpCenter = () => {
237
268
  console.log("go to help center");
@@ -240,21 +271,20 @@ const goToDetailPremiumID = () => {
240
271
  console.log("go to detail premium id");
241
272
  };
242
273
  const getProfile = () => {
243
- const fakeProfileName = "testProfile";
244
- const fakeBasicID = "@100006047146577";
245
- const fakePremiumID = "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14";
246
- const fakeCategory = "testCategory";
247
274
  const commonMenus = [
248
275
  {
249
276
  label: "\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C",
250
- value: fakeProfileName,
277
+ value: props.profileDetail?.profileName || "-",
251
278
  action: () => {
252
279
  step.value = "profile-name";
280
+ if (props.profileDetail?.profileName && props.profileDetail.profileName !== "-") {
281
+ profileName.value = props.profileDetail.profileName;
282
+ }
253
283
  }
254
284
  },
255
285
  {
256
286
  label: "\u0E40\u0E1A\u0E2A\u0E34\u0E04 ID",
257
- value: fakeBasicID,
287
+ value: props.profileDetail?.basicId || "-",
258
288
  action: () => {
259
289
  }
260
290
  }
@@ -262,7 +292,7 @@ const getProfile = () => {
262
292
  const businessMenus = [
263
293
  {
264
294
  label: "\u0E1E\u0E23\u0E35\u0E40\u0E21\u0E35\u0E22\u0E21 ID",
265
- value: fakePremiumID,
295
+ value: props.profileDetail?.premiumId || "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14",
266
296
  action: () => {
267
297
  step.value = "premium-id";
268
298
  }
@@ -271,7 +301,7 @@ const getProfile = () => {
271
301
  const profileMenus = [
272
302
  {
273
303
  label: "\u0E2B\u0E21\u0E27\u0E14\u0E2B\u0E21\u0E39\u0E48",
274
- value: fakeCategory,
304
+ value: props.profileDetail?.category || "-",
275
305
  action: () => {
276
306
  step.value = "category";
277
307
  }
@@ -297,7 +327,11 @@ watch(step, (state) => {
297
327
  reset();
298
328
  }
299
329
  });
300
- onMounted(() => {
301
- getProfile();
302
- });
330
+ watch(
331
+ () => props.profileDetail,
332
+ () => {
333
+ getProfile();
334
+ },
335
+ { deep: true, immediate: true }
336
+ );
303
337
  </script>
@@ -1,5 +1,7 @@
1
+ import type { ModalProfileEditDetail } from "@/types/components/modal/modal-profile-edit";
1
2
  interface Props {
2
3
  state?: "profile" | "business";
4
+ profileDetail?: ModalProfileEditDetail;
3
5
  }
4
6
  type __VLS_Props = Props;
5
7
  type __VLS_ModelProps = {
@@ -12,6 +14,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
12
14
  "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
13
15
  }>, {
14
16
  state: "profile" | "business";
17
+ profileDetail: ModalProfileEditDetail;
15
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
19
  declare const _default: typeof __VLS_export;
17
20
  export default _default;
@@ -12,7 +12,10 @@
12
12
 
13
13
  <ModalShare v-model="isOpenModalShare" />
14
14
  <ModalReport state v-model="isOpenModalReport" />
15
- <ModalProfileEdit v-model="isOpenModalProfileEdit" />
15
+ <ModalProfileEdit
16
+ v-model="isOpenModalProfileEdit"
17
+ :profile-detail="props.profileDetail"
18
+ />
16
19
  </template>
17
20
 
18
21
  <script setup>
@@ -20,6 +23,7 @@ import { computed, ref } from "vue";
20
23
  const emit = defineEmits(["profile-edit", "profile-share", "profile-follower-delete", "profile-block", "blog-pin", "blog-unpin", "blog-edit", "blog-delete", "report-blog", "report-place", "report-profile", "report-announce", "report-review", "place-close-duplicate", "review-edit", "review-delete", "archive"]);
21
24
  const props = defineProps({
22
25
  state: { type: String, required: false },
26
+ profileDetail: { type: Object, required: false },
23
27
  items: { type: Array, required: false },
24
28
  variant: { type: null, required: false },
25
29
  circle: { type: Boolean, required: false },
@@ -3,21 +3,21 @@ export declare class Convert {
3
3
  * Convert number to Thai format
4
4
  * @example convertNumber(1500000) => "1.5 ล้าน"
5
5
  */
6
- convertNumber(num: number): string;
6
+ convertNumber: (num: number) => string;
7
7
  /**
8
8
  * Convert date to Thai format
9
9
  * @example convertDate("2024-01-01") => "1 ม.ค. 2567"
10
10
  */
11
- convertDate(date: string | Date | null | undefined, format?: string): string;
11
+ convertDate: (date: string | Date | null | undefined, format?: string) => string;
12
12
  /**
13
13
  * Convert date time to Thai format
14
14
  * @example convertDateTime("2024-01-01 12:00") => "1 ม.ค. 2567 12:00"
15
15
  */
16
- convertDateTime(date: string | Date | null | undefined, format?: string): string;
16
+ convertDateTime: (date: string | Date | null | undefined, format?: string) => string;
17
17
  /**
18
18
  * Convert date to relative text
19
19
  * @example "เมื่อสักครู่", "10 นาทีที่ผ่านมา", "2 ชั่วโมงที่ผ่านมา", "17 ก.พ. 2569, 13:19"
20
20
  */
21
- convertDateTorelativeText(date: string | Date | null | undefined): string;
21
+ convertDateTorelativeText: (date: string | Date | null | undefined) => string;
22
22
  }
23
23
  export declare function useConvert(): Convert;
@@ -4,7 +4,7 @@ export class Convert {
4
4
  * Convert number to Thai format
5
5
  * @example convertNumber(1500000) => "1.5 ล้าน"
6
6
  */
7
- convertNumber(num) {
7
+ convertNumber = (num) => {
8
8
  if (num >= 1e6) {
9
9
  const value = Math.floor(num / 1e6 * 10) / 10;
10
10
  return value.toString().replace(/\.0$/, "") + " \u0E25\u0E49\u0E32\u0E19";
@@ -22,28 +22,28 @@ export class Convert {
22
22
  return value.toString().replace(/\.0$/, "") + " \u0E1E\u0E31\u0E19";
23
23
  }
24
24
  return num.toString();
25
- }
25
+ };
26
26
  /**
27
27
  * Convert date to Thai format
28
28
  * @example convertDate("2024-01-01") => "1 ม.ค. 2567"
29
29
  */
30
- convertDate(date, format = "D MMM BBBB") {
30
+ convertDate = (date, format = "D MMM BBBB") => {
31
31
  if (!date) return "-";
32
32
  return dayjs(date).format(format);
33
- }
33
+ };
34
34
  /**
35
35
  * Convert date time to Thai format
36
36
  * @example convertDateTime("2024-01-01 12:00") => "1 ม.ค. 2567 12:00"
37
37
  */
38
- convertDateTime(date, format = "D MMM BBBB, HH:mm") {
38
+ convertDateTime = (date, format = "D MMM BBBB, HH:mm") => {
39
39
  if (!date) return "-";
40
40
  return dayjs(date).format(format);
41
- }
41
+ };
42
42
  /**
43
43
  * Convert date to relative text
44
44
  * @example "เมื่อสักครู่", "10 นาทีที่ผ่านมา", "2 ชั่วโมงที่ผ่านมา", "17 ก.พ. 2569, 13:19"
45
45
  */
46
- convertDateTorelativeText(date) {
46
+ convertDateTorelativeText = (date) => {
47
47
  if (!date) return "-";
48
48
  const target = dayjs(date);
49
49
  const now = dayjs();
@@ -59,7 +59,7 @@ export class Convert {
59
59
  return `${diffHour} \u0E0A\u0E31\u0E48\u0E27\u0E42\u0E21\u0E07\u0E17\u0E35\u0E48\u0E1C\u0E48\u0E32\u0E19\u0E21\u0E32`;
60
60
  }
61
61
  return this.convertDateTime(date, "D MMM BBBB, HH:mm");
62
- }
62
+ };
63
63
  }
64
64
  const convertInstance = new Convert();
65
65
  export function useConvert() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.141.0",
3
+ "version": "1.142.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",