pukaad-ui-lib 1.141.0 → 1.143.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.143.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -31,8 +31,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
31
31
  fullHeight: boolean;
32
32
  name: string;
33
33
  limit: number;
34
- disabledErrorMessage: boolean;
35
34
  accept: string;
35
+ disabledErrorMessage: boolean;
36
36
  labelIcon: string;
37
37
  disabledDrop: boolean;
38
38
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -31,8 +31,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
31
31
  fullHeight: boolean;
32
32
  name: string;
33
33
  limit: number;
34
- disabledErrorMessage: boolean;
35
34
  accept: string;
35
+ disabledErrorMessage: boolean;
36
36
  labelIcon: string;
37
37
  disabledDrop: boolean;
38
38
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -45,11 +45,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
45
45
  name: string;
46
46
  disabled: boolean;
47
47
  limit: number;
48
+ resize: "none" | "both" | "horizontal" | "vertical";
48
49
  disabledErrorMessage: boolean;
49
50
  disabledBorder: boolean;
50
51
  showCounter: boolean;
51
52
  readonly: boolean;
52
- resize: "none" | "both" | "horizontal" | "vertical";
53
53
  rows: number;
54
54
  heightScroll: boolean;
55
55
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -45,11 +45,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
45
45
  name: string;
46
46
  disabled: boolean;
47
47
  limit: number;
48
+ resize: "none" | "both" | "horizontal" | "vertical";
48
49
  disabledErrorMessage: boolean;
49
50
  disabledBorder: boolean;
50
51
  showCounter: boolean;
51
52
  readonly: boolean;
52
- resize: "none" | "both" | "horizontal" | "vertical";
53
53
  rows: number;
54
54
  heightScroll: boolean;
55
55
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -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,32 @@ 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 === "SUCCESS_OK") {
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
+ const profileItem = listMenu.value.find((m) => m.label === "\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C");
257
+ if (profileItem && profileName.value) {
258
+ profileItem.value = profileName.value;
259
+ }
260
+ step.value = "menu";
261
+ } else {
262
+ 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");
263
+ }
264
+ } catch (error) {
265
+ console.error("Update profile error:", error);
266
+ $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");
267
+ } finally {
268
+ isLoading.value = false;
269
+ }
235
270
  };
236
271
  const goToHelpCenter = () => {
237
272
  console.log("go to help center");
@@ -240,21 +275,20 @@ const goToDetailPremiumID = () => {
240
275
  console.log("go to detail premium id");
241
276
  };
242
277
  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
278
  const commonMenus = [
248
279
  {
249
280
  label: "\u0E0A\u0E37\u0E48\u0E2D\u0E42\u0E1B\u0E23\u0E44\u0E1F\u0E25\u0E4C",
250
- value: fakeProfileName,
281
+ value: props.profileDetail?.profileName || "-",
251
282
  action: () => {
252
283
  step.value = "profile-name";
284
+ if (props.profileDetail?.profileName && props.profileDetail.profileName !== "-") {
285
+ profileName.value = props.profileDetail.profileName;
286
+ }
253
287
  }
254
288
  },
255
289
  {
256
290
  label: "\u0E40\u0E1A\u0E2A\u0E34\u0E04 ID",
257
- value: fakeBasicID,
291
+ value: props.profileDetail?.basicId || "-",
258
292
  action: () => {
259
293
  }
260
294
  }
@@ -262,7 +296,7 @@ const getProfile = () => {
262
296
  const businessMenus = [
263
297
  {
264
298
  label: "\u0E1E\u0E23\u0E35\u0E40\u0E21\u0E35\u0E22\u0E21 ID",
265
- value: fakePremiumID,
299
+ value: props.profileDetail?.premiumId || "\u0E22\u0E31\u0E07\u0E44\u0E21\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14",
266
300
  action: () => {
267
301
  step.value = "premium-id";
268
302
  }
@@ -271,7 +305,7 @@ const getProfile = () => {
271
305
  const profileMenus = [
272
306
  {
273
307
  label: "\u0E2B\u0E21\u0E27\u0E14\u0E2B\u0E21\u0E39\u0E48",
274
- value: fakeCategory,
308
+ value: props.profileDetail?.category || "-",
275
309
  action: () => {
276
310
  step.value = "category";
277
311
  }
@@ -297,7 +331,11 @@ watch(step, (state) => {
297
331
  reset();
298
332
  }
299
333
  });
300
- onMounted(() => {
301
- getProfile();
302
- });
334
+ watch(
335
+ () => props.profileDetail,
336
+ () => {
337
+ getProfile();
338
+ },
339
+ { deep: true, immediate: true }
340
+ );
303
341
  </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.143.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",