@namphuongtechnologi/np-hub 0.1.6 → 0.1.7
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/README.md +25 -22
- package/docs/DEVELOPER_GUIDE.md +2 -2
- package/docs/USAGE_STATIC_REACT.md +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,16 +26,18 @@ function initNpHub() {
|
|
|
26
26
|
|
|
27
27
|
document.body.appendChild(widget);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
// Optional khi config — chỉ prefill; form UI vẫn bắt buộc nhập
|
|
30
|
+
// widget.setUser({
|
|
31
|
+
// name: "Nguyen Van A",
|
|
32
|
+
// email: "a@gmail.com",
|
|
33
|
+
// phoneNumber: "0912345678",
|
|
34
|
+
// });
|
|
35
|
+
|
|
36
|
+
// Optional khi config — chỉ prefill nội dung/file
|
|
37
|
+
// widget.setFormPrefill({
|
|
38
|
+
// content: "Mô tả sự cố cần hỗ trợ...",
|
|
39
|
+
// attachments: [],
|
|
40
|
+
// });
|
|
39
41
|
|
|
40
42
|
widget.addEventListener("np-hub-submit-success", function (event) {
|
|
41
43
|
console.log("Tạo yêu cầu thành công:", event.detail);
|
|
@@ -93,15 +95,16 @@ export default function App() {
|
|
|
93
95
|
priority={0}
|
|
94
96
|
coordinators={[]}
|
|
95
97
|
emailContacts={[]}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
// Optional khi config — chỉ prefill; form UI vẫn bắt buộc nhập
|
|
99
|
+
// user={{
|
|
100
|
+
// name: "Nguyen Van A",
|
|
101
|
+
// email: "a@gmail.com",
|
|
102
|
+
// phoneNumber: "0912345678",
|
|
103
|
+
// }}
|
|
104
|
+
// formPrefill={{
|
|
105
|
+
// content: "Mô tả sự cố cần hỗ trợ...",
|
|
106
|
+
// attachments: [],
|
|
107
|
+
// }}
|
|
105
108
|
onSubmitSuccess={(detail) => console.log("Thành công:", detail)}
|
|
106
109
|
onSubmitError={(error) => console.error("Lỗi:", error)}
|
|
107
110
|
/>
|
|
@@ -119,8 +122,8 @@ export default function App() {
|
|
|
119
122
|
| `priority` | Không | Độ ưu tiên (mặc định `0`) |
|
|
120
123
|
| `coordinators` | Không | Danh sách điều phối viên (mảng email) |
|
|
121
124
|
| `emailContacts` | Không | Danh sách email liên hệ nhận bản tin |
|
|
122
|
-
| `user` | Không |
|
|
123
|
-
| `formPrefill` | Không |
|
|
125
|
+
| `user` | Không | Prefill tên/email/SĐT (form vẫn bắt buộc nhập) |
|
|
126
|
+
| `formPrefill` | Không | Prefill nội dung form (`content`, `attachments`) |
|
|
124
127
|
| `width` / `height` | Không | Kích thước nút nổi (mặc định `72px`) |
|
|
125
128
|
| `onSubmitSuccess` | Không | Callback khi gửi thành công |
|
|
126
129
|
| `onSubmitError` | Không | Callback khi gửi lỗi |
|
|
@@ -140,7 +143,7 @@ export default function App() {
|
|
|
140
143
|
| Lỗi | Cách xử lý |
|
|
141
144
|
| ------------------------------------------ | -------------------------------------------------------- |
|
|
142
145
|
| `projectId is required.` | Kiểm tra `project-id` / `projectId` |
|
|
143
|
-
| `user.name/email/phoneNumber is required.` |
|
|
146
|
+
| `user.name/email/phoneNumber is required.` | Form vẫn bắt buộc đủ tên/email/SĐT; prop `user` chỉ prefill (optional) |
|
|
144
147
|
| `Content is required.` | Người dùng cần nhập nội dung trước khi submit |
|
|
145
148
|
| Gọi API thất bại | Kiểm tra `is-dev` / `isDev` nếu đang test môi trường dev |
|
|
146
149
|
|
package/docs/DEVELOPER_GUIDE.md
CHANGED
|
@@ -65,9 +65,9 @@ npm run typecheck
|
|
|
65
65
|
|
|
66
66
|
### Methods
|
|
67
67
|
|
|
68
|
-
- `setUser(user)`: prefill thông tin người gửi
|
|
68
|
+
- `setUser(user)`: prefill thông tin người gửi (optional khi config; form UI vẫn bắt buộc nhập)
|
|
69
69
|
- `setConfig(config)`: cấu hình thông tin dự án (`projectId`, `isDev`, `priority`, `coordinators`, `emailContacts`)
|
|
70
|
-
- `setFormPrefill(data)`: prefill nội dung form (`content`, `attachments`)
|
|
70
|
+
- `setFormPrefill(data)`: prefill nội dung form (`content`, `attachments`) (optional)
|
|
71
71
|
- `open()` / `close()`: điều khiển modal
|
|
72
72
|
|
|
73
73
|
### Attributes
|
|
@@ -22,7 +22,8 @@ npm install @namphuongtechnologi/np-hub
|
|
|
22
22
|
import { SupportWidget } from "@namphuongtechnologi/np-hub/react";
|
|
23
23
|
|
|
24
24
|
// Đặt một lần trong App.tsx / main.tsx / root layout
|
|
25
|
-
|
|
25
|
+
{/* user/formPrefill optional khi config; trên form vẫn bắt buộc nhập */}
|
|
26
|
+
<SupportWidget projectId="NPP" />
|
|
26
27
|
```
|
|
27
28
|
|
|
28
29
|
Xem `README.md` để biết đầy đủ props và callback.
|