@gnar-engine/cli 1.0.3 → 1.0.4
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/bootstrap/deploy.localdev.yml +18 -31
- package/bootstrap/secrets.localdev.yml +7 -12
- package/bootstrap/services/user/Dockerfile +1 -1
- package/package.json +1 -1
- package/src/config.js +2 -1
- package/src/dev/dev.service.js +44 -16
- package/src/scaffolder/commands.js +11 -4
- package/src/scaffolder/scaffolder.handler.js +228 -55
- package/templates/service/Dockerfile.hbs +4 -1
- package/templates/service/package.json.hbs +14 -16
- package/templates/service/{app.js.hbs → src/app.js.hbs} +8 -4
- package/templates/service/{commands → src/commands}/{{serviceName}}.handler.js.hbs +1 -2
- package/{bootstrap/services/agent/src/config.js → templates/service/src/mongodb.config.js.hbs} +11 -18
- package/templates/service/{config.js.hbs → src/mysql.config.js.hbs} +6 -0
- package/{bootstrap/services/agent/src/schema/Agent.schema.js → templates/service/src/schema/{{serviceName}}.schema.js.hbs} +3 -3
- package/templates/service/src/services/mongodb.{{serviceName}}.service.js.hbs +70 -0
- package/bootstrap/services/agent/Dockerfile +0 -23
- package/bootstrap/services/agent/notes.md +0 -28
- package/bootstrap/services/agent/package.json +0 -16
- package/bootstrap/services/agent/src/app.js +0 -52
- package/bootstrap/services/agent/src/commands/agent.handler.js +0 -104
- package/bootstrap/services/agent/src/controllers/http.controller.js +0 -44
- package/bootstrap/services/agent/src/controllers/message.controller.js +0 -51
- package/bootstrap/services/agent/src/db/migrations/01-init.js +0 -50
- package/bootstrap/services/agent/src/db/migrations/02-agent-service-init.js +0 -36
- package/bootstrap/services/agent/src/policies/agent.policy.js +0 -13
- package/bootstrap/services/agent/src/services/agent.service.js +0 -259
- package/bootstrap/services/agent/src/services/chatgpt.service.js +0 -46
- package/bootstrap/services/agent/src/services/manifest.service.js +0 -21
- package/bootstrap/services/portal/Dockerfile +0 -23
- package/bootstrap/services/portal/Dockerfile.remote +0 -40
- package/bootstrap/services/portal/README.md +0 -22
- package/bootstrap/services/portal/nginx.conf +0 -12
- package/bootstrap/services/portal/package.json +0 -59
- package/bootstrap/services/portal/public/favicon.ico +0 -0
- package/bootstrap/services/portal/public/gnar-white.png +0 -0
- package/bootstrap/services/portal/public/gnarengine-logo-black.png +0 -0
- package/bootstrap/services/portal/public/index.html +0 -43
- package/bootstrap/services/portal/public/logo192.png +0 -0
- package/bootstrap/services/portal/public/logo512.png +0 -0
- package/bootstrap/services/portal/public/manifest.json +0 -25
- package/bootstrap/services/portal/public/robots.txt +0 -3
- package/bootstrap/services/portal/src/App.js +0 -56
- package/bootstrap/services/portal/src/assets/Logo_Anchord_Black.svg +0 -1
- package/bootstrap/services/portal/src/assets/Logo_Anchord_Black_Green.svg +0 -1
- package/bootstrap/services/portal/src/assets/Logo_Anchord_White_Green.svg +0 -1
- package/bootstrap/services/portal/src/assets/activity.svg +0 -3
- package/bootstrap/services/portal/src/assets/arrow.svg +0 -3
- package/bootstrap/services/portal/src/assets/bin-white.svg +0 -3
- package/bootstrap/services/portal/src/assets/bin.svg +0 -3
- package/bootstrap/services/portal/src/assets/check.svg +0 -3
- package/bootstrap/services/portal/src/assets/chevron.svg +0 -3
- package/bootstrap/services/portal/src/assets/contact.svg +0 -3
- package/bootstrap/services/portal/src/assets/dots-vertical.svg +0 -5
- package/bootstrap/services/portal/src/assets/eye-off.svg +0 -3
- package/bootstrap/services/portal/src/assets/eye.svg +0 -4
- package/bootstrap/services/portal/src/assets/gnar-engine-black.svg +0 -47
- package/bootstrap/services/portal/src/assets/gnar-engine-white.svg +0 -47
- package/bootstrap/services/portal/src/assets/gnar_engine.svg +0 -3
- package/bootstrap/services/portal/src/assets/gnarengine-logo-black.png +0 -0
- package/bootstrap/services/portal/src/assets/home.svg +0 -3
- package/bootstrap/services/portal/src/assets/link.svg +0 -3
- package/bootstrap/services/portal/src/assets/lock.svg +0 -3
- package/bootstrap/services/portal/src/assets/package.svg +0 -4
- package/bootstrap/services/portal/src/assets/raffle.svg +0 -3
- package/bootstrap/services/portal/src/assets/settings.svg +0 -4
- package/bootstrap/services/portal/src/assets/shopping-bag.svg +0 -3
- package/bootstrap/services/portal/src/assets/user-black.svg +0 -3
- package/bootstrap/services/portal/src/assets/user.svg +0 -3
- package/bootstrap/services/portal/src/assets/users.svg +0 -3
- package/bootstrap/services/portal/src/assets/wallet.svg +0 -3
- package/bootstrap/services/portal/src/css/style.css +0 -1007
- package/bootstrap/services/portal/src/data/data.js +0 -70
- package/bootstrap/services/portal/src/features/attributeFormRow/AttributeFormRow.jsx +0 -32
- package/bootstrap/services/portal/src/features/billingShipping/BillingShipping.jsx +0 -160
- package/bootstrap/services/portal/src/features/crud/crudEdit.less +0 -230
- package/bootstrap/services/portal/src/features/crud/crudList.less +0 -134
- package/bootstrap/services/portal/src/features/crud/crudPage.less +0 -31
- package/bootstrap/services/portal/src/features/crudContact/CrudContactList.jsx +0 -108
- package/bootstrap/services/portal/src/features/crudContact/CrudContactSingle.jsx +0 -243
- package/bootstrap/services/portal/src/features/crudOrder/CrudOrderList.jsx +0 -109
- package/bootstrap/services/portal/src/features/crudOrder/CrudOrderSingle.jsx +0 -315
- package/bootstrap/services/portal/src/features/crudProducts/CrudProductList.jsx +0 -104
- package/bootstrap/services/portal/src/features/crudProducts/CrudProductSingle.jsx +0 -388
- package/bootstrap/services/portal/src/features/crudRaffles/CrudRafflesList.jsx +0 -104
- package/bootstrap/services/portal/src/features/crudRaffles/CrudRafflesSingle.jsx +0 -208
- package/bootstrap/services/portal/src/features/crudSubscription/CrudSubscriptionList.jsx +0 -110
- package/bootstrap/services/portal/src/features/crudSubscription/CrudSubscriptionSingle.jsx +0 -261
- package/bootstrap/services/portal/src/features/crudUser/CrudUserList.jsx +0 -107
- package/bootstrap/services/portal/src/features/crudUser/CrudUserSingle.jsx +0 -402
- package/bootstrap/services/portal/src/features/inventoryFormRow/InventoryFormRow.jsx +0 -30
- package/bootstrap/services/portal/src/features/lineItems/LineItems.jsx +0 -113
- package/bootstrap/services/portal/src/features/loginForm/LoginForm.jsx +0 -56
- package/bootstrap/services/portal/src/features/loginForm/loginForm.less +0 -56
- package/bootstrap/services/portal/src/features/notes/Notes.jsx +0 -18
- package/bootstrap/services/portal/src/features/passwordReset/PasswordResetForm.jsx +0 -96
- package/bootstrap/services/portal/src/features/passwordReset/PasswordResetRequestForm.jsx +0 -74
- package/bootstrap/services/portal/src/features/priceFormRow/PriceFormRow.jsx +0 -102
- package/bootstrap/services/portal/src/features/priceFormRow/priceFormRow.less +0 -24
- package/bootstrap/services/portal/src/features/raffleEntriesList/RaffleEntriesList.jsx +0 -99
- package/bootstrap/services/portal/src/features/raffleProductFormRow/RaffleProductFormRow.jsx +0 -46
- package/bootstrap/services/portal/src/features/sidebar/Sidebar.jsx +0 -64
- package/bootstrap/services/portal/src/features/sidebar/sidebar.less +0 -49
- package/bootstrap/services/portal/src/features/skus/Skus.jsx +0 -109
- package/bootstrap/services/portal/src/features/subscriptionSchedule/SubscriptionSchedule.jsx +0 -44
- package/bootstrap/services/portal/src/features/taxonomyFormRow/TaxonomyFormRow.jsx +0 -32
- package/bootstrap/services/portal/src/features/user/User.jsx +0 -54
- package/bootstrap/services/portal/src/features/user/user.less +0 -57
- package/bootstrap/services/portal/src/includes/utilities.js +0 -259
- package/bootstrap/services/portal/src/index.js +0 -14
- package/bootstrap/services/portal/src/layouts/CrudLayout.jsx +0 -50
- package/bootstrap/services/portal/src/layouts/LoginLayout.jsx +0 -17
- package/bootstrap/services/portal/src/layouts/PortalLayout.jsx +0 -48
- package/bootstrap/services/portal/src/layouts/loginLayout.less +0 -33
- package/bootstrap/services/portal/src/layouts/portalLayout.less +0 -67
- package/bootstrap/services/portal/src/pages/contacts/Contacts.jsx +0 -199
- package/bootstrap/services/portal/src/pages/dashboard/Dashboard.jsx +0 -17
- package/bootstrap/services/portal/src/pages/integrations/Integrations.jsx +0 -10
- package/bootstrap/services/portal/src/pages/login/Login.jsx +0 -15
- package/bootstrap/services/portal/src/pages/login/login.less +0 -10
- package/bootstrap/services/portal/src/pages/orders/Orders.jsx +0 -199
- package/bootstrap/services/portal/src/pages/passwordReset/PasswordResetPage.jsx +0 -15
- package/bootstrap/services/portal/src/pages/passwordResetRequest/PasswordResetRequestPage.jsx +0 -15
- package/bootstrap/services/portal/src/pages/payments/Payments.jsx +0 -10
- package/bootstrap/services/portal/src/pages/portal/Portal.jsx +0 -43
- package/bootstrap/services/portal/src/pages/products/Products.jsx +0 -212
- package/bootstrap/services/portal/src/pages/raffleEntries/RaffleEntries.jsx +0 -124
- package/bootstrap/services/portal/src/pages/raffles/Raffles.jsx +0 -186
- package/bootstrap/services/portal/src/pages/reports/Reports.jsx +0 -10
- package/bootstrap/services/portal/src/pages/settings/Settings.jsx +0 -10
- package/bootstrap/services/portal/src/pages/subscriptions/Subscriptions.jsx +0 -199
- package/bootstrap/services/portal/src/pages/users/Users.jsx +0 -193
- package/bootstrap/services/portal/src/pages/users/users.less +0 -25
- package/bootstrap/services/portal/src/slices/authSlice.js +0 -71
- package/bootstrap/services/portal/src/store/configureStore.js +0 -12
- package/bootstrap/services/portal/src/styles/global.less +0 -159
- package/bootstrap/services/portal/src/styles/inputs.less +0 -157
- package/bootstrap/services/portal/src/styles/main.less +0 -26
- package/bootstrap/services/portal/src/ui/collapsible/Collapsible.jsx +0 -97
- package/bootstrap/services/portal/src/ui/collapsible/collapsible.less +0 -23
- package/bootstrap/services/portal/src/ui/customCheckbox/CustomCheckbox.jsx +0 -17
- package/bootstrap/services/portal/src/ui/customCheckbox/customCheckbox.less +0 -42
- package/bootstrap/services/portal/src/ui/customMultiSelect/CustomMultiSelect.jsx +0 -63
- package/bootstrap/services/portal/src/ui/customMultiSelect/CustomMultiSelectPeriod.jsx +0 -63
- package/bootstrap/services/portal/src/ui/customSelect/CustomSelect.jsx +0 -63
- package/bootstrap/services/portal/src/ui/customSelect/customSelect.less +0 -92
- package/bootstrap/services/portal/src/ui/goBack/GoBack.jsx +0 -19
- package/bootstrap/services/portal/src/ui/loader/Loader.jsx +0 -12
- package/bootstrap/services/portal/src/ui/pagination/Pagination.jsx +0 -23
- package/bootstrap/services/portal/src/ui/repeater/Repeater.jsx +0 -29
- package/bootstrap/services/portal/src/ui/saveButton/SaveButton.jsx +0 -69
- package/bootstrap/services/portal/src/ui/saveButton/saveButton.less +0 -0
- package/bootstrap/services/user/src/db/seeders/development/02-portal-admin-user.js +0 -27
- package/templates/service/schema/{{serviceName}}.schema.js.hbs +0 -14
- /package/templates/service/{controllers → src/controllers}/http.controller.js.hbs +0 -0
- /package/templates/service/{controllers → src/controllers}/message.controller.js.hbs +0 -0
- /package/templates/service/{db → src/mysql.db}/migrations/01-init.js.hbs +0 -0
- /package/templates/service/{db → src/mysql.db}/migrations/02-{{lowerCase serviceName}}-service-init.js.hbs +0 -0
- /package/templates/service/{policies → src/policies}/{{serviceName}}.policy.js.hbs +0 -0
- /package/templates/service/{services/{{serviceName}}.service.js.hbs → src/services/mysql.{{serviceName}}.service.js.hbs} +0 -0
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import CrudLayout from "../../layouts/CrudLayout";
|
|
3
|
-
import gnarEngine from "@gnar-engine/js-client";
|
|
4
|
-
import CustomSelect from "../../ui/customSelect/CustomSelect";
|
|
5
|
-
import arrow from '../../assets/arrow.svg';
|
|
6
|
-
import CrudContactSingle from "../../features/crudContact/CrudContactSingle";
|
|
7
|
-
import CrudContactList from "../../features/crudContact/CrudContactList";
|
|
8
|
-
|
|
9
|
-
const Contacts = () => {
|
|
10
|
-
|
|
11
|
-
const [view, setView] = useState(null);
|
|
12
|
-
const [selectedSingleItemId, setSelectedSingleItemId] = useState(null);
|
|
13
|
-
const [selectedContact, setContact] = useState(null);
|
|
14
|
-
const [loading, setLoading] = useState(false);
|
|
15
|
-
const [selectedAction, setSelectedAction] = useState(null);
|
|
16
|
-
const [selectedContactIds, setSelectedContactIds] = useState(new Set());
|
|
17
|
-
const [contacts, setContacts] = useState([]);
|
|
18
|
-
const [message, setMessage] = useState('');
|
|
19
|
-
const [currentPage, setCurrentPage] = useState(1);
|
|
20
|
-
|
|
21
|
-
const fetchContacts = async () => {
|
|
22
|
-
try {
|
|
23
|
-
const data = await gnarEngine.contacts.getMany();
|
|
24
|
-
console.log('data:', data);
|
|
25
|
-
|
|
26
|
-
const contactsList = data.contacts.map(contact => ({
|
|
27
|
-
id: contact._id,
|
|
28
|
-
firstName: contact.firstName,
|
|
29
|
-
lastName: contact.lastName,
|
|
30
|
-
email: contact.email,
|
|
31
|
-
phone: contact.phone,
|
|
32
|
-
dateOfBirth: contact.dateOfBirth,
|
|
33
|
-
createdAt: formatDate(contact.createdAt),
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
setContacts(contactsList);
|
|
37
|
-
setMessage(contactsList.length > 0 ? '' : 'No contacts found');
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error('Error fetching contacts:', error);
|
|
40
|
-
setContacts([]);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
fetchContacts();
|
|
46
|
-
}, []);
|
|
47
|
-
|
|
48
|
-
const formatDate = (isoString) => {
|
|
49
|
-
if (!isoString) return "N/A";
|
|
50
|
-
|
|
51
|
-
const date = new Date(isoString);
|
|
52
|
-
if (isNaN(date.getTime())) return "N/A"; // Checks if the date is invalid
|
|
53
|
-
|
|
54
|
-
return `${date.getFullYear()}/${String(date.getMonth() + 1).padStart(2, '0')}/${String(date.getDate()).padStart(2, '0')} at ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const handleAddNew = () => {
|
|
59
|
-
setView("single");
|
|
60
|
-
setSelectedSingleItemId(null);
|
|
61
|
-
setContact(null);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const refreshSelectedContact = () => {
|
|
65
|
-
if (!selectedSingleItemId) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
(async () => {
|
|
69
|
-
try {
|
|
70
|
-
const data = await gnarEngine.contacts.getContact(selectedSingleItemId);
|
|
71
|
-
setContact(data.contact);
|
|
72
|
-
} catch (error) {
|
|
73
|
-
console.error('Error fetching contact:', error);
|
|
74
|
-
}
|
|
75
|
-
})();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
(async () => {
|
|
80
|
-
if (!selectedSingleItemId) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
// fetch contact data
|
|
85
|
-
const data = await gnarEngine.contacts.getContact(selectedSingleItemId);
|
|
86
|
-
setContact(data.contact);
|
|
87
|
-
|
|
88
|
-
} catch (error) {
|
|
89
|
-
console.error('Error fetching contact:', error);
|
|
90
|
-
}
|
|
91
|
-
})();
|
|
92
|
-
}, [selectedSingleItemId]);
|
|
93
|
-
|
|
94
|
-
const handleAction = () => {
|
|
95
|
-
if (!selectedAction) {
|
|
96
|
-
alert("Please select an action first!");
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (selectedAction.id === "delete") {
|
|
101
|
-
handleDelete();
|
|
102
|
-
} else if (selectedAction.id === "export") {
|
|
103
|
-
console.log("Export action triggered");
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const handleDelete = () => {
|
|
108
|
-
if (selectedContactIds.size === 0) {
|
|
109
|
-
alert("Please select a contact to delete first!");
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (!window.confirm(`Are you sure you want to delete ${selectedContactIds.size} contact(s)?`)) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
(async () => {
|
|
116
|
-
try {
|
|
117
|
-
for (const contactId of selectedContactIds) {
|
|
118
|
-
await gnarEngine.contacts.delete(contactId);
|
|
119
|
-
}
|
|
120
|
-
setSelectedContactIds(new Set());
|
|
121
|
-
setSelectedAction(null);
|
|
122
|
-
await fetchContacts();
|
|
123
|
-
} catch (error) {
|
|
124
|
-
console.error('Error deleting contact:', error);
|
|
125
|
-
}
|
|
126
|
-
})();
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<CrudLayout
|
|
132
|
-
view={view}
|
|
133
|
-
setView={setView}
|
|
134
|
-
selectedSingleItemId={selectedSingleItemId}
|
|
135
|
-
setSelectedSingleItemId={setSelectedSingleItemId}
|
|
136
|
-
>
|
|
137
|
-
<div className="crud-page">
|
|
138
|
-
|
|
139
|
-
{view === "list" ? (
|
|
140
|
-
<div className="crud-list-cont">
|
|
141
|
-
<div className="crud-list-controls">
|
|
142
|
-
<div className="controls-left-col">
|
|
143
|
-
<button onClick={handleAddNew} className="add-new">Add new</button>
|
|
144
|
-
</div>
|
|
145
|
-
<div className="controls-right-col">
|
|
146
|
-
<CustomSelect
|
|
147
|
-
name="filter-contacts"
|
|
148
|
-
placeholder="filter by"
|
|
149
|
-
options={[
|
|
150
|
-
{ id: "all", name: "All" },
|
|
151
|
-
{ id: "admin", name: "Admin" },
|
|
152
|
-
{ id: "contact", name: "User" }
|
|
153
|
-
]}
|
|
154
|
-
labelKey="name"
|
|
155
|
-
setSelectedOption={() => {}}
|
|
156
|
-
selectedOption={null}
|
|
157
|
-
/>
|
|
158
|
-
<CustomSelect
|
|
159
|
-
name="action"
|
|
160
|
-
placeholder="action"
|
|
161
|
-
options={[
|
|
162
|
-
{ id: "delete", name: "Delete" },
|
|
163
|
-
// { id: "export", name: "Export" }
|
|
164
|
-
]}
|
|
165
|
-
labelKey="name"
|
|
166
|
-
setSelectedOption={setSelectedAction}
|
|
167
|
-
selectedOption={selectedAction}
|
|
168
|
-
/>
|
|
169
|
-
<button className="arrowButton" onClick={handleAction}><img src={arrow} alt="right arrow icon" /></button>
|
|
170
|
-
</div>
|
|
171
|
-
</div>
|
|
172
|
-
<CrudContactList
|
|
173
|
-
setSelectedSingleItemId={setSelectedSingleItemId}
|
|
174
|
-
setView={() => setView('single')}
|
|
175
|
-
selectedContactIds={selectedContactIds}
|
|
176
|
-
setSelectedContactIds={setSelectedContactIds}
|
|
177
|
-
contacts={contacts}
|
|
178
|
-
message={message}
|
|
179
|
-
/>
|
|
180
|
-
</div>
|
|
181
|
-
) : (
|
|
182
|
-
<CrudContactSingle
|
|
183
|
-
loading={loading}
|
|
184
|
-
setLoading={setLoading}
|
|
185
|
-
contact={selectedContact}
|
|
186
|
-
setView={() => setView('list')}
|
|
187
|
-
refreshSelectedContact={refreshSelectedContact}
|
|
188
|
-
setContact={setContact}
|
|
189
|
-
fetchContacts={fetchContacts}
|
|
190
|
-
formatDate={formatDate}
|
|
191
|
-
setSelectedSingleItemId={setSelectedSingleItemId}
|
|
192
|
-
/>
|
|
193
|
-
)}
|
|
194
|
-
</div>
|
|
195
|
-
</CrudLayout>
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export default Contacts;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
const Dashboard = () => {
|
|
4
|
-
|
|
5
|
-
return (
|
|
6
|
-
<div className="dashboard">
|
|
7
|
-
<h1>Dashboard</h1>
|
|
8
|
-
|
|
9
|
-
<div className="separator"></div>
|
|
10
|
-
|
|
11
|
-
<p>Please use the relevant links within the side bar to view, update and track your data.</p>
|
|
12
|
-
|
|
13
|
-
</div>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default Dashboard;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import LoginLayout from "../../layouts/LoginLayout";
|
|
3
|
-
import LoginForm from "../../features/loginForm/LoginForm";
|
|
4
|
-
|
|
5
|
-
const LoginPage = () => {
|
|
6
|
-
return (
|
|
7
|
-
<LoginLayout>
|
|
8
|
-
|
|
9
|
-
<LoginForm />
|
|
10
|
-
|
|
11
|
-
</LoginLayout>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default LoginPage;
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import CrudLayout from "../../layouts/CrudLayout";
|
|
3
|
-
import gnarEngine from "@gnar-engine/js-client";
|
|
4
|
-
import CustomSelect from "../../ui/customSelect/CustomSelect";
|
|
5
|
-
import arrow from '../../assets/arrow.svg';
|
|
6
|
-
import CrudOrderList from "../../features/crudOrder/CrudOrderList";
|
|
7
|
-
import CrudOrderSingle from "../../features/crudOrder/CrudOrderSingle";
|
|
8
|
-
|
|
9
|
-
const Orders = () => {
|
|
10
|
-
|
|
11
|
-
const [view, setView] = useState("list");
|
|
12
|
-
const [selectedSingleItemId, setSelectedSingleItemId] = useState(null);
|
|
13
|
-
const [selectedOrder, setOrder] = useState(null);
|
|
14
|
-
const [loading, setLoading] = useState(false);
|
|
15
|
-
const [selectedAction, setSelectedAction] = useState(null);
|
|
16
|
-
const [selectedOrderIds, setSelectedOrderIds] = useState(new Set());
|
|
17
|
-
const [orders, setOrders] = useState([]);
|
|
18
|
-
const [message, setMessage] = useState('');
|
|
19
|
-
const [currentPage, setCurrentPage] = useState(1);
|
|
20
|
-
|
|
21
|
-
const fetchOrders = async () => {
|
|
22
|
-
try {
|
|
23
|
-
const data = await gnarEngine.order.getOrders();
|
|
24
|
-
console.log('data:', data);
|
|
25
|
-
|
|
26
|
-
const ordersList = data.orders.map(order => ({
|
|
27
|
-
id: order._id,
|
|
28
|
-
type: order.type,
|
|
29
|
-
firstName: order.billingAddress.firstName,
|
|
30
|
-
lastName: order.billingAddress.lastName,
|
|
31
|
-
date: new Date(order.createdAt).toLocaleDateString(),
|
|
32
|
-
status: order.status,
|
|
33
|
-
total: '£' + order.total?.toFixed(2),
|
|
34
|
-
createdAt: formatDate(order.createdAt),
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
setOrders(ordersList);
|
|
38
|
-
setMessage(ordersList.length > 0 ? '' : 'No orders found');
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.error('Error fetching orders:', error);
|
|
41
|
-
setOrders([]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
fetchOrders();
|
|
47
|
-
}, []);
|
|
48
|
-
|
|
49
|
-
const formatDate = (isoString) => {
|
|
50
|
-
if (!isoString) return "N/A";
|
|
51
|
-
|
|
52
|
-
const date = new Date(isoString);
|
|
53
|
-
if (isNaN(date.getTime())) return "N/A"; // Checks if the date is invalid
|
|
54
|
-
|
|
55
|
-
return `${date.getFullYear()}/${String(date.getMonth() + 1).padStart(2, '0')}/${String(date.getDate()).padStart(2, '0')} at ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const handleAddNew = () => {
|
|
60
|
-
setView("single");
|
|
61
|
-
setSelectedSingleItemId(null);
|
|
62
|
-
setOrder(null);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const refreshSelectedOrder = () => {
|
|
66
|
-
if (!selectedSingleItemId) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
(async () => {
|
|
70
|
-
try {
|
|
71
|
-
const data = await gnarEngine.order.getOrder(selectedSingleItemId);
|
|
72
|
-
setOrder(data.order);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
console.error('Error fetching orders:', error);
|
|
75
|
-
}
|
|
76
|
-
})();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
(async () => {
|
|
81
|
-
if (!selectedSingleItemId) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
// fetch contact data
|
|
86
|
-
const data = await gnarEngine.order.getOrder(selectedSingleItemId);
|
|
87
|
-
setOrder(data.order);
|
|
88
|
-
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.error('Error fetching order:', error);
|
|
91
|
-
}
|
|
92
|
-
})();
|
|
93
|
-
}, [selectedSingleItemId]);
|
|
94
|
-
|
|
95
|
-
const handleAction = () => {
|
|
96
|
-
if (!selectedAction) {
|
|
97
|
-
alert("Please select an action first!");
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (selectedAction.id === "delete") {
|
|
102
|
-
handleDelete();
|
|
103
|
-
} else if (selectedAction.id === "export") {
|
|
104
|
-
console.log("Export action triggered");
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const handleDelete = () => {
|
|
109
|
-
if (selectedOrderIds.size === 0) {
|
|
110
|
-
alert("Please select an order to delete first!");
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (!window.confirm(`Are you sure you want to delete ${selectedOrderIds.size} order(s)?`)) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
(async () => {
|
|
117
|
-
try {
|
|
118
|
-
for (const orderId of selectedOrderIds) {
|
|
119
|
-
await gnarEngine.order.deleteOrder(orderId);
|
|
120
|
-
}
|
|
121
|
-
setSelectedOrderIds(new Set());
|
|
122
|
-
setSelectedAction(null);
|
|
123
|
-
await fetchOrders();
|
|
124
|
-
} catch (error) {
|
|
125
|
-
console.error('Error deleting order:', error);
|
|
126
|
-
}
|
|
127
|
-
})();
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<CrudLayout
|
|
132
|
-
view={view}
|
|
133
|
-
setView={setView}
|
|
134
|
-
selectedSingleItemId={selectedSingleItemId}
|
|
135
|
-
setSelectedSingleItemId={setSelectedSingleItemId}
|
|
136
|
-
>
|
|
137
|
-
<div className="crud-page">
|
|
138
|
-
|
|
139
|
-
{view === "list" ? (
|
|
140
|
-
<div className="crud-list-cont">
|
|
141
|
-
<div className="crud-list-controls">
|
|
142
|
-
<div className="controls-left-col">
|
|
143
|
-
<button onClick={handleAddNew} className="add-new">Add new</button>
|
|
144
|
-
</div>
|
|
145
|
-
<div className="controls-right-col">
|
|
146
|
-
<CustomSelect
|
|
147
|
-
name="filter-contacts"
|
|
148
|
-
placeholder="filter by"
|
|
149
|
-
options={[
|
|
150
|
-
{ id: "all", name: "All" },
|
|
151
|
-
{ id: "admin", name: "Admin" },
|
|
152
|
-
{ id: "contact", name: "User" }
|
|
153
|
-
]}
|
|
154
|
-
labelKey="name"
|
|
155
|
-
setSelectedOption={() => {}}
|
|
156
|
-
selectedOption={null}
|
|
157
|
-
/>
|
|
158
|
-
<CustomSelect
|
|
159
|
-
name="action"
|
|
160
|
-
placeholder="action"
|
|
161
|
-
options={[
|
|
162
|
-
{ id: "delete", name: "Delete" },
|
|
163
|
-
// { id: "export", name: "Export" }
|
|
164
|
-
]}
|
|
165
|
-
labelKey="name"
|
|
166
|
-
setSelectedOption={setSelectedAction}
|
|
167
|
-
selectedOption={selectedAction}
|
|
168
|
-
/>
|
|
169
|
-
<button className="arrowButton" onClick={handleAction}><img src={arrow} alt="right arrow icon" /></button>
|
|
170
|
-
</div>
|
|
171
|
-
</div>
|
|
172
|
-
<CrudOrderList
|
|
173
|
-
setSelectedSingleItemId={setSelectedSingleItemId}
|
|
174
|
-
setView={() => setView('single')}
|
|
175
|
-
selectedOrderIds={selectedOrderIds}
|
|
176
|
-
setSelectedOrderIds={setSelectedOrderIds}
|
|
177
|
-
orders={orders}
|
|
178
|
-
message={message}
|
|
179
|
-
/>
|
|
180
|
-
</div>
|
|
181
|
-
) : (
|
|
182
|
-
<CrudOrderSingle
|
|
183
|
-
loading={loading}
|
|
184
|
-
setLoading={setLoading}
|
|
185
|
-
order={selectedOrder}
|
|
186
|
-
setView={() => setView('list')}
|
|
187
|
-
refreshSelectedOrder={refreshSelectedOrder}
|
|
188
|
-
setOrder={setOrder}
|
|
189
|
-
fetchOrders={fetchOrders}
|
|
190
|
-
formatDate={formatDate}
|
|
191
|
-
setSelectedSingleItemId={setSelectedSingleItemId}
|
|
192
|
-
/>
|
|
193
|
-
)}
|
|
194
|
-
</div>
|
|
195
|
-
</CrudLayout>
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export default Orders;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import LoginLayout from "../../layouts/LoginLayout";
|
|
3
|
-
import PasswordResetForm from "../../features/passwordReset/PasswordResetForm";
|
|
4
|
-
|
|
5
|
-
const PasswordResetPage = () => {
|
|
6
|
-
return (
|
|
7
|
-
<LoginLayout>
|
|
8
|
-
|
|
9
|
-
<PasswordResetForm />
|
|
10
|
-
|
|
11
|
-
</LoginLayout>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default PasswordResetPage;
|
package/bootstrap/services/portal/src/pages/passwordResetRequest/PasswordResetRequestPage.jsx
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import LoginLayout from "../../layouts/LoginLayout";
|
|
3
|
-
import PasswordResetRequestForm from "../../features/passwordReset/PasswordResetRequestForm";
|
|
4
|
-
|
|
5
|
-
const PasswordResetRequestPage = () => {
|
|
6
|
-
return (
|
|
7
|
-
<LoginLayout>
|
|
8
|
-
|
|
9
|
-
<PasswordResetRequestForm />
|
|
10
|
-
|
|
11
|
-
</LoginLayout>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default PasswordResetRequestPage;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Routes, Route, Outlet } from 'react-router-dom';
|
|
3
|
-
import PortalLayout from "../../layouts/PortalLayout";
|
|
4
|
-
import Dashboard from "../dashboard/Dashboard";
|
|
5
|
-
import Products from "../products/Products";
|
|
6
|
-
import Reports from "../reports/Reports";
|
|
7
|
-
import Orders from "../orders/Orders";
|
|
8
|
-
import Integrations from "../integrations/Integrations";
|
|
9
|
-
import Contacts from "../contacts/Contacts";
|
|
10
|
-
import Payments from "../payments/Payments";
|
|
11
|
-
import Settings from "../settings/Settings";
|
|
12
|
-
import Users from "../users/Users";
|
|
13
|
-
import Subscriptions from "../subscriptions/Subscriptions";
|
|
14
|
-
import RaffleEntries from "../raffleEntries/RaffleEntries";
|
|
15
|
-
import Raffles from "../raffles/Raffles";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const Portal = () => {
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<PortalLayout>
|
|
22
|
-
|
|
23
|
-
<Routes>
|
|
24
|
-
<Route path="/" element={<Dashboard />} />
|
|
25
|
-
<Route path="/products" element={<Products />} />
|
|
26
|
-
<Route path="/orders" element={<Orders />} />
|
|
27
|
-
<Route path="/subscriptions" element={<Subscriptions />} />
|
|
28
|
-
<Route path="/integrations" element={<Integrations />} />
|
|
29
|
-
<Route path="/raffles" element={<Raffles />} />
|
|
30
|
-
<Route path="/raffle-entries" element={<RaffleEntries />} />
|
|
31
|
-
<Route path="/contacts" element={<Contacts />} />
|
|
32
|
-
<Route path="/payments" element={<Payments />} />
|
|
33
|
-
<Route path="/users" element={<Users />} />
|
|
34
|
-
<Route path="/reports" element={<Reports />} />
|
|
35
|
-
<Route path="/settings" element={<Settings />} />
|
|
36
|
-
</Routes>
|
|
37
|
-
|
|
38
|
-
<Outlet />
|
|
39
|
-
</PortalLayout>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default Portal;
|