@syzy/apphost 1.0.14 → 1.0.16
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/App.d.ts +2 -2
- package/dist/App.js +6 -69
- package/dist/AppHostRoutes.js +10 -10
- package/dist/api/mapping-api.js +4 -4
- package/dist/components/Home/Home.js +9 -10
- package/dist/components/Login/Login.js +2 -2
- package/dist/components/Mappings/ComponentMapping/ComponentRoleMapping.js +12 -7
- package/dist/components/Mappings/MappingForm/MappingForm.js +0 -1
- package/dist/components/api/settings-api.d.ts +1 -1
- package/dist/components/api/settings-api.js +0 -2
- package/dist/config/EnvConfig.d.ts +6 -4
- package/dist/config/EnvConfig.js +6 -4
- package/dist/index.css +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/package.json +1 -1
- package/dist/AppHostProvider.d.ts +0 -6
- package/dist/AppHostProvider.js +0 -4
- package/dist/components/NavBar/Sidebar.d.ts +0 -4
- package/dist/components/NavBar/Sidebar.js +0 -56
- package/dist/components/ProfileForm/ProfileForm.d.ts +0 -3
- package/dist/components/ProfileForm/ProfileForm.js +0 -190
- package/dist/components/ProfileForm/ProfileList.d.ts +0 -3
- package/dist/components/ProfileForm/ProfileList.js +0 -33
- package/dist/components/ProfileForm/profileColumns.d.ts +0 -3
- package/dist/components/ProfileForm/profileColumns.js +0 -67
- package/dist/components/ProfileForm/profileSchema.d.ts +0 -52
- package/dist/components/ProfileForm/profileSchema.js +0 -50
- package/dist/components/SettingsPage/SettingsPage.d.ts +0 -3
- package/dist/components/SettingsPage/SettingsPage.js +0 -240
- package/dist/config/amplifyConfig.d.ts +0 -1
- package/dist/config/amplifyConfig.js +0 -45
- package/dist/configureAppHost.d.ts +0 -6
- package/dist/configureAppHost.js +0 -5
- package/dist/hoc/withSyzyAuth.d.ts +0 -2
- package/dist/hoc/withSyzyAuth.js +0 -87
- package/dist/hooks/useCurrentUser.d.ts +0 -3
- package/dist/hooks/useCurrentUser.js +0 -6
- package/dist/hooks/useDispatch.d.ts +0 -3
- package/dist/hooks/useDispatch.js +0 -7
- package/dist/hooks/usePermission.d.ts +0 -1
- package/dist/hooks/usePermission.js +0 -7
- package/dist/services/navigationMenu.d.ts +0 -1
- package/dist/services/navigationMenu.js +0 -9
- package/dist/store/AppAction.d.ts +0 -11
- package/dist/store/AppAction.js +0 -5
- package/dist/store/AppContext.d.ts +0 -3
- package/dist/store/AppContext.js +0 -3
- package/dist/store/AppContextType.d.ts +0 -12
- package/dist/store/AppContextType.js +0 -6
- package/dist/store/AppProvider.d.ts +0 -7
- package/dist/store/AppProvider.js +0 -32
- package/dist/store/HostedInContainerContext.d.ts +0 -5
- package/dist/store/HostedInContainerContext.js +0 -11
- package/dist/store/SesssionReducer.d.ts +0 -4
- package/dist/store/SesssionReducer.js +0 -16
- package/dist/types.d.ts +0 -26
- package/dist/types.js +0 -14
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useEffect, useState } from "react";
|
|
3
|
-
import { transformdToPrefixDescription, useGetSettingsByPk, useUpdateSettingsMutation } from "../api/settings-api";
|
|
4
|
-
import { Button, Card, Col, Container, Form, Modal, Row } from "react-bootstrap";
|
|
5
|
-
import { toast } from "react-toastify";
|
|
6
|
-
import { BsPencilSquare, BsCheckCircle, BsXCircle, BsInfoCircle } from "react-icons/bs";
|
|
7
|
-
import './SettingsPage.css';
|
|
8
|
-
import { ALL, BOOKING_RECEIPT_PREFIX_FORMAT, BOOKING_RECEIPT_RESETTING_PERIOD, BOOKING_RECEIPT_SEQUENCE_PADDING, BOOKING_RECEIPT_SERIES_NUMBER, HIDE_SIGN_UP, INVOICE_PREFIX_FORMAT, INVOICE_RESETTING_PERIOD, INVOICE_SEQUENCE_PADDING, INVOICE_SERIES_NUMBER, NEVER, PURCHASE_ORDER_PREFIX_FORMAT, PURCHASE_ORDER_RESETTING_PERIOD, PURCHASE_ORDER_SEQUENCE_PADDING, RESERVATION_PREFIX_FORMAT, RESERVATION_RESETTING_PERIOD, RESERVATION_SEQUENCE_PADDING } from "../../static/constants";
|
|
9
|
-
import Select from "react-select";
|
|
10
|
-
import { ResettingPeriodOptions } from "../../domain/type/ResettingPeriodOptions";
|
|
11
|
-
import { initPrefixDescription } from "../../domain/model/PrefixDescriptionDto";
|
|
12
|
-
import { resettingOptions, validateFirstOccurance, validateFullWrapper } from "../../util/prefixAndResettingValidation";
|
|
13
|
-
import { logger } from "../../util/Logger";
|
|
14
|
-
import AppContext from "../../store/AppContext";
|
|
15
|
-
import { sighUpOptions } from "../../domain/type/signUpOptions";
|
|
16
|
-
import { Roles } from "../../domain/type/RolesEnum";
|
|
17
|
-
const SettingsPage = () => {
|
|
18
|
-
const { user } = useContext(AppContext) ?? { user: undefined };
|
|
19
|
-
const rawBranch = user?.branchId ?? "";
|
|
20
|
-
const parts = rawBranch.split("#");
|
|
21
|
-
const branchId = parts[1];
|
|
22
|
-
const userRoles = user?.roles ?? [];
|
|
23
|
-
const { settingsByPK } = useGetSettingsByPk(branchId);
|
|
24
|
-
const updateSettingsMutation = useUpdateSettingsMutation();
|
|
25
|
-
const [editStates, setEditStates] = useState({});
|
|
26
|
-
const [activeEditKey, setActiveEditKey] = useState(null);
|
|
27
|
-
const defaultInvResettingPeriodOption = ResettingPeriodOptions.find(option => option.value === "");
|
|
28
|
-
const [selectedInvResettingPeriod, setSelectedInvResettingPeriod] = useState(defaultInvResettingPeriodOption);
|
|
29
|
-
const defaultPurchaseOrderResetPeriodOption = ResettingPeriodOptions.find(option => option.value === "");
|
|
30
|
-
const [selectedPurchaseOrderResettingPeriod, setSelectedPurchaseOrdResettingPeriod] = useState(defaultPurchaseOrderResetPeriodOption);
|
|
31
|
-
const defaultReservationResetPeriodOption = ResettingPeriodOptions.find(option => option.value === "");
|
|
32
|
-
const [selectedReservationResettingPeriod, setSelectedReservationResettingPeriod] = useState(defaultReservationResetPeriodOption);
|
|
33
|
-
const defaultBookingReceiptResetPeriodOption = ResettingPeriodOptions.find(option => option.value === "");
|
|
34
|
-
const [selectedBookingReceiptResettingPeriod, setSelectedBookingReceiptResettingPeriod] = useState(defaultBookingReceiptResetPeriodOption);
|
|
35
|
-
const [showPrefixInfo, setShowPrefixInfo] = useState(false);
|
|
36
|
-
const [prefixDescription, setPrefixDescription] = useState(initPrefixDescription);
|
|
37
|
-
const defaultSignUpOption = sighUpOptions.find(option => option.value === "");
|
|
38
|
-
const [selectedSignUpOption, setSelectedSighUpOPtion] = useState(defaultSignUpOption);
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (settingsByPK && settingsByPK.length > 0) {
|
|
41
|
-
const invResetPeriod = settingsByPK.find((setting) => setting.sk === INVOICE_RESETTING_PERIOD);
|
|
42
|
-
const purchaseOrdResetPeriod = settingsByPK.find((setting) => setting.sk === PURCHASE_ORDER_RESETTING_PERIOD);
|
|
43
|
-
const reservationResetPeriod = settingsByPK.find((setting) => setting.sk === RESERVATION_RESETTING_PERIOD);
|
|
44
|
-
const bookingReceiptResetPeriod = settingsByPK.find((setting) => setting.sk === BOOKING_RECEIPT_RESETTING_PERIOD);
|
|
45
|
-
const hideSignUp = settingsByPK.find((setting) => setting.sk === HIDE_SIGN_UP);
|
|
46
|
-
setSelectedInvResettingPeriod({ label: invResetPeriod?.value ?? '', value: invResetPeriod?.sk ?? '' });
|
|
47
|
-
setSelectedPurchaseOrdResettingPeriod({ label: purchaseOrdResetPeriod?.value ?? '', value: purchaseOrdResetPeriod?.sk ?? '' });
|
|
48
|
-
setSelectedReservationResettingPeriod({ label: reservationResetPeriod?.value ?? '', value: reservationResetPeriod?.sk ?? '' });
|
|
49
|
-
setSelectedBookingReceiptResettingPeriod({ label: bookingReceiptResetPeriod?.value ?? '', value: bookingReceiptResetPeriod?.sk ?? '' });
|
|
50
|
-
setSelectedSighUpOPtion({ label: hideSignUp?.value ?? '', value: hideSignUp?.sk ?? '' });
|
|
51
|
-
}
|
|
52
|
-
}, [settingsByPK]);
|
|
53
|
-
const handleEdit = (sk, currentValue) => {
|
|
54
|
-
setActiveEditKey(sk);
|
|
55
|
-
setEditStates((prev) => ({
|
|
56
|
-
...prev,
|
|
57
|
-
[sk]: { isEditing: true, value: currentValue }
|
|
58
|
-
}));
|
|
59
|
-
};
|
|
60
|
-
const handleCancel = (sk) => {
|
|
61
|
-
setActiveEditKey(null);
|
|
62
|
-
setEditStates((prev) => ({
|
|
63
|
-
...prev,
|
|
64
|
-
[sk]: { isEditing: false, value: prev[sk]?.value || "" },
|
|
65
|
-
}));
|
|
66
|
-
};
|
|
67
|
-
const handleChange = (sk, newValue) => {
|
|
68
|
-
setEditStates((prev) => ({ ...prev, [sk]: { ...prev[sk], value: newValue }, }));
|
|
69
|
-
};
|
|
70
|
-
const handleResettingPeriodChange = (sk, selectedOption) => {
|
|
71
|
-
if (selectedOption) {
|
|
72
|
-
const selectedVal = selectedOption.value;
|
|
73
|
-
setEditStates((prev) => ({ ...prev, [sk]: { ...prev[sk], value: selectedVal }, }));
|
|
74
|
-
if (sk === INVOICE_RESETTING_PERIOD) {
|
|
75
|
-
setSelectedInvResettingPeriod({ label: selectedVal, value: sk ?? '' });
|
|
76
|
-
}
|
|
77
|
-
else if (sk === PURCHASE_ORDER_RESETTING_PERIOD) {
|
|
78
|
-
setSelectedPurchaseOrdResettingPeriod({ label: selectedVal, value: sk ?? '' });
|
|
79
|
-
}
|
|
80
|
-
else if (sk === RESERVATION_RESETTING_PERIOD) {
|
|
81
|
-
setSelectedReservationResettingPeriod({ label: selectedVal, value: sk ?? '' });
|
|
82
|
-
}
|
|
83
|
-
else if (sk === BOOKING_RECEIPT_RESETTING_PERIOD) {
|
|
84
|
-
setSelectedBookingReceiptResettingPeriod({ label: selectedVal, value: sk ?? '' });
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const upsertSettingsMutationFn = (settingsData) => {
|
|
89
|
-
try {
|
|
90
|
-
return new Promise((resolve, reject) => {
|
|
91
|
-
updateSettingsMutation.mutate(settingsData, {
|
|
92
|
-
onSuccess: (_res) => {
|
|
93
|
-
toast.success("Settings update successfully!");
|
|
94
|
-
resolve();
|
|
95
|
-
},
|
|
96
|
-
onError: (err) => {
|
|
97
|
-
toast.error("Error while request the Product");
|
|
98
|
-
reject(err);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
catch (err) {
|
|
104
|
-
logger.error("error at product request updation", err);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
const validatePrefixResetting = (prefixSk, resetSk) => {
|
|
108
|
-
const prefix = editStates[prefixSk]?.value ||
|
|
109
|
-
settingsByPK?.find(s => s.sk === prefixSk)?.value || "";
|
|
110
|
-
const resettingPeriod = editStates[resetSk]?.value ||
|
|
111
|
-
settingsByPK?.find(s => s.sk === resetSk)?.value || "";
|
|
112
|
-
const allowedPrefix = /^[a-zA-Z]+$/.test(prefix);
|
|
113
|
-
if (allowedPrefix) {
|
|
114
|
-
return true; // bypass resetting validation for custom prefixes
|
|
115
|
-
}
|
|
116
|
-
const allowedPeriods = getAllowedResettingPeriods(prefix).map(opt => opt.value);
|
|
117
|
-
if (!allowedPeriods.includes(resettingPeriod)) {
|
|
118
|
-
toast.info("Resetting period is not suitable for prefix format. Please select other resetting options before updating prefix.");
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
return true;
|
|
122
|
-
};
|
|
123
|
-
const handleUpdate = (settingData) => {
|
|
124
|
-
const newValue = editStates[settingData.sk]?.value;
|
|
125
|
-
// ✅ Series number validation (must be greater than existing)
|
|
126
|
-
if (settingData.sk === INVOICE_SERIES_NUMBER ||
|
|
127
|
-
settingData.sk === BOOKING_RECEIPT_SERIES_NUMBER) {
|
|
128
|
-
const existingValue = Number(settingData.value);
|
|
129
|
-
const enteredValue = Number(newValue);
|
|
130
|
-
if (isNaN(enteredValue)) {
|
|
131
|
-
toast.error("Please enter a valid number.");
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
if (enteredValue <= existingValue) {
|
|
135
|
-
toast.error(`New series number must be greater than existing value (${existingValue}).`);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
const allowedPrefix = (settingData.sk === INVOICE_PREFIX_FORMAT || settingData.sk === BOOKING_RECEIPT_PREFIX_FORMAT) && /^[a-zA-Z]+$/.test(newValue);
|
|
140
|
-
// check allowed predefined constant usage -----
|
|
141
|
-
if (settingData.sk === INVOICE_PREFIX_FORMAT || settingData.sk === PURCHASE_ORDER_PREFIX_FORMAT || settingData.sk === RESERVATION_PREFIX_FORMAT || settingData.sk === BOOKING_RECEIPT_PREFIX_FORMAT) {
|
|
142
|
-
const invalidWrapper = validateFullWrapper(newValue);
|
|
143
|
-
if (invalidWrapper && !allowedPrefix) {
|
|
144
|
-
toast.info("Predefined constants only allowed. Please check the prefix format.");
|
|
145
|
-
return; // stop update
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// first occurance check-------------
|
|
149
|
-
if (settingData.sk === INVOICE_PREFIX_FORMAT || settingData.sk === PURCHASE_ORDER_PREFIX_FORMAT || settingData.sk === RESERVATION_PREFIX_FORMAT || settingData.sk === BOOKING_RECEIPT_PREFIX_FORMAT) {
|
|
150
|
-
const { firstWrapper, validTokens } = validateFirstOccurance(newValue);
|
|
151
|
-
if (!allowedPrefix) {
|
|
152
|
-
if (!firstWrapper || !validTokens.includes(firstWrapper)) {
|
|
153
|
-
toast.info("Predefined constant must start with {FY}, {fy}, {Y}, {y}, {M}, or {D}.");
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// check prefix and resetting combination ----------
|
|
159
|
-
if (settingData.sk === INVOICE_PREFIX_FORMAT || settingData.sk === INVOICE_RESETTING_PERIOD) {
|
|
160
|
-
if (!validatePrefixResetting(INVOICE_PREFIX_FORMAT, INVOICE_RESETTING_PERIOD))
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
if (settingData.sk === PURCHASE_ORDER_PREFIX_FORMAT || settingData.sk === PURCHASE_ORDER_RESETTING_PERIOD) {
|
|
164
|
-
if (!validatePrefixResetting(PURCHASE_ORDER_PREFIX_FORMAT, PURCHASE_ORDER_RESETTING_PERIOD))
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
if (settingData.sk === RESERVATION_PREFIX_FORMAT || settingData.sk === RESERVATION_RESETTING_PERIOD) {
|
|
168
|
-
if (!validatePrefixResetting(RESERVATION_PREFIX_FORMAT, RESERVATION_RESETTING_PERIOD))
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
if (settingData.sk === BOOKING_RECEIPT_PREFIX_FORMAT || settingData.sk === BOOKING_RECEIPT_RESETTING_PERIOD) {
|
|
172
|
-
if (!validatePrefixResetting(BOOKING_RECEIPT_PREFIX_FORMAT, BOOKING_RECEIPT_RESETTING_PERIOD))
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
setActiveEditKey(null);
|
|
176
|
-
setEditStates((prev) => ({
|
|
177
|
-
...prev,
|
|
178
|
-
[settingData.sk]: { isEditing: false, value: newValue || "" }
|
|
179
|
-
}));
|
|
180
|
-
settingData.value = newValue;
|
|
181
|
-
// don't change pk for sign up option if super admin
|
|
182
|
-
settingData.pk = (settingData.pk === ALL && settingData.sk === HIDE_SIGN_UP && userRoles.includes(Roles.SuperAdmin)) ? settingData.pk : branchId;
|
|
183
|
-
upsertSettingsMutationFn(settingData);
|
|
184
|
-
};
|
|
185
|
-
const getAllowedResettingPeriods = (prefix) => {
|
|
186
|
-
if (!prefix) {
|
|
187
|
-
return ResettingPeriodOptions.filter(opt => opt.value === NEVER);
|
|
188
|
-
}
|
|
189
|
-
const firstMatch = resettingOptions(prefix);
|
|
190
|
-
if (firstMatch) {
|
|
191
|
-
return ResettingPeriodOptions.filter(opt => firstMatch.periods.includes(opt.value));
|
|
192
|
-
}
|
|
193
|
-
// NONE prefix → only NEVER
|
|
194
|
-
return ResettingPeriodOptions.filter(opt => opt.value === NEVER);
|
|
195
|
-
};
|
|
196
|
-
const handleSignUpOptionChange = (sk, selectedOption) => {
|
|
197
|
-
if (selectedOption) {
|
|
198
|
-
const selectedVal = selectedOption.value;
|
|
199
|
-
setEditStates((prev) => ({ ...prev, [sk]: { ...prev[sk], value: selectedVal }, }));
|
|
200
|
-
setSelectedSighUpOPtion({ label: selectedVal, value: sk ?? '' });
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
return (_jsxs(Container, { className: "mt-4", children: [settingsByPK && settingsByPK.length > 0 && (_jsxs(Card, { className: "shadow-lg settings-card", children: [_jsx(Card.Header, { className: "fw-bold", children: "Settings" }), _jsx(Card.Body, { children: settingsByPK.map((setting) => {
|
|
204
|
-
const editState = editStates[setting.sk] || { isEditing: false, value: setting.value };
|
|
205
|
-
const isActive = activeEditKey === setting.sk;
|
|
206
|
-
return (_jsxs(Row, { className: "align-items-center mb-3", children: [_jsxs(Col, { xs: 3, sm: 3, md: 3, lg: 5, xl: 5, className: "fw-bold settings-key-col", children: [setting.pk === ALL && setting.sk === HIDE_SIGN_UP && !userRoles.includes(Roles.SuperAdmin) ? "" : setting.sk, (setting.sk === INVOICE_PREFIX_FORMAT || setting.sk === PURCHASE_ORDER_PREFIX_FORMAT || setting.sk === RESERVATION_PREFIX_FORMAT || setting.sk === BOOKING_RECEIPT_PREFIX_FORMAT) && (_jsx(Button, { size: "sm", variant: "link", className: "ms-2 p-0 text-info mb-1", onClick: () => {
|
|
207
|
-
setShowPrefixInfo(true);
|
|
208
|
-
setPrefixDescription(transformdToPrefixDescription(setting.description));
|
|
209
|
-
}, children: _jsx(BsInfoCircle, { className: "info-icon" }) }))] }), _jsx(Col, { xs: 3, sm: 3, md: 5, lg: 5, xl: 5, className: "settings-value-col", children: !isActive ? (_jsx("span", { children: setting.pk === ALL && setting.sk === HIDE_SIGN_UP && !userRoles.includes(Roles.SuperAdmin) ? "" : setting.value })) : (_jsxs(_Fragment, { children: [(setting.sk === INVOICE_RESETTING_PERIOD || setting.sk === PURCHASE_ORDER_RESETTING_PERIOD || setting.sk === RESERVATION_RESETTING_PERIOD || setting.sk === BOOKING_RECEIPT_RESETTING_PERIOD) ?
|
|
210
|
-
_jsx(Select, { options: getAllowedResettingPeriods(setting.sk === INVOICE_RESETTING_PERIOD
|
|
211
|
-
? settingsByPK.find(s => s.sk === INVOICE_PREFIX_FORMAT)?.value ?? ""
|
|
212
|
-
: setting.sk === PURCHASE_ORDER_RESETTING_PERIOD
|
|
213
|
-
? settingsByPK.find(s => s.sk === PURCHASE_ORDER_PREFIX_FORMAT)?.value ?? ""
|
|
214
|
-
: setting.sk === RESERVATION_RESETTING_PERIOD
|
|
215
|
-
? settingsByPK.find(s => s.sk === RESERVATION_PREFIX_FORMAT)?.value ?? ""
|
|
216
|
-
: settingsByPK.find(s => s.sk === BOOKING_RECEIPT_PREFIX_FORMAT)?.value ?? ""), value: setting.sk === INVOICE_RESETTING_PERIOD
|
|
217
|
-
? selectedInvResettingPeriod
|
|
218
|
-
: setting.sk === PURCHASE_ORDER_RESETTING_PERIOD
|
|
219
|
-
? selectedPurchaseOrderResettingPeriod
|
|
220
|
-
: setting.sk === RESERVATION_RESETTING_PERIOD
|
|
221
|
-
? selectedReservationResettingPeriod
|
|
222
|
-
: selectedBookingReceiptResettingPeriod, onChange: (selectedOption) => selectedOption && handleResettingPeriodChange(setting.sk, selectedOption), placeholder: "Select resetting period", className: "resetting-period-select", maxMenuHeight: 200 }) : (setting.pk === ALL && setting.sk === HIDE_SIGN_UP && userRoles.includes(Roles.SuperAdmin)) ?
|
|
223
|
-
_jsx(Select, { options: sighUpOptions, value: selectedSignUpOption, onChange: (selectedOption) => selectedOption && handleSignUpOptionChange(setting.sk, selectedOption), placeholder: "Select Sign up option", className: "resetting-period-select", maxMenuHeight: 200 }) :
|
|
224
|
-
(setting.sk === INVOICE_PREFIX_FORMAT ||
|
|
225
|
-
setting.sk === PURCHASE_ORDER_PREFIX_FORMAT ||
|
|
226
|
-
setting.sk === RESERVATION_PREFIX_FORMAT ||
|
|
227
|
-
setting.sk === BOOKING_RECEIPT_PREFIX_FORMAT ||
|
|
228
|
-
setting.sk === INVOICE_SEQUENCE_PADDING ||
|
|
229
|
-
setting.sk === PURCHASE_ORDER_SEQUENCE_PADDING ||
|
|
230
|
-
setting.sk === RESERVATION_SEQUENCE_PADDING ||
|
|
231
|
-
setting.sk === BOOKING_RECEIPT_SEQUENCE_PADDING ||
|
|
232
|
-
setting.sk === INVOICE_SERIES_NUMBER ||
|
|
233
|
-
setting.sk === BOOKING_RECEIPT_SERIES_NUMBER) ?
|
|
234
|
-
_jsx(Form.Control, { type: (setting.sk === INVOICE_SEQUENCE_PADDING || setting.sk === PURCHASE_ORDER_SEQUENCE_PADDING || setting.sk === RESERVATION_SEQUENCE_PADDING || setting.sk === BOOKING_RECEIPT_SEQUENCE_PADDING) ? 'number' : 'text', value: editState.value, onChange: (e) => handleChange(setting.sk, e.target.value), className: "settings-value-form-control" })
|
|
235
|
-
: null, ((setting.sk === INVOICE_SEQUENCE_PADDING) || (setting.sk === PURCHASE_ORDER_SEQUENCE_PADDING) || (setting.sk === RESERVATION_SEQUENCE_PADDING) || (setting.sk === BOOKING_RECEIPT_SEQUENCE_PADDING)) &&
|
|
236
|
-
_jsx("label", { className: "seq-pad-info text-primary", children: setting.description })] })) }), setting.pk === ALL && setting.sk === HIDE_SIGN_UP && !userRoles.includes(Roles.SuperAdmin) ? null :
|
|
237
|
-
_jsx(Col, { xs: 3, sm: 3, md: 4, lg: 5, xl: 5, className: "text-end settings-btns", children: !isActive ? (_jsx(Button, { size: "sm", variant: "outline-primary", className: "edit-btn", onClick: () => handleEdit(setting.sk, setting.value), children: _jsx(BsPencilSquare, {}) })) : (_jsxs(_Fragment, { children: [_jsx(Button, { size: "sm", variant: "success", className: "me-2 update-btn", onClick: () => handleUpdate(setting), children: _jsx(BsCheckCircle, {}) }), _jsx(Button, { size: "sm", variant: "secondary", className: "cancel-btn", onClick: () => handleCancel(setting.sk), children: _jsx(BsXCircle, {}) })] })) })] }, setting.sk));
|
|
238
|
-
}) })] })), _jsxs(Modal, { show: showPrefixInfo, onHide: () => setShowPrefixInfo(false), size: "lg", centered: true, children: [_jsx(Modal.Header, { closeButton: true, children: _jsx(Modal.Title, { children: "Prefix Format Info" }) }), _jsxs(Modal.Body, { children: [_jsx("p", { className: "fw-bold", children: prefixDescription.message }), prefixDescription.constants.map((constant, index) => (_jsxs("p", { children: [constant.constant, " - ", constant.description] }, index))), _jsx("b", { className: "text-success", children: "Example:" }), _jsxs("p", { children: [_jsx("strong", { children: "Prefix:" }), " ", prefixDescription.example.prefixFormat] }), _jsxs("p", { children: [_jsx("strong", { children: "Result:" }), " ", prefixDescription.example.outputValue] })] }), _jsx(Modal.Footer, { children: _jsx(Button, { variant: "secondary", onClick: () => setShowPrefixInfo(false), children: "Close" }) })] })] }));
|
|
239
|
-
};
|
|
240
|
-
export default SettingsPage;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function configureAmplify(): void;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Amplify } from 'aws-amplify';
|
|
2
|
-
import { EnvConfig } from './EnvConfig';
|
|
3
|
-
import { VITE_API_AUTHMODE } from "../static/constants";
|
|
4
|
-
// Optional global marker for debugging
|
|
5
|
-
const AMPLIFY_INIT_FLAG = '__AMPLIFY_INITIALIZED__';
|
|
6
|
-
export function configureAmplify() {
|
|
7
|
-
const apiConfig = {
|
|
8
|
-
GraphQL: {
|
|
9
|
-
endpoint: EnvConfig.appHostAPi,
|
|
10
|
-
region: EnvConfig.region,
|
|
11
|
-
defaultAuthMode: VITE_API_AUTHMODE,
|
|
12
|
-
apiKey: EnvConfig.apiKey,
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
const authConfig = {
|
|
16
|
-
Cognito: {
|
|
17
|
-
allowGuestAccess: true,
|
|
18
|
-
userPoolId: EnvConfig.userPoolId,
|
|
19
|
-
userPoolClientId: EnvConfig.userPoolClientId,
|
|
20
|
-
identityPoolId: EnvConfig.identityPoolId,
|
|
21
|
-
signUpVerificationMethod: 'code',
|
|
22
|
-
loginWith: { email: true },
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
const storageConfig = {
|
|
26
|
-
S3: {
|
|
27
|
-
bucket: EnvConfig.storage,
|
|
28
|
-
region: EnvConfig.region,
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
// 1️⃣ If running inside a host, do nothing — assume host already configured Amplify
|
|
32
|
-
if (window.hosted_in_container === true) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
// 2️⃣ If already initialized (e.g. hot reload), skip
|
|
36
|
-
if (window[AMPLIFY_INIT_FLAG]) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
Amplify.configure({
|
|
40
|
-
API: apiConfig,
|
|
41
|
-
Auth: authConfig,
|
|
42
|
-
Storage: storageConfig,
|
|
43
|
-
});
|
|
44
|
-
window[AMPLIFY_INIT_FLAG] = true;
|
|
45
|
-
}
|
package/dist/configureAppHost.js
DELETED
package/dist/hoc/withSyzyAuth.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useEffect, useState } from "react";
|
|
3
|
-
import AppContext from "../store/AppContext";
|
|
4
|
-
import LoginForm from "../components/Login/Login";
|
|
5
|
-
import { getCurrentUser } from "aws-amplify/auth";
|
|
6
|
-
import { AppActionEnum } from "../store/AppAction";
|
|
7
|
-
import './withSyzyAuth.css';
|
|
8
|
-
import { Client } from "../services/Client.Service";
|
|
9
|
-
import { fetchAuthSession } from 'aws-amplify/auth';
|
|
10
|
-
import { getComponentsByRoleOnly, getRolesMappingByUserIdAndEntityFun, useGetUserMappingByUserId } from "../api/mapping-api";
|
|
11
|
-
import { EntityTypes } from "../domain/type/EntityTypes";
|
|
12
|
-
import { Status } from "../domain/type/StatusEnum";
|
|
13
|
-
export function withSyzyAuth(WrappedComponent) {
|
|
14
|
-
const ComponentWithAuthenticator = (props) => {
|
|
15
|
-
const [currentUser, setCurrentUser] = useState();
|
|
16
|
-
const { user, dispatch } = useContext(AppContext) || { user: undefined, allowedComponents: undefined, dispatch: undefined };
|
|
17
|
-
const [_isLoggedIn, setIsLoggedIn] = useState(false);
|
|
18
|
-
const [_emailVerifiedStatus, setEmailVerifiedStatus] = useState("");
|
|
19
|
-
const [isSessionReady, setIsSessionReady] = useState(false);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (!user?.userName) {
|
|
22
|
-
setCurrentUser(null);
|
|
23
|
-
setIsSessionReady(false);
|
|
24
|
-
}
|
|
25
|
-
}, [user]);
|
|
26
|
-
const fetchSession = async () => {
|
|
27
|
-
try {
|
|
28
|
-
const session = await getCurrentUser();
|
|
29
|
-
const userInfo = await fetchAuthSession({ forceRefresh: true });
|
|
30
|
-
setEmailVerifiedStatus(userInfo.tokens?.idToken?.payload.email_verified?.toString() ?? "");
|
|
31
|
-
if (session) {
|
|
32
|
-
const userId = session.signInDetails?.loginId ?? session.username;
|
|
33
|
-
setCurrentUser(userId);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
setCurrentUser(null);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
setCurrentUser(null);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
fetchSession();
|
|
45
|
-
}, []);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
const stopResetScheduler = Client.startClientResetScheduler();
|
|
48
|
-
return () => stopResetScheduler();
|
|
49
|
-
}, []);
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
setIsLoggedIn(!!user?.userName);
|
|
52
|
-
}, [user]);
|
|
53
|
-
const { userMappingByUserId } = useGetUserMappingByUserId(currentUser ?? "");
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
const updateSession = async () => {
|
|
56
|
-
if (!currentUser)
|
|
57
|
-
return;
|
|
58
|
-
const branchId = userMappingByUserId?.pk ?? "";
|
|
59
|
-
// Fetch roles of this user
|
|
60
|
-
const roleData = await getRolesMappingByUserIdAndEntityFun(branchId, currentUser, EntityTypes.ROLE);
|
|
61
|
-
const activeRoles = roleData.filter(r => r.status === Status.Active);
|
|
62
|
-
const roleNames = activeRoles.map(r => r.roleName);
|
|
63
|
-
// Fetch components for each active role
|
|
64
|
-
const compData = await Promise.all(activeRoles.map(role => getComponentsByRoleOnly(role.roleId)));
|
|
65
|
-
const allowedComponents = compData.flat().map(c => c.componentTitle);
|
|
66
|
-
// Build and dispatch user session
|
|
67
|
-
const userSession = {
|
|
68
|
-
userName: currentUser,
|
|
69
|
-
branchId,
|
|
70
|
-
roles: roleNames,
|
|
71
|
-
allowedComponents: [...new Set(allowedComponents)],
|
|
72
|
-
};
|
|
73
|
-
dispatch?.({ session: userSession, type: AppActionEnum.SignIn });
|
|
74
|
-
setIsSessionReady(true);
|
|
75
|
-
};
|
|
76
|
-
updateSession();
|
|
77
|
-
}, [currentUser, userMappingByUserId]);
|
|
78
|
-
// Login handler
|
|
79
|
-
const login = (loggedIn) => {
|
|
80
|
-
setIsLoggedIn(loggedIn);
|
|
81
|
-
if (loggedIn)
|
|
82
|
-
fetchSession();
|
|
83
|
-
};
|
|
84
|
-
return (_jsx("div", { children: currentUser === null ? _jsx(LoginForm, { login: login }) : _jsx(WrappedComponent, { ...props, isSessionReady: isSessionReady }) }));
|
|
85
|
-
};
|
|
86
|
-
return ComponentWithAuthenticator;
|
|
87
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import AppContext from "../store/AppContext";
|
|
3
|
-
import { defaultSession } from "../store/AppContextType";
|
|
4
|
-
export const useDispatch = () => {
|
|
5
|
-
const { dispatch } = useContext(AppContext) || { user: defaultSession };
|
|
6
|
-
return { dispatch };
|
|
7
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function AmIPermitted(componentName: string): boolean;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// hooks/usePermissions.ts
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import AppContext from "../store/AppContext";
|
|
4
|
-
export function AmIPermitted(componentName) {
|
|
5
|
-
const { user } = useContext(AppContext) || {};
|
|
6
|
-
return user?.allowedComponents?.includes(componentName) ?? false;
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getSidebarMenu: () => Promise<unknown>;
|
package/dist/store/AppAction.js
DELETED
package/dist/store/AppContext.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AppAction } from "./AppAction";
|
|
2
|
-
export interface AppSession {
|
|
3
|
-
userName: string;
|
|
4
|
-
branchId?: string;
|
|
5
|
-
roles: string[];
|
|
6
|
-
allowedComponents?: string[];
|
|
7
|
-
}
|
|
8
|
-
export declare const defaultSession: AppSession;
|
|
9
|
-
export interface AppContextProps {
|
|
10
|
-
user: AppSession;
|
|
11
|
-
dispatch: React.Dispatch<AppAction>;
|
|
12
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { defaultSession } from "./AppContextType";
|
|
3
|
-
import AppContext from "./AppContext";
|
|
4
|
-
import { ToastContainer } from 'react-toastify';
|
|
5
|
-
import 'react-toastify/dist/ReactToastify.css';
|
|
6
|
-
import { AppActionEnum } from "./AppAction";
|
|
7
|
-
import { sessionStorage } from "aws-amplify/utils";
|
|
8
|
-
import { APPHOSTSESSION_KEY, useSessionReducer } from "./SesssionReducer";
|
|
9
|
-
import { logger } from "../util/Logger";
|
|
10
|
-
const appContextReducer = (state, action) => {
|
|
11
|
-
logger.debug("Action:", action);
|
|
12
|
-
let newState = state;
|
|
13
|
-
switch (action.type) {
|
|
14
|
-
case AppActionEnum.SignIn:
|
|
15
|
-
newState = {
|
|
16
|
-
...action.session,
|
|
17
|
-
};
|
|
18
|
-
break;
|
|
19
|
-
case AppActionEnum.SignOut:
|
|
20
|
-
newState = { ...defaultSession };
|
|
21
|
-
sessionStorage.clear();
|
|
22
|
-
break;
|
|
23
|
-
default:
|
|
24
|
-
newState = state;
|
|
25
|
-
}
|
|
26
|
-
return newState;
|
|
27
|
-
};
|
|
28
|
-
const AppProvider = ({ children }) => {
|
|
29
|
-
const [state, dispatch] = useSessionReducer(appContextReducer, defaultSession, APPHOSTSESSION_KEY);
|
|
30
|
-
return (_jsxs(_Fragment, { children: [_jsx(ToastContainer, { position: "top-right", autoClose: 5000 }), _jsx(AppContext.Provider, { value: { user: state, dispatch }, children: children })] }));
|
|
31
|
-
};
|
|
32
|
-
export default AppProvider;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from 'react';
|
|
3
|
-
const HostedInContainerContext = createContext(false);
|
|
4
|
-
export const HostedInContainerProvider = ({ children }) => {
|
|
5
|
-
const isHosted = (() => {
|
|
6
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
7
|
-
return urlParams.get('hosted_in_container') === 'true';
|
|
8
|
-
})();
|
|
9
|
-
return (_jsx(HostedInContainerContext.Provider, { value: isHosted, children: children }));
|
|
10
|
-
};
|
|
11
|
-
export const useHostedInContainer = () => useContext(HostedInContainerContext);
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Reducer, Dispatch } from 'react';
|
|
2
|
-
import { AppSession } from './AppContextType';
|
|
3
|
-
export declare const APPHOSTSESSION_KEY = "AppHostSession";
|
|
4
|
-
export declare const useSessionReducer: <T extends AppSession, A>(reducer: Reducer<T, A>, initialState: T, storageKey: string) => [T, Dispatch<A>];
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useReducer, useEffect } from 'react';
|
|
2
|
-
export const APPHOSTSESSION_KEY = 'AppHostSession';
|
|
3
|
-
export const useSessionReducer = (reducer, initialState, storageKey) => {
|
|
4
|
-
const [state, dispatch] = useReducer(reducer, initialState, () => {
|
|
5
|
-
const value = localStorage.getItem(storageKey); // use storageKey here
|
|
6
|
-
let retState = { ...initialState };
|
|
7
|
-
if (value) {
|
|
8
|
-
retState = JSON.parse(value);
|
|
9
|
-
}
|
|
10
|
-
return retState;
|
|
11
|
-
});
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
localStorage.setItem(storageKey, JSON.stringify(state)); // same key
|
|
14
|
-
}, [storageKey, state]);
|
|
15
|
-
return [state, dispatch];
|
|
16
|
-
};
|
package/dist/types.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface Route {
|
|
2
|
-
path: string;
|
|
3
|
-
component: React.ComponentType<any>;
|
|
4
|
-
title: string;
|
|
5
|
-
requiredComponent?: string;
|
|
6
|
-
exact?: boolean;
|
|
7
|
-
acl?: {
|
|
8
|
-
[key in Role]: {
|
|
9
|
-
type: DecisionType;
|
|
10
|
-
meta?: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
props?: any;
|
|
14
|
-
}
|
|
15
|
-
export declare enum Role {
|
|
16
|
-
GUEST = "GUEST",
|
|
17
|
-
MEMBER = "MEMBER",
|
|
18
|
-
CHAPTERADMIN = "CHAPTERADMIN",
|
|
19
|
-
SUPPORTADMIN = "SUPPORTADMIN",
|
|
20
|
-
SUPERADMIN = "SUPERADMIN"
|
|
21
|
-
}
|
|
22
|
-
export declare enum DecisionType {
|
|
23
|
-
ALLOW = "allow",
|
|
24
|
-
DENY = "deny",
|
|
25
|
-
REDIRECT = "redirect"
|
|
26
|
-
}
|
package/dist/types.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export var Role;
|
|
2
|
-
(function (Role) {
|
|
3
|
-
Role["GUEST"] = "GUEST";
|
|
4
|
-
Role["MEMBER"] = "MEMBER";
|
|
5
|
-
Role["CHAPTERADMIN"] = "CHAPTERADMIN";
|
|
6
|
-
Role["SUPPORTADMIN"] = "SUPPORTADMIN";
|
|
7
|
-
Role["SUPERADMIN"] = "SUPERADMIN";
|
|
8
|
-
})(Role || (Role = {}));
|
|
9
|
-
export var DecisionType;
|
|
10
|
-
(function (DecisionType) {
|
|
11
|
-
DecisionType["ALLOW"] = "allow";
|
|
12
|
-
DecisionType["DENY"] = "deny";
|
|
13
|
-
DecisionType["REDIRECT"] = "redirect";
|
|
14
|
-
})(DecisionType || (DecisionType = {}));
|