medusa-contact-us 0.0.1 → 0.0.2
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 +128 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,9 +20,12 @@ yarn add medusa-contact-us
|
|
|
20
20
|
npm install medusa-contact-us
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
23
25
|
Inside `medusa-config.ts` register the plugin and tailor the options:
|
|
24
26
|
|
|
25
27
|
```ts
|
|
28
|
+
import type { ConfigModule } from "@medusajs/framework/types"
|
|
26
29
|
import {
|
|
27
30
|
defineContactUsPluginOptions,
|
|
28
31
|
ContactRequestModule,
|
|
@@ -32,56 +35,169 @@ const plugins = [
|
|
|
32
35
|
{
|
|
33
36
|
resolve: "medusa-contact-us",
|
|
34
37
|
options: defineContactUsPluginOptions({
|
|
38
|
+
// Form configuration
|
|
35
39
|
form: {
|
|
40
|
+
// Maximum payload size in KB
|
|
36
41
|
max_payload_kb: 128,
|
|
42
|
+
// Additional custom fields beyond the required email field
|
|
37
43
|
additional_fields: [
|
|
38
|
-
{
|
|
44
|
+
{
|
|
45
|
+
key: "subject",
|
|
46
|
+
label: "Subject",
|
|
47
|
+
description: "Brief description of your inquiry",
|
|
48
|
+
type: "text",
|
|
49
|
+
required: true,
|
|
50
|
+
placeholder: "e.g., Order inquiry",
|
|
51
|
+
helper_text: "Please provide a clear subject line",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
key: "message",
|
|
55
|
+
label: "Message",
|
|
56
|
+
description: "Detailed message about your inquiry",
|
|
57
|
+
type: "textarea",
|
|
58
|
+
required: true,
|
|
59
|
+
placeholder: "Please describe your issue or question...",
|
|
60
|
+
},
|
|
39
61
|
{
|
|
40
62
|
key: "priority",
|
|
41
63
|
label: "Priority",
|
|
64
|
+
description: "How urgent is your request?",
|
|
42
65
|
type: "select",
|
|
66
|
+
required: false,
|
|
43
67
|
options: [
|
|
44
68
|
{ value: "low", label: "Low" },
|
|
69
|
+
{ value: "medium", label: "Medium" },
|
|
45
70
|
{ value: "high", label: "High" },
|
|
71
|
+
{ value: "urgent", label: "Urgent" },
|
|
46
72
|
],
|
|
47
73
|
},
|
|
74
|
+
{
|
|
75
|
+
key: "order_number",
|
|
76
|
+
label: "Order Number",
|
|
77
|
+
description: "If this relates to an order, please provide the order number",
|
|
78
|
+
type: "text",
|
|
79
|
+
required: false,
|
|
80
|
+
placeholder: "order_123456",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
key: "phone",
|
|
84
|
+
label: "Phone Number",
|
|
85
|
+
type: "text",
|
|
86
|
+
required: false,
|
|
87
|
+
placeholder: "+1 (555) 123-4567",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
key: "preferred_contact_method",
|
|
91
|
+
label: "Preferred Contact Method",
|
|
92
|
+
type: "select",
|
|
93
|
+
required: false,
|
|
94
|
+
options: [
|
|
95
|
+
{ value: "email", label: "Email" },
|
|
96
|
+
{ value: "phone", label: "Phone" },
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
key: "is_return_request",
|
|
101
|
+
label: "Is this a return request?",
|
|
102
|
+
type: "boolean",
|
|
103
|
+
required: false,
|
|
104
|
+
},
|
|
48
105
|
],
|
|
49
106
|
},
|
|
107
|
+
// Status lifecycle configuration
|
|
108
|
+
statuses: {
|
|
109
|
+
// Initial status when a request is created
|
|
110
|
+
initial: "new",
|
|
111
|
+
// Intermediate statuses (work in progress)
|
|
112
|
+
intermediates: ["in_review", "waiting_for_customer"],
|
|
113
|
+
// Final status (request is complete)
|
|
114
|
+
final: "closed",
|
|
115
|
+
// Allowed status transitions
|
|
116
|
+
transitions: {
|
|
117
|
+
new: ["in_review", "closed"],
|
|
118
|
+
in_review: ["waiting_for_customer", "closed"],
|
|
119
|
+
waiting_for_customer: ["in_review", "closed"],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
// Status options with labels and notification settings
|
|
50
123
|
status_options: [
|
|
51
|
-
{
|
|
52
|
-
|
|
124
|
+
{
|
|
125
|
+
code: "new",
|
|
126
|
+
label: "New",
|
|
127
|
+
description: "Recently submitted requests awaiting review",
|
|
128
|
+
notify_customer: true,
|
|
129
|
+
template: "emails/contact-received.mjml",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
code: "in_review",
|
|
133
|
+
label: "In Review",
|
|
134
|
+
description: "Assigned to an agent and being reviewed",
|
|
135
|
+
notify_customer: false,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
code: "waiting_for_customer",
|
|
139
|
+
label: "Waiting for Customer",
|
|
140
|
+
description: "Awaiting response from customer",
|
|
141
|
+
notify_customer: true,
|
|
142
|
+
template: "emails/contact-waiting.mjml",
|
|
143
|
+
},
|
|
53
144
|
{
|
|
54
145
|
code: "closed",
|
|
55
146
|
label: "Closed",
|
|
147
|
+
description: "Resolved and completed",
|
|
56
148
|
notify_customer: true,
|
|
57
149
|
template: "emails/contact-final.mjml",
|
|
58
150
|
},
|
|
59
151
|
],
|
|
60
|
-
|
|
61
|
-
initial: "new",
|
|
62
|
-
intermediates: ["in_review"],
|
|
63
|
-
final: "closed",
|
|
64
|
-
transitions: {
|
|
65
|
-
new: ["in_review", "closed"],
|
|
66
|
-
in_review: ["closed"],
|
|
67
|
-
},
|
|
68
|
-
},
|
|
152
|
+
// Notification configuration
|
|
69
153
|
notifications: {
|
|
154
|
+
// Send email when a contact request is created
|
|
70
155
|
send_on_create: true,
|
|
156
|
+
// Template for acknowledgement email
|
|
71
157
|
acknowledgement_template: "emails/contact-received.mjml",
|
|
158
|
+
// Send email when request reaches final status
|
|
72
159
|
send_on_final_status: true,
|
|
160
|
+
// Optional: Custom from address
|
|
161
|
+
from_address: "support@yourstore.com",
|
|
162
|
+
// Optional: Reply-to address
|
|
163
|
+
reply_to: "support@yourstore.com",
|
|
73
164
|
},
|
|
165
|
+
// Comments configuration
|
|
74
166
|
comments: {
|
|
167
|
+
// Enable admin comments on contact requests
|
|
75
168
|
enabled: true,
|
|
169
|
+
// Require a note when changing status to final
|
|
76
170
|
require_note_on_final: true,
|
|
77
171
|
},
|
|
78
172
|
}),
|
|
79
173
|
},
|
|
80
174
|
]
|
|
81
175
|
|
|
176
|
+
// Register the ContactRequestModule
|
|
82
177
|
const modules = [ContactRequestModule]
|
|
178
|
+
|
|
179
|
+
export default {
|
|
180
|
+
projectConfig: {
|
|
181
|
+
// Your Medusa project configuration
|
|
182
|
+
// database_url: process.env.DATABASE_URL,
|
|
183
|
+
// ...
|
|
184
|
+
},
|
|
185
|
+
plugins,
|
|
186
|
+
modules,
|
|
187
|
+
} satisfies ConfigModule
|
|
83
188
|
```
|
|
84
189
|
|
|
190
|
+
### Field Types
|
|
191
|
+
|
|
192
|
+
Available field types for `additional_fields`:
|
|
193
|
+
- `text`: Single-line text input
|
|
194
|
+
- `textarea`: Multi-line text input
|
|
195
|
+
- `number`: Numeric input
|
|
196
|
+
- `select`: Dropdown selection (requires `options` array)
|
|
197
|
+
- `multi_select`: Multiple selection (requires `options` array)
|
|
198
|
+
- `boolean`: Checkbox
|
|
199
|
+
- `date`: Date picker
|
|
200
|
+
|
|
85
201
|
### Status lifecycle best practices
|
|
86
202
|
|
|
87
203
|
- Define unique status codes (kebab or snake case) and map them in `status_options`.
|