pukaad-ui-lib 1.169.1 → 1.170.1

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.169.1",
4
+ "version": "1.170.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -18,10 +18,14 @@ type __VLS_Props = {
18
18
  disabledDividerBottom?: boolean;
19
19
  disabled?: boolean;
20
20
  iconSize?: number | string;
21
+ id?: string;
22
+ state?: string;
21
23
  };
22
24
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
25
+ id: string;
23
26
  disabled: boolean;
24
27
  disabledPadding: boolean;
28
+ state: string;
25
29
  itemCount: Count;
26
30
  itemActive: Reacted;
27
31
  padding: string | number;
@@ -32,6 +32,7 @@
32
32
 
33
33
  <script setup>
34
34
  import { computed, reactive, ref, watch } from "vue";
35
+ import { useApi } from "../../composables/useApi";
35
36
  const isOpenModalShare = ref(false);
36
37
  const props = defineProps({
37
38
  itemCount: { type: Object, required: false, default: () => ({
@@ -50,7 +51,9 @@ const props = defineProps({
50
51
  disabledDividerTop: { type: Boolean, required: false, default: false },
51
52
  disabledDividerBottom: { type: Boolean, required: false, default: false },
52
53
  disabled: { type: Boolean, required: false, default: false },
53
- iconSize: { type: [Number, String], required: false, default: 20 }
54
+ iconSize: { type: [Number, String], required: false, default: 20 },
55
+ id: { type: String, required: false, default: "" },
56
+ state: { type: String, required: false, default: "" }
54
57
  });
55
58
  const computedPadding = computed(
56
59
  () => props.disabledPadding ? 0 : props.padding
@@ -110,9 +113,22 @@ const reactions = [
110
113
  action: toggleShared
111
114
  }
112
115
  ];
113
- function toggleLike() {
114
- reaction.liked = !reaction.liked;
116
+ async function toggleLike() {
117
+ const previousLiked = reaction.liked;
118
+ reaction.liked = !previousLiked;
115
119
  counts.liked += reaction.liked ? 1 : -1;
120
+ if (props.state === "blog" && props.id) {
121
+ try {
122
+ const api = useApi();
123
+ await api(`/blogs/${props.id}/like`, {
124
+ method: reaction.liked ? "POST" : "DELETE"
125
+ });
126
+ } catch (error) {
127
+ console.error(error);
128
+ reaction.liked = previousLiked;
129
+ counts.liked += previousLiked ? 1 : -1;
130
+ }
131
+ }
116
132
  }
117
133
  function toggleBookmark() {
118
134
  reaction.bookmarked = !reaction.bookmarked;
@@ -18,10 +18,14 @@ type __VLS_Props = {
18
18
  disabledDividerBottom?: boolean;
19
19
  disabled?: boolean;
20
20
  iconSize?: number | string;
21
+ id?: string;
22
+ state?: string;
21
23
  };
22
24
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
25
+ id: string;
23
26
  disabled: boolean;
24
27
  disabledPadding: boolean;
28
+ state: string;
25
29
  itemCount: Count;
26
30
  itemActive: Reacted;
27
31
  padding: string | number;
@@ -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;
@@ -7,7 +7,8 @@
7
7
  >
8
8
  <div class="flex flex-col gap-2 items-center">
9
9
  <InputOTP :disabled="isTimeExp" v-model="valueOTP" />
10
- <div v-if="isTimeExp" class="text-center">
10
+ <div v-if="isLoading" class="text-center">กำลังส่งรหัสยืนยัน...</div>
11
+ <div v-else-if="isTimeExp" class="text-center">
11
12
  รหัสหมดอายุ
12
13
  <span class="text-primary cursor-pointer" @click="handleSendEmail">
13
14
  ขอรหัสผ่านใหม่
@@ -50,6 +51,7 @@ const isOpen = defineModel({ type: Boolean, ...{
50
51
  } });
51
52
  const valueOTP = ref("");
52
53
  const timeExp = ref("");
54
+ const isLoading = ref(false);
53
55
  const displayTimeExp = CountdownTime(timeExp);
54
56
  const isTimeExp = computed(() => {
55
57
  return !timeExp.value || displayTimeExp.value === "00:00";
@@ -78,6 +80,7 @@ const onVerifyOTP = async () => {
78
80
  };
79
81
  const handleSendEmail = async () => {
80
82
  try {
83
+ isLoading.value = true;
81
84
  if (!props.email) throw new Error("\u0E01\u0E23\u0E38\u0E13\u0E32\u0E23\u0E30\u0E1A\u0E38 email");
82
85
  const response = await api(
83
86
  "/me/email-otp-request",
@@ -88,9 +91,11 @@ const handleSendEmail = async () => {
88
91
  }
89
92
  }
90
93
  );
91
- timeExp.value = response.expired_time;
94
+ timeExp.value = response.data.expired_time;
92
95
  } catch (err) {
93
96
  $toast.error("\u0E1E\u0E1A\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14 \u0E1A\u0E32\u0E07\u0E2D\u0E22\u0E48\u0E32\u0E07 !");
97
+ } finally {
98
+ isLoading.value = false;
94
99
  }
95
100
  };
96
101
  watch(isOpen, (v) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.169.1",
3
+ "version": "1.170.1",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",