@phygitallabs/phygital-consent 1.0.23 → 1.0.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phygitallabs/phygital-consent",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/api/docs.json CHANGED
@@ -276,7 +276,9 @@
276
276
  "version": { "type": "string" },
277
277
  "effective_date": { "type": "string", "format": "date-time" },
278
278
  "last_updated": { "type": "string", "format": "date-time" },
279
- "meta_data": { "type": "object" }
279
+ "meta_data": { "type": "object" },
280
+ "id": { "type": "string" },
281
+ "content": { "type": "string" }
280
282
  }
281
283
  },
282
284
  "PolicyPreference": {
@@ -2,10 +2,7 @@
2
2
 
3
3
  import { useState } from "react";
4
4
  import { useCreateUserConsent } from "../hooks/useConsent";
5
-
6
- const POLICY_PLACEHOLDER = `
7
- Tanta petere igitur et tam longe abesse non opus est. Quodsi haberent magnalia inter potentiam et divitias, et tamen ista philosophia et disciplina vivendi. Quam ob rem ut illi superiores, nos usque ad hanc aetatem. Sed ut iis bonis erudiamur, quae gignuntur ex tempore. Et tamen rerum necessitatibus saepe vincimur. Quam ob rem ut illi superiores, nos usque ad hanc aetatem.
8
- `.trim();
5
+ import { usePolicies } from "../hooks";
9
6
 
10
7
  const REFUSAL_MESSAGE =
11
8
  "Vì bạn không đồng ý với thỏa thuận này. Chúng tôi sẽ xóa tài khoản trong vòng x ngày. Nhấn nút 'Đồng ý' để tiếp tục";
@@ -29,6 +26,26 @@ export function PolicyPopup({
29
26
  const [agreed, setAgreed] = useState(false);
30
27
  const [showRefusalAlert, setShowRefusalAlert] = useState(false);
31
28
 
29
+ const { data: policies } = usePolicies({
30
+ type: "ACCOUNT_REGISTER",
31
+ });
32
+
33
+ const handleParseJson = (full_description?: string) => {
34
+ try {
35
+ return JSON.parse(full_description || "");
36
+ } catch {
37
+ return {
38
+ htmlContent: "",
39
+ };
40
+ }
41
+ };
42
+
43
+ const privacyPolicyDocument = policies?.data?.[0]?.documents?.find(
44
+ (policy) => policy.id === "privacy_policy",
45
+ );
46
+
47
+ const document = handleParseJson(privacyPolicyDocument?.content);
48
+
32
49
  const createUserConsent = useCreateUserConsent({
33
50
  onSuccess: (_data, variables) => {
34
51
  if (variables.status === "ACCEPTED") onAgreeSuccess?.();
@@ -77,16 +94,23 @@ export function PolicyPopup({
77
94
  display: "flex",
78
95
  alignItems: "center",
79
96
  justifyContent: "center",
97
+ padding: "1rem",
80
98
  }}
81
99
  >
82
100
  <div
83
- className="consent:overflow-hidden consent:flex consent:flex-col"
101
+ className="consent:bg-white consent:border consent:border-gray-200 consent:shadow-lg consent:max-h-[90vh] consent:overflow-hidden consent:flex consent:flex-col"
84
102
  style={{
103
+ backgroundColor: "#fff",
104
+ borderRadius: "0.75rem",
105
+ border: "1px solid #e5e7eb",
106
+ boxShadow: "0 10px 15px -3px rgb(0 0 0 / 0.1)",
107
+ maxWidth: "28rem",
85
108
  width: "100%",
86
- height: "100%",
109
+ maxHeight: "90vh",
87
110
  overflow: "hidden",
88
111
  display: "flex",
89
112
  flexDirection: "column",
113
+ position: "relative",
90
114
  }}
91
115
  onClick={(e) => e.stopPropagation()}
92
116
  >
@@ -113,7 +137,7 @@ export function PolicyPopup({
113
137
  </button> */}
114
138
  <h2
115
139
  style={{
116
- fontSize: "20px",
140
+ fontSize: "18px",
117
141
  fontWeight: 600,
118
142
  color: "#000",
119
143
  padding: "20px 2.5rem 12px 20px",
@@ -126,13 +150,13 @@ export function PolicyPopup({
126
150
  flex: 1,
127
151
  overflowY: "auto",
128
152
  padding: "1rem 1.25rem",
129
- fontSize: "1rem",
153
+ fontSize: "0.875rem",
130
154
  color: "#111827",
131
155
  lineHeight: 1.6,
132
156
  }}
133
157
  >
134
158
  <p style={{ margin: 0, whiteSpace: "pre-wrap" }}>
135
- {POLICY_PLACEHOLDER}
159
+ {document?.htmlContent}
136
160
  </p>
137
161
  </div>
138
162
  <div
@@ -180,7 +204,7 @@ export function PolicyPopup({
180
204
  border: "1px solid #111827",
181
205
  background: "#fff",
182
206
  padding: "0.5rem 1rem",
183
- fontSize: "1rem",
207
+ fontSize: "0.875rem",
184
208
  fontWeight: 500,
185
209
  color: "#111827",
186
210
  cursor: "pointer",
@@ -199,7 +223,7 @@ export function PolicyPopup({
199
223
  borderRadius: "0.5rem",
200
224
  background: agreed ? "#111827" : "#e5e7eb",
201
225
  padding: "0.5rem 1rem",
202
- fontSize: "1rem",
226
+ fontSize: "0.875rem",
203
227
  fontWeight: 500,
204
228
  color: agreed ? "#fff" : "#9ca3af",
205
229
  border: "none",
@@ -212,7 +236,7 @@ export function PolicyPopup({
212
236
  {createUserConsent.isError && (
213
237
  <p
214
238
  className="consent:text-sm consent:text-red-600"
215
- style={{ fontSize: "1rem", color: "#dc2626", margin: 0 }}
239
+ style={{ fontSize: "0.875rem", color: "#dc2626", margin: 0 }}
216
240
  >
217
241
  Đã xảy ra lỗi. Vui lòng thử lại.
218
242
  </p>
@@ -255,7 +279,7 @@ export function PolicyPopup({
255
279
  <p
256
280
  className="consent:text-sm consent:text-gray-700"
257
281
  style={{
258
- fontSize: "1rem",
282
+ fontSize: "0.875rem",
259
283
  color: "#374151",
260
284
  margin: "0 0 1rem 0",
261
285
  lineHeight: 1.5,
@@ -280,7 +304,7 @@ export function PolicyPopup({
280
304
  border: "1px solid #111827",
281
305
  background: "#fff",
282
306
  padding: "0.5rem 1rem",
283
- fontSize: "1rem",
307
+ fontSize: "0.875rem",
284
308
  fontWeight: 500,
285
309
  color: "#111827",
286
310
  cursor: "pointer",
@@ -299,7 +323,7 @@ export function PolicyPopup({
299
323
  borderRadius: "0.5rem",
300
324
  background: "#a71f24",
301
325
  padding: "0.5rem 1rem",
302
- fontSize: "1rem",
326
+ fontSize: "0.875rem",
303
327
  fontWeight: 500,
304
328
  color: "#fff",
305
329
  border: "none",
@@ -312,7 +336,7 @@ export function PolicyPopup({
312
336
  {createUserConsent.isError && (
313
337
  <p
314
338
  className="consent:text-sm consent:text-red-600"
315
- style={{ fontSize: "1rem", color: "#dc2626", margin: "0.5rem 0 0 0" }}
339
+ style={{ fontSize: "0.875rem", color: "#dc2626", margin: "0.5rem 0 0 0" }}
316
340
  >
317
341
  Đã xảy ra lỗi. Vui lòng thử lại.
318
342
  </p>
@@ -15,6 +15,8 @@ export interface PolicyDocument {
15
15
  effective_date?: string;
16
16
  last_updated?: string;
17
17
  meta_data?: Record<string, unknown>;
18
+ id?: string;
19
+ content?: string;
18
20
  }
19
21
 
20
22
  export interface PolicyPreference {