@nerdjs/sales-kit 2.4.22 → 2.4.23

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.
Files changed (44) hide show
  1. package/dist/entities/shipcon/helper.js +1 -1
  2. package/dist/entities/shipcon/helper.js.map +1 -1
  3. package/dist/hooks/lep/lepAccessorials.js +2 -2
  4. package/dist/hooks/lep/lepAdjustments.js +2 -2
  5. package/dist/hooks/lep/lepAppointmentArrivals.js +2 -2
  6. package/dist/hooks/lep/lepClaims.js +3 -3
  7. package/dist/hooks/lep/lepClaims.js.map +1 -1
  8. package/dist/hooks/lep/lepCommodities.js +2 -2
  9. package/dist/hooks/lep/lepCommodities.js.map +1 -1
  10. package/dist/hooks/lep/lepConsolidations.js +2 -2
  11. package/dist/hooks/lep/lepCustomerContacts.js +3 -3
  12. package/dist/hooks/lep/lepCustomerPeople.js +3 -3
  13. package/dist/hooks/lep/lepCustomerSalesNotes.js +2 -2
  14. package/dist/hooks/lep/lepCustomersAccessorials.js +2 -2
  15. package/dist/hooks/lep/lepDispatches.js +2 -2
  16. package/dist/hooks/lep/lepDispatches.js.map +1 -1
  17. package/dist/hooks/lep/lepDocuments.js +2 -2
  18. package/dist/hooks/lep/lepDocuments.js.map +1 -1
  19. package/dist/hooks/lep/lepEDI.js +2 -2
  20. package/dist/hooks/lep/lepEDI.js.map +1 -1
  21. package/dist/hooks/lep/lepHosLogs.js +2 -2
  22. package/dist/hooks/lep/lepInvoiceLineItems.js +2 -2
  23. package/dist/hooks/lep/lepKickbacks.js +2 -2
  24. package/dist/hooks/lep/lepLoadChanges.js +2 -2
  25. package/dist/hooks/lep/lepNotifications.js +24 -23
  26. package/dist/hooks/lep/lepNotifications.js.map +1 -1
  27. package/dist/hooks/lep/lepPossibleIssues.js +2 -2
  28. package/dist/hooks/lep/lepRateLogs.js +2 -2
  29. package/dist/hooks/lep/lepRateReviews.js +2 -2
  30. package/dist/hooks/lep/lepShipcons.js +2 -2
  31. package/dist/hooks/lep/lepTenders.js +2 -2
  32. package/dist/hooks/lep/lepUserNotes.js +2 -2
  33. package/dist/hooks/lep/lepWorkflowEvents.js +2 -2
  34. package/dist/hooks/locationsForm/locationFormSales/helper.d.ts +8 -0
  35. package/dist/hooks/locationsForm/locationFormSales/helper.js +25 -0
  36. package/dist/hooks/locationsForm/locationFormSales/helper.js.map +1 -0
  37. package/dist/hooks/locationsForm/locationFormSales/locationFormSales.js +99 -52
  38. package/dist/hooks/locationsForm/locationFormSales/locationFormSales.js.map +1 -1
  39. package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.d.ts +2 -4
  40. package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.js +322 -615
  41. package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.js.map +1 -1
  42. package/dist/hooks/quote/helpers.js +1 -1
  43. package/dist/hooks/quote/helpers.js.map +1 -1
  44. package/package.json +1 -1
@@ -1,18 +1,17 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button, FormControl, FormLabel, Input, Checkbox, CircularProgress, Select, Option, FormHelperText, Textarea, Box, Autocomplete, Divider, } from "@mui/joy";
3
3
  import { NerdDatePicker, NerdPhoneField, NerdTimePicker, } from "@nerdjs/nerd-ui";
4
4
  import { useEffect, useState } from "react";
5
5
  import salesKitI18n from "../../../i18n";
6
6
  import { useTranslation } from "react-i18next";
7
7
  import { DateTime } from "luxon";
8
- import { locationEntityTypeGuard } from "../../../entities";
9
- import { useGetLocationV1Query, useUpdateLocationV1Mutation, } from "../../../redux";
8
+ import { addressFormGeocoder } from "./helper";
10
9
  /**
11
10
  *
12
11
  * @param {LocationFormSalesMainProps} props props
13
12
  * @returns {ReactElement} locationsFormSalesMain
14
13
  */
15
- export function LocationFormSalesMain({ place, onValidate, onChange: setLocation, value: location, }) {
14
+ export function LocationFormSalesMain({ onValidate, onChange: setLocation, value: location, readOnly, }) {
16
15
  const { t } = useTranslation("common", { i18n: salesKitI18n });
17
16
  const [validationObject, _setValidationObject] = useState({
18
17
  name: true,
@@ -23,98 +22,17 @@ export function LocationFormSalesMain({ place, onValidate, onChange: setLocation
23
22
  FCFSIN: true,
24
23
  FCFSOUT: true,
25
24
  });
26
- const { data, isLoading } = useGetLocationV1Query(locationEntityTypeGuard(place) && place.id ? place.id : 0, { skip: locationEntityTypeGuard(place) && place.id ? false : true });
27
- const [updateLocation] = useUpdateLocationV1Mutation();
28
25
  const googleMapsAutocompleteService = new google.maps.places.AutocompleteService();
29
26
  const googleMapsGeocoder = new google.maps.Geocoder();
30
27
  const [googleMapsPredictions, setGoogleMapsPredictions] = useState(null);
31
28
  const [value, setValue] = useState(null);
32
- const [loadingMapsLocations, setLoadingMapsLocations] = useState(place ? true : false);
33
- const addressFormGeocoder = (place) => {
34
- const address = {};
35
- const _ref = place.address_components;
36
- const _len = _ref.length;
37
- for (let _i = 0; _i < _len; _i++) {
38
- const i = _ref[_i];
39
- const _ref1 = i.types;
40
- const _len1 = _ref1.length;
41
- for (let _j = 0; _j < _len1; _j++) {
42
- const t = _ref1[_j];
43
- address[t] = i.short_name;
44
- address[`${t}_long`] = i.long_name;
45
- }
46
- }
47
- const line1 = `${address.street_number ? `${address.street_number} ` : ""}${address.route}`.trim();
48
- const city = address.locality_long ||
49
- address.sublocality_long ||
50
- address.sublocality_level_1_long ||
51
- address.neighborhood_long;
52
- const state = address.administrative_area_level_1;
53
- const zip = address.postal_code;
54
- const formatted_address = place.formatted_address;
55
- return { line1, city, state, zip, formatted_address };
56
- };
57
- useEffect(() => {
58
- // If place is an Archer location v3 object, fetch the matching v1 object and populate the google maps autocomplete
59
- if (locationEntityTypeGuard(place) &&
60
- data?.id &&
61
- place?.id &&
62
- data.id === place.id) {
63
- setLocation(data);
64
- setValidationObject({
65
- ...validationObject,
66
- address: data?.address_id ? true : false,
67
- name: data?.name ? true : false,
68
- phone: true,
69
- });
70
- if (data.formatted_address) {
71
- getGoogleAddresses(data.formatted_address, true);
72
- }
73
- else {
74
- setLoadingMapsLocations(false);
75
- }
76
- }
77
- else if (place && locationEntityTypeGuard(place)) {
78
- setLocation({
79
- line1: place.address.line1,
80
- city: place.address.city,
81
- state: place.address.state,
82
- zip: place.address.zip,
83
- formatted_address: place.address.formattedAddress,
84
- place_id: place.address.placeId,
85
- });
86
- setValidationObject({
87
- ...validationObject,
88
- name: false,
89
- });
90
- if (place.address.formattedAddress) {
91
- getGoogleAddresses(place.address.formattedAddress, true);
92
- }
93
- else {
94
- setLoadingMapsLocations(false);
95
- }
96
- }
97
- else if (place) {
98
- const address = addressFormGeocoder(place);
99
- setLocation({ ...address });
100
- setLoadingMapsLocations(false);
101
- getGoogleAddresses(place.formatted_address, true);
102
- }
103
- }, [data?.id, place]);
104
- useEffect(() => {
105
- if (!loadingMapsLocations) {
106
- setValue(googleMapsPredictions?.find((l) => location.place_id === l.place_id) ||
107
- googleMapsPredictions?.[0] ||
108
- null);
109
- }
110
- }, [loadingMapsLocations]);
29
+ const [loadingMapsLocations, setLoadingMapsLocations] = useState(location.formatted_address ? true : false);
111
30
  const setValidationObject = (validationObject) => {
112
31
  _setValidationObject(validationObject);
113
32
  onValidate?.(validationObject);
114
33
  };
115
- const getGoogleAddresses = (searchText, init) => {
116
- if (init)
117
- setLoadingMapsLocations(true);
34
+ const getGoogleAddresses = (searchText, callback) => {
35
+ setLoadingMapsLocations(true);
118
36
  googleMapsAutocompleteService.getPlacePredictions({
119
37
  input: searchText,
120
38
  componentRestrictions: { country: "us" },
@@ -122,550 +40,339 @@ export function LocationFormSalesMain({ place, onValidate, onChange: setLocation
122
40
  language: "en",
123
41
  }, (googleSuggestions) => {
124
42
  setGoogleMapsPredictions(googleSuggestions);
125
- if (init)
126
- setLoadingMapsLocations(false);
43
+ setLoadingMapsLocations(false);
44
+ callback?.(googleSuggestions);
127
45
  });
128
46
  };
129
- return (_jsx(_Fragment, { children: isLoading ? (_jsx(Box, { sx: {
130
- display: "flex",
131
- justifyContent: "center",
132
- alignItems: "center",
133
- height: { xs: "100%", sm: "none" },
134
- }, children: _jsx(CircularProgress, {}) })) : (_jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, children: [_jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", children: [_jsxs(FormControl, { required: true, sx: {
135
- flex: "1 1 220px",
136
- }, children: [_jsx(FormLabel, { children: t("Name") }), _jsx(Input, { fullWidth: true, error: !validationObject.name, onChange: (e) => {
47
+ useEffect(() => {
48
+ setValidationObject({
49
+ ...validationObject,
50
+ address: location.place_id ? true : false,
51
+ name: location.name ? true : false,
52
+ phone: true,
53
+ });
54
+ }, [location]);
55
+ useEffect(() => {
56
+ if (location.formatted_address) {
57
+ getGoogleAddresses(location.formatted_address, (result) => setValue(result?.find((l) => location.place_id === l.place_id) ||
58
+ result?.[0] ||
59
+ null));
60
+ }
61
+ else {
62
+ setLoadingMapsLocations(false);
63
+ }
64
+ }, [location.formatted_address]);
65
+ return (_jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, children: [_jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", children: [_jsxs(FormControl, { required: true, sx: {
66
+ flex: "1 1 220px",
67
+ }, children: [_jsx(FormLabel, { children: t("Name") }), _jsx(Input, { fullWidth: true, readOnly: readOnly, error: !validationObject.name, onChange: (e) => {
68
+ setValidationObject({
69
+ ...validationObject,
70
+ name: e.target.value ? true : false,
71
+ });
72
+ setLocation({ ...location, name: e.target.value });
73
+ }, size: "sm", value: location?.name ?? "", placeholder: t("Facility's name") })] }), _jsxs(FormControl, { required: true, sx: {
74
+ flex: "1 1 300px",
75
+ }, children: [_jsx(FormLabel, { children: "Address" }), _jsx(Autocomplete, { size: "sm", readOnly: readOnly, value: value, error: !validationObject.address, options: googleMapsPredictions || [], onInputChange: (_e, v) => {
76
+ getGoogleAddresses(v);
77
+ }, endDecorator: loadingMapsLocations ? (_jsx(CircularProgress, { sx: {
78
+ "--CircularProgress-size": "18px",
79
+ "--CircularProgress-trackThickness": "3px",
80
+ "--CircularProgress-progressThickness": "3px",
81
+ } })) : null, onChange: (_e, v) => {
82
+ setValue(v);
83
+ if (v && v.place_id !== location.place_id) {
84
+ googleMapsGeocoder.geocode({ placeId: v.place_id }, (result) => {
85
+ const place = result?.[0];
86
+ if (place) {
87
+ const address = addressFormGeocoder(place);
88
+ setLocation({
89
+ ...location,
90
+ ...address,
91
+ place_id: place.place_id,
92
+ });
93
+ }
94
+ });
95
+ }
96
+ }, getOptionLabel: (option) => `${option.structured_formatting.main_text}, ${option.structured_formatting.secondary_text}`, isOptionEqualToValue: (o, v) => o.place_id === v.place_id })] })] }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: 1, children: [_jsxs(FormControl, { sx: {
97
+ flex: "1.5 1 auto",
98
+ }, children: [_jsx(FormLabel, { children: "Line 1" }), _jsx(Input, { readOnly: true, size: "sm", value: location?.line1 ?? "", placeholder: t("Line 1") })] }), _jsxs(FormControl, { sx: {
99
+ flex: "1 1 auto",
100
+ }, children: [_jsx(FormLabel, { children: "#" }), _jsx(Input, { size: "sm", readOnly: readOnly, value: location?.line2 ?? "", onChange: (e) => {
101
+ setLocation({ ...location, line2: e.target.value });
102
+ } })] }), _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "City" }), _jsx(Input, { readOnly: true, size: "sm", value: location?.city ?? "", placeholder: t("City") })] }), _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "State" }), _jsx(Input, { sx: {
103
+ width: "45px",
104
+ }, readOnly: true, size: "sm", value: location?.state ?? "", placeholder: t("State") })] }), _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "ZIP" }), _jsx(Input, { sx: {
105
+ width: "70px",
106
+ }, readOnly: true, size: "sm", value: location?.zip ?? "", placeholder: t("ZIP") })] })] }), _jsx(Box, { flex: "1 1 100%", mt: 0.5, mb: 0.5, children: _jsx(Divider, {}) }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", children: [_jsxs(FormControl, { sx: {
107
+ flex: "1 1 auto",
108
+ }, children: [_jsx(FormLabel, { children: "Emails" }), _jsx(Input, { fullWidth: true, readOnly: readOnly, onChange: (e) => {
109
+ setLocation({ ...location, email_addresses: e.target.value });
110
+ }, size: "sm", value: location?.email_addresses || "", placeholder: "one@email.com; two@email.com..." })] }), _jsxs(FormControl, { sx: {
111
+ flex: "1 1 auto",
112
+ }, children: [_jsx(FormLabel, { children: "Contact" }), _jsx(Input, { fullWidth: true, readOnly: readOnly, onChange: (e) => {
113
+ setLocation({ ...location, contact: e.target.value });
114
+ }, size: "sm", value: location.contact || "", placeholder: "Contact" }), _jsx(FormHelperText, { sx: {
115
+ display: { xs: "none", lg: "initial" },
116
+ }, children: " " })] }), _jsx(NerdPhoneField, { value: location.phone, label: t("Phone"), inputProps: {
117
+ placeholder: t("Phone"),
118
+ size: "sm",
119
+ fullWidth: true,
120
+ error: !validationObject.phone,
121
+ readOnly,
122
+ }, onAccept: (value) => {
123
+ setValidationObject({
124
+ ...validationObject,
125
+ phone: true,
126
+ });
127
+ setLocation({ ...location, phone: value });
128
+ }, onError: () => {
129
+ setValidationObject({
130
+ ...validationObject,
131
+ phone: false,
132
+ });
133
+ }, format: "national" }), _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Ext" }), _jsx(Input, { value: location.ext_number || "", placeholder: "Ext", size: "sm", sx: {
134
+ width: 80,
135
+ }, onChange: (e) => {
136
+ setLocation({ ...location, ext_number: e.target.value });
137
+ }, readOnly: readOnly })] })] }), _jsx(Box, { flex: "1 1 100%", mt: 0.5, mb: 0.5, children: _jsx(Divider, {}) }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", mb: 0.5, children: [_jsx(Checkbox, { label: "Need File", disabled: readOnly, checked: location.needs_file || false, onChange: (e) => {
138
+ setLocation({ ...location, needs_file: e.target.checked });
139
+ }, sx: {
140
+ flex: "1 1 auto",
141
+ } }), _jsx(Checkbox, { label: "Need Liquor Permit", disabled: readOnly, checked: location.needs_liquor_permit || false, onChange: (e) => {
142
+ setLocation({
143
+ ...location,
144
+ needs_liquor_permit: e.target.checked,
145
+ });
146
+ }, sx: {
147
+ flex: "1 1 auto",
148
+ } }), _jsx(Checkbox, { label: "First come first serve(FCFS)", disabled: readOnly, checked: location.first_come_first_serve || false, onChange: (e) => {
149
+ setLocation({
150
+ ...location,
151
+ first_come_first_serve: e.target.checked,
152
+ });
153
+ }, sx: {
154
+ flex: "1 1 auto",
155
+ } }), _jsx(Checkbox, { label: "Strict Scheduling", disabled: readOnly, checked: location.strict_scheduling || false, onChange: (e) => {
156
+ setLocation({
157
+ ...location,
158
+ strict_scheduling: e.target.checked,
159
+ });
160
+ }, sx: {
161
+ flex: "1 1 auto",
162
+ } })] }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", justifyContent: "space-between", children: [_jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, children: [_jsx(NerdDatePicker, { inputProps: {
163
+ size: "sm",
164
+ disabled: readOnly,
165
+ }, value: location.first_come_date
166
+ ? DateTime.fromISO(location.first_come_date)
167
+ : null, onChange: (newDate) => {
168
+ setLocation({
169
+ ...location,
170
+ first_come_date: newDate?.toISO() || "",
171
+ });
172
+ } }), _jsx(NerdTimePicker, { label: "FCFS IN", inputProps: {
173
+ sx: {
174
+ width: 100,
175
+ },
176
+ size: "sm",
177
+ slotProps: {
178
+ input: {
179
+ sx: {
180
+ p: 0.5,
181
+ },
182
+ },
183
+ },
184
+ disabled: readOnly,
185
+ }, value: location.first_come_in
186
+ ? DateTime.fromISO(location.first_come_in)
187
+ .toUTC()
188
+ .toFormat("HH:mm")
189
+ : null, onChange: (time) => {
190
+ if (!time.isValid) {
137
191
  setValidationObject({
138
192
  ...validationObject,
139
- name: e.target.value ? true : false,
193
+ FCFSIN: false,
140
194
  });
141
- setLocation({ ...location, name: e.target.value });
142
- }, onBlur: (e) => {
143
- if (location.id && data?.name !== e.target.value)
144
- updateLocation({
145
- id: location.id,
146
- body: {
147
- location: {
148
- name: e.target.value,
149
- },
150
- },
151
- });
152
- }, size: "sm", value: location?.name ?? "", placeholder: t("Facility's name") })] }), _jsxs(FormControl, { required: true, sx: {
153
- flex: "1 1 300px",
154
- }, children: [_jsx(FormLabel, { children: "Address" }), _jsx(Autocomplete, { size: "sm", value: value, error: !validationObject.address, options: googleMapsPredictions || [], onInputChange: (_e, v) => {
155
- getGoogleAddresses(v, false);
156
- }, endDecorator: loadingMapsLocations ? (_jsx(CircularProgress, { sx: {
157
- "--CircularProgress-size": "18px",
158
- "--CircularProgress-trackThickness": "3px",
159
- "--CircularProgress-progressThickness": "3px",
160
- } })) : null, onChange: (_e, v) => {
161
- setValue(v);
162
- if (v && v.place_id !== location.place_id) {
163
- googleMapsGeocoder.geocode({ placeId: v.place_id }, (result) => {
164
- const place = result?.[0];
165
- if (place) {
166
- const address = addressFormGeocoder(place);
167
- setLocation({
168
- ...location,
169
- ...address,
170
- place_id: place.place_id,
171
- });
172
- if (location.id && place.place_id !== data?.place_id)
173
- updateLocation({
174
- id: location.id,
175
- body: {
176
- location: {
177
- ...address,
178
- place_id: place.place_id,
179
- },
180
- },
181
- });
182
- }
183
- });
184
- }
195
+ }
196
+ else {
185
197
  setValidationObject({
186
198
  ...validationObject,
187
- address: !v ? false : true,
199
+ FCFSIN: true,
188
200
  });
189
- }, getOptionLabel: (option) => `${option.structured_formatting.main_text}, ${option.structured_formatting.secondary_text}`, isOptionEqualToValue: (o, v) => o.place_id === v.place_id })] })] }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: 1, children: [_jsxs(FormControl, { sx: {
190
- flex: "1.5 1 auto",
191
- }, children: [_jsx(FormLabel, { children: "Line 1" }), _jsx(Input, { readOnly: true, size: "sm", value: location?.line1 ?? "", placeholder: t("Line 1") })] }), _jsxs(FormControl, { sx: {
192
- flex: "1 1 auto",
193
- }, children: [_jsx(FormLabel, { children: "#" }), _jsx(Input, { size: "sm", value: location?.line2 ?? "", onChange: (e) => {
194
- setLocation({ ...location, line2: e.target.value });
195
- }, onBlur: (e) => {
196
- if (location.id && data?.line2 !== e.target.value)
197
- updateLocation({
198
- id: location.id,
199
- body: {
200
- location: {
201
- line2: e.target.value,
202
- },
203
- },
204
- });
205
- } })] }), _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "City" }), _jsx(Input, { readOnly: true, size: "sm", value: location?.city ?? "", placeholder: t("City") })] }), _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "State" }), _jsx(Input, { sx: {
206
- width: "45px",
207
- }, readOnly: true, size: "sm", value: location?.state ?? "", placeholder: t("State") })] }), _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "ZIP" }), _jsx(Input, { sx: {
208
- width: "70px",
209
- }, readOnly: true, size: "sm", value: location?.zip ?? "", placeholder: t("ZIP") })] })] }), _jsx(Box, { flex: "1 1 100%", mt: 0.5, mb: 0.5, children: _jsx(Divider, {}) }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", children: [_jsxs(FormControl, { sx: {
210
- flex: "1 1 auto",
211
- }, children: [_jsx(FormLabel, { children: "Emails" }), _jsx(Input, { fullWidth: true, onChange: (e) => {
212
- setLocation({ ...location, email_addresses: e.target.value });
213
- }, onBlur: (e) => {
214
- if (location.id && data?.email_addresses !== e.target.value)
215
- updateLocation({
216
- id: location.id,
217
- body: {
218
- location: {
219
- email_addresses: e.target.value,
220
- },
221
- },
222
- });
223
- }, size: "sm", value: location?.email_addresses || "", placeholder: "one@email.com; two@email.com..." })] }), _jsxs(FormControl, { sx: {
224
- flex: "1 1 auto",
225
- }, children: [_jsx(FormLabel, { children: "Contact" }), _jsx(Input, { fullWidth: true, onChange: (e) => {
226
- setLocation({ ...location, contact: e.target.value });
227
- }, onBlur: (e) => {
228
- if (location.id && data?.contact !== e.target.value)
229
- updateLocation({
230
- id: location.id,
231
- body: {
232
- location: {
233
- contact: e.target.value,
234
- },
235
- },
236
- });
237
- }, size: "sm", value: location.contact || "", placeholder: "Contact" }), _jsx(FormHelperText, { sx: {
238
- display: { xs: "none", lg: "initial" },
239
- }, children: " " })] }), _jsx(NerdPhoneField, { value: location.phone, label: t("Phone"), inputProps: {
240
- placeholder: t("Phone"),
241
- size: "sm",
242
- fullWidth: true,
243
- error: !validationObject.phone,
244
- }, onAccept: (value) => {
245
- setValidationObject({
246
- ...validationObject,
247
- phone: true,
248
- });
249
- setLocation({ ...location, phone: value });
250
- if (location.id && data?.phone !== value)
251
- updateLocation({
252
- id: location.id,
253
- body: {
254
- location: {
255
- phone: value,
256
- },
257
- },
258
- });
259
- }, onError: () => {
260
- setValidationObject({
261
- ...validationObject,
262
- phone: false,
263
- });
264
- } }), _jsxs(FormControl, { children: [_jsx(FormLabel, { children: "Ext" }), _jsx(Input, { value: location.ext_number || "", placeholder: "Ext", size: "sm", sx: {
265
- width: 80,
266
- }, onChange: (e) => {
267
- setLocation({ ...location, ext_number: e.target.value });
268
- }, onBlur: (e) => {
269
- if (location.id && data?.ext_number !== e.target.value)
270
- updateLocation({
271
- id: location.id,
272
- body: {
273
- location: {
274
- ext_number: e.target.value,
275
- },
276
- },
277
- });
278
- } })] })] }), _jsx(Box, { flex: "1 1 100%", mt: 0.5, mb: 0.5, children: _jsx(Divider, {}) }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", mb: 0.5, children: [_jsx(Checkbox, { label: "Need File", checked: location.needs_file || false, onChange: (e) => {
279
- setLocation({ ...location, needs_file: e.target.checked });
280
- if (location.id && data?.needs_file !== e.target.checked)
281
- updateLocation({
282
- id: location.id,
283
- body: {
284
- location: {
285
- needs_file: e.target.checked,
286
- },
287
- },
288
- });
289
- }, sx: {
290
- flex: "1 1 auto",
291
- } }), _jsx(Checkbox, { label: "Need Liquor Permit", checked: location.needs_liquor_permit || false, onChange: (e) => {
292
- setLocation({
293
- ...location,
294
- needs_liquor_permit: e.target.checked,
295
- });
296
- if (location.id &&
297
- data?.needs_liquor_permit !== e.target.checked)
298
- updateLocation({
299
- id: location.id,
300
- body: {
301
- location: {
302
- needs_liquor_permit: e.target.checked,
303
- },
304
- },
305
- });
306
- }, sx: {
307
- flex: "1 1 auto",
308
- } }), _jsx(Checkbox, { label: "First come first serve(FCFS)", checked: location.first_come_first_serve || false, onChange: (e) => {
309
- setLocation({
310
- ...location,
311
- first_come_first_serve: e.target.checked,
312
- });
313
- if (location.id &&
314
- data?.first_come_first_serve !== e.target.checked)
315
- updateLocation({
316
- id: location.id,
317
- body: {
318
- location: {
319
- first_come_first_serve: e.target.checked,
320
- },
321
- },
322
- });
323
- }, sx: {
324
- flex: "1 1 auto",
325
- } }), _jsx(Checkbox, { label: "Strict Scheduling", checked: location.strict_scheduling || false, onChange: (e) => {
326
- setLocation({
327
- ...location,
328
- strict_scheduling: e.target.checked,
329
- });
330
- if (location.id && data?.strict_scheduling !== e.target.checked)
331
- updateLocation({
332
- id: location.id,
333
- body: {
334
- location: {
335
- strict_scheduling: e.target.checked,
201
+ const newTime = time.duration
202
+ ? DateTime.now()
203
+ .toUTC()
204
+ .set({
205
+ hour: time.duration.hours,
206
+ minute: time.duration.minutes,
207
+ second: 0,
208
+ })
209
+ .toISO() || ""
210
+ : "";
211
+ setLocation({ ...location, first_come_in: newTime });
212
+ }
213
+ } }), _jsx(NerdTimePicker, { label: "FCFS OUT", inputProps: {
214
+ sx: {
215
+ width: 100,
216
+ },
217
+ size: "sm",
218
+ slotProps: {
219
+ input: {
220
+ sx: {
221
+ p: 0.5,
336
222
  },
337
223
  },
338
- });
339
- }, sx: {
340
- flex: "1 1 auto",
341
- } })] }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", justifyContent: "space-between", children: [_jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, children: [_jsx(NerdDatePicker, { inputProps: {
342
- size: "sm",
343
- }, value: location.first_come_date
344
- ? DateTime.fromISO(location.first_come_date)
345
- : null, onChange: (newDate) => {
346
- setLocation({
347
- ...location,
348
- first_come_date: newDate?.toISO() || "",
224
+ },
225
+ disabled: readOnly,
226
+ }, value: location.first_come_out
227
+ ? DateTime.fromISO(location.first_come_out)
228
+ .toUTC()
229
+ .toFormat("HH:mm")
230
+ : null, onChange: (time) => {
231
+ if (!time.isValid) {
232
+ setValidationObject({
233
+ ...validationObject,
234
+ FCFSOUT: false,
349
235
  });
350
- if (location.id &&
351
- data?.first_come_date !== (newDate?.toISO() || ""))
352
- updateLocation({
353
- id: location.id,
354
- body: {
355
- location: {
356
- first_come_date: newDate?.toISO() || "",
357
- },
358
- },
359
- });
360
- } }), _jsx(NerdTimePicker, { label: "FCFS IN", inputProps: {
361
- sx: {
362
- width: 100,
363
- },
364
- size: "sm",
365
- slotProps: {
366
- input: {
367
- sx: {
368
- p: 0.5,
369
- },
370
- },
371
- },
372
- }, value: location.first_come_in
373
- ? DateTime.fromISO(location.first_come_in)
374
- .toUTC()
375
- .toFormat("HH:mm")
376
- : null, onChange: (time) => {
377
- if (!time.isValid) {
378
- setValidationObject({
379
- ...validationObject,
380
- FCFSIN: false,
381
- });
382
- }
383
- else {
384
- setValidationObject({
385
- ...validationObject,
386
- FCFSIN: true,
387
- });
388
- const newTime = time.duration
389
- ? DateTime.now()
390
- .toUTC()
391
- .set({
392
- hour: time.duration.hours,
393
- minute: time.duration.minutes,
394
- second: 0,
395
- })
396
- .toISO() || ""
397
- : "";
398
- setLocation({ ...location, first_come_in: newTime });
399
- if (location.id && data?.first_come_in !== newTime)
400
- updateLocation({
401
- id: location.id,
402
- body: {
403
- location: {
404
- first_come_in: newTime,
405
- },
406
- },
407
- });
408
- }
409
- } }), _jsx(NerdTimePicker, { label: "FCFS OUT", inputProps: {
410
- sx: {
411
- width: 100,
412
- },
413
- size: "sm",
414
- slotProps: {
415
- input: {
236
+ }
237
+ else {
238
+ setValidationObject({
239
+ ...validationObject,
240
+ FCFSOUT: true,
241
+ });
242
+ const newTime = time.duration
243
+ ? DateTime.now()
244
+ .toUTC()
245
+ .set({
246
+ hour: time.duration.hours,
247
+ minute: time.duration.minutes,
248
+ second: 0,
249
+ })
250
+ .toISO() || ""
251
+ : "";
252
+ setLocation({ ...location, first_come_out: newTime });
253
+ }
254
+ } })] }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, children: [_jsxs(FormControl, { children: [_jsx(FormLabel, { children: "PSR Days" }), _jsxs(Select, { size: "sm", defaultValue: location.preschedule_days || 0, onChange: (_e, value) => {
255
+ setLocation({ ...location, preschedule_days: value || 0 });
256
+ }, slotProps: {
257
+ listbox: {
416
258
  sx: {
417
- p: 0.5,
418
- },
419
- },
420
- },
421
- }, value: location.first_come_out
422
- ? DateTime.fromISO(location.first_come_out)
423
- .toUTC()
424
- .toFormat("HH:mm")
425
- : null, onChange: (time) => {
426
- if (!time.isValid) {
427
- setValidationObject({
428
- ...validationObject,
429
- FCFSOUT: false,
430
- });
431
- }
432
- else {
433
- setValidationObject({
434
- ...validationObject,
435
- FCFSOUT: true,
436
- });
437
- const newTime = time.duration
438
- ? DateTime.now()
439
- .toUTC()
440
- .set({
441
- hour: time.duration.hours,
442
- minute: time.duration.minutes,
443
- second: 0,
444
- })
445
- .toISO() || ""
446
- : "";
447
- setLocation({ ...location, first_come_out: newTime });
448
- if (location.id && data?.first_come_out !== newTime)
449
- updateLocation({
450
- id: location.id,
451
- body: {
452
- location: {
453
- first_come_out: newTime,
454
- },
455
- },
456
- });
457
- }
458
- } })] }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, children: [_jsxs(FormControl, { children: [_jsx(FormLabel, { children: "PSR Days" }), _jsxs(Select, { size: "sm", defaultValue: location.preschedule_days || 0, onChange: (_e, value) => {
459
- setLocation({ ...location, preschedule_days: value || 0 });
460
- if (location.id && data?.preschedule_days !== (value || 0))
461
- updateLocation({
462
- id: location.id,
463
- body: {
464
- location: {
465
- preschedule_days: value || 0,
466
- },
467
- },
468
- });
469
- }, slotProps: {
470
- listbox: {
471
- sx: {
472
- zIndex: (theme) => theme.zIndex.modal,
473
- },
259
+ zIndex: (theme) => theme.zIndex.modal,
474
260
  },
475
- }, children: [_jsx(Option, { value: 0, children: "None" }, 0), [1, 2, 3, 4, 5].map((v) => (_jsx(Option, { value: v, children: v }, v))), _jsx(Option, { value: 14, children: "ASAP" }, 14)] })] }), _jsx(NerdTimePicker, { inputProps: {
476
- sx: {
477
- width: 100,
478
- },
479
- size: "sm",
480
- }, label: "Open Time", value: location.time_from
481
- ? DateTime.fromISO(location.time_from)
482
- .toUTC()
483
- .toFormat("HH:mm")
484
- : null, onChange: (time) => {
485
- if (!time.isValid) {
486
- setValidationObject({
487
- ...validationObject,
488
- openTime: false,
489
- });
490
- }
491
- else {
492
- setValidationObject({
493
- ...validationObject,
494
- openTime: true,
495
- });
496
- const newTime = time.duration
497
- ? DateTime.now()
498
- .toUTC()
499
- .set({
500
- hour: time.duration.hours,
501
- minute: time.duration.minutes,
502
- second: 0,
503
- })
504
- .toISO() || ""
505
- : "";
506
- setLocation({ ...location, time_from: newTime });
507
- if (location.id && data?.time_from !== newTime)
508
- updateLocation({
509
- id: location.id,
510
- body: {
511
- location: {
512
- time_from: newTime,
513
- },
514
- },
515
- });
516
- }
517
- } }), _jsx(NerdTimePicker, { inputProps: {
518
- sx: {
519
- width: 100,
520
- },
521
- size: "sm",
522
- }, label: "Close Time", value: location.time_to
523
- ? DateTime.fromISO(location.time_to)
524
- .toUTC()
525
- .toFormat("HH:mm")
526
- : null, onChange: (time) => {
527
- if (!time.isValid) {
528
- setValidationObject({
529
- ...validationObject,
530
- closeTime: false,
531
- });
532
- }
533
- else {
534
- setValidationObject({
535
- ...validationObject,
536
- closeTime: true,
537
- });
538
- const newTime = time.duration
539
- ? DateTime.now()
540
- .toUTC()
541
- .set({
542
- hour: time.duration.hours,
543
- minute: time.duration.minutes,
544
- second: 0,
545
- })
546
- .toISO() || ""
547
- : "";
548
- setLocation({ ...location, time_to: newTime });
549
- if (location.id && data?.time_to !== newTime)
550
- updateLocation({
551
- id: location.id,
552
- body: {
553
- location: {
554
- time_to: newTime,
555
- },
556
- },
557
- });
558
- }
559
- } })] })] }), _jsxs(FormControl, { sx: {
560
- flex: 1,
561
- }, children: [_jsx(FormLabel, { children: "TMS Link" }), _jsx(Input, { fullWidth: true, onChange: (e) => {
562
- setLocation({ ...location, tms_link: e.target.value });
563
- }, onBlur: (e) => {
564
- if (location.id && data?.tms_link !== e.target.value)
565
- updateLocation({
566
- id: location.id,
567
- body: {
568
- location: {
569
- tms_link: e.target.value,
570
- },
571
- },
572
- });
573
- }, size: "sm", value: location.tms_link || "", placeholder: "TMS Link", endDecorator: _jsx(Button, { variant: "soft", size: "sm", component: location.tms_link ? "a" : "button", href: location.tms_link
574
- ? location.tms_link.match(/^https?:\/{2}/)
575
- ? location.tms_link
576
- : `//${location.tms_link}`
577
- : "", startDecorator: _jsx("i", { className: "fa-solid fa-arrow-up-right-from-square" }), target: "_blank", rel: "noopener noreferrer", sx: {
578
- mr: -1,
579
- height: "100%",
580
- textDecoration: "none!important",
581
- }, children: "GO" }) })] }), _jsxs(FormControl, { sx: {
582
- flex: 1,
583
- }, children: [_jsx(FormLabel, { children: "Channel" }), _jsx(Select, { size: "sm", defaultValue: location.scheduling_channel, onChange: (_e, value) => {
584
- setLocation({ ...location, scheduling_channel: value || "" });
585
- if (location.id && data?.scheduling_channel !== (value || ""))
586
- updateLocation({
587
- id: location.id,
588
- body: {
589
- location: {
590
- scheduling_channel: value || "",
591
261
  },
592
- },
593
- });
594
- }, slotProps: {
595
- listbox: {
262
+ }, disabled: readOnly, children: [_jsx(Option, { value: 0, children: "None" }, 0), [1, 2, 3, 4, 5].map((v) => (_jsx(Option, { value: v, children: v }, v))), _jsx(Option, { value: 14, children: "ASAP" }, 14)] })] }), _jsx(NerdTimePicker, { inputProps: {
596
263
  sx: {
597
- zIndex: (theme) => theme.zIndex.modal,
264
+ width: 100,
598
265
  },
599
- },
600
- }, children: [
601
- { label: "None", value: "" },
602
- { label: "Email", value: "email" },
603
- { label: "Call", value: "call" },
604
- { label: "Portal", value: "portal" },
605
- { label: "Customer", value: "customer" },
606
- ].map((v) => (_jsx(Option, { value: v.value, children: v.label }, v.value))) }), _jsx(FormHelperText, { children: " " })] }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", children: [_jsxs(FormControl, { sx: {
607
- flex: 1,
608
- }, children: [_jsx(FormLabel, { children: "Prev. Appts." }), _jsx(Textarea, { maxRows: 4, minRows: 4, onChange: (e) => {
609
- setLocation({ ...location, prev_apts: e.target.value });
610
- }, onBlur: (e) => {
611
- if (location.id && data?.prev_apts !== e.target.value)
612
- updateLocation({
613
- id: location.id,
614
- body: {
615
- location: {
616
- prev_apts: e.target.value,
617
- },
618
- },
619
- });
620
- }, size: "sm", value: location.prev_apts || "" })] }), _jsxs(FormControl, { sx: {
621
- flex: 1,
622
- }, children: [_jsx(FormLabel, { children: "Location Notes" }), _jsx(Textarea, { maxRows: 4, minRows: 4, onChange: (e) => {
623
- setLocation({ ...location, notes: e.target.value });
624
- }, onBlur: (e) => {
625
- if (location.id && data?.notes !== e.target.value)
626
- updateLocation({
627
- id: location.id,
628
- body: {
629
- location: {
630
- notes: e.target.value,
631
- },
632
- },
633
- });
634
- }, size: "sm", value: location.notes || "" })] })] }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", children: [_jsxs(FormControl, { sx: {
635
- flex: 1,
636
- }, children: [_jsx(FormLabel, { children: "Location Scheduling Notes" }), _jsx(Textarea, { maxRows: 4, minRows: 4, onChange: (e) => {
637
- setLocation({
638
- ...location,
639
- scheduling_notes: e.target.value,
266
+ size: "sm",
267
+ disabled: readOnly,
268
+ }, label: "Open Time", value: location.time_from
269
+ ? DateTime.fromISO(location.time_from).toUTC().toFormat("HH:mm")
270
+ : null, onChange: (time) => {
271
+ if (!time.isValid) {
272
+ setValidationObject({
273
+ ...validationObject,
274
+ openTime: false,
640
275
  });
641
- }, onBlur: (e) => {
642
- if (location.id && data?.scheduling_notes !== e.target.value)
643
- updateLocation({
644
- id: location.id,
645
- body: {
646
- location: {
647
- scheduling_notes: e.target.value,
648
- },
649
- },
650
- });
651
- }, size: "sm", value: location.scheduling_notes || "" })] }), _jsxs(FormControl, { sx: {
652
- flex: 1,
653
- }, children: [_jsx(FormLabel, { children: "Driver Instructions" }), _jsx(Textarea, { maxRows: 4, minRows: 4, onChange: (e) => {
654
- setLocation({
655
- ...location,
656
- driver_instructions: e.target.value,
276
+ }
277
+ else {
278
+ setValidationObject({
279
+ ...validationObject,
280
+ openTime: true,
657
281
  });
658
- }, onBlur: (e) => {
659
- if (location.id &&
660
- data?.driver_instructions !== e.target.value)
661
- updateLocation({
662
- id: location.id,
663
- body: {
664
- location: {
665
- driver_instructions: e.target.value,
666
- },
667
- },
668
- });
669
- }, size: "sm", value: location.driver_instructions || "" })] })] })] })) }));
282
+ const newTime = time.duration
283
+ ? DateTime.now()
284
+ .toUTC()
285
+ .set({
286
+ hour: time.duration.hours,
287
+ minute: time.duration.minutes,
288
+ second: 0,
289
+ })
290
+ .toISO() || ""
291
+ : "";
292
+ setLocation({ ...location, time_from: newTime });
293
+ }
294
+ } }), _jsx(NerdTimePicker, { inputProps: {
295
+ sx: {
296
+ width: 100,
297
+ },
298
+ size: "sm",
299
+ disabled: readOnly,
300
+ }, label: "Close Time", value: location.time_to
301
+ ? DateTime.fromISO(location.time_to).toUTC().toFormat("HH:mm")
302
+ : null, onChange: (time) => {
303
+ if (!time.isValid) {
304
+ setValidationObject({
305
+ ...validationObject,
306
+ closeTime: false,
307
+ });
308
+ }
309
+ else {
310
+ setValidationObject({
311
+ ...validationObject,
312
+ closeTime: true,
313
+ });
314
+ const newTime = time.duration
315
+ ? DateTime.now()
316
+ .toUTC()
317
+ .set({
318
+ hour: time.duration.hours,
319
+ minute: time.duration.minutes,
320
+ second: 0,
321
+ })
322
+ .toISO() || ""
323
+ : "";
324
+ setLocation({ ...location, time_to: newTime });
325
+ }
326
+ } })] })] }), _jsxs(FormControl, { sx: {
327
+ flex: 1,
328
+ }, children: [_jsx(FormLabel, { children: "TMS Link" }), _jsx(Input, { fullWidth: true, onChange: (e) => {
329
+ setLocation({ ...location, tms_link: e.target.value });
330
+ }, readOnly: readOnly, size: "sm", value: location.tms_link || "", placeholder: "TMS Link", endDecorator: _jsx(Button, { variant: "soft", size: "sm", component: location.tms_link ? "a" : "button", href: location.tms_link
331
+ ? location.tms_link.match(/^https?:\/{2}/)
332
+ ? location.tms_link
333
+ : `//${location.tms_link}`
334
+ : "", startDecorator: _jsx("i", { className: "fa-solid fa-arrow-up-right-from-square" }), target: "_blank", rel: "noopener noreferrer", sx: {
335
+ mr: -1,
336
+ height: "100%",
337
+ textDecoration: "none!important",
338
+ }, children: "GO" }) })] }), _jsxs(FormControl, { sx: {
339
+ flex: 1,
340
+ }, children: [_jsx(FormLabel, { children: "Channel" }), _jsx(Select, { disabled: readOnly, size: "sm", defaultValue: location.scheduling_channel, onChange: (_e, value) => {
341
+ setLocation({ ...location, scheduling_channel: value || "" });
342
+ }, slotProps: {
343
+ listbox: {
344
+ sx: {
345
+ zIndex: (theme) => theme.zIndex.modal,
346
+ },
347
+ },
348
+ }, children: [
349
+ { label: "None", value: "" },
350
+ { label: "Email", value: "email" },
351
+ { label: "Call", value: "call" },
352
+ { label: "Portal", value: "portal" },
353
+ { label: "Customer", value: "customer" },
354
+ ].map((v) => (_jsx(Option, { value: v.value, children: v.label }, v.value))) }), _jsx(FormHelperText, { children: " " })] }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", children: [_jsxs(FormControl, { sx: {
355
+ flex: 1,
356
+ }, children: [_jsx(FormLabel, { children: "Prev. Appts." }), _jsx(Textarea, { readOnly: readOnly, maxRows: 4, minRows: 4, onChange: (e) => {
357
+ setLocation({ ...location, prev_apts: e.target.value });
358
+ }, size: "sm", value: location.prev_apts || "" })] }), _jsxs(FormControl, { sx: {
359
+ flex: 1,
360
+ }, children: [_jsx(FormLabel, { children: "Location Notes" }), _jsx(Textarea, { readOnly: readOnly, maxRows: 4, minRows: 4, onChange: (e) => {
361
+ setLocation({ ...location, notes: e.target.value });
362
+ }, size: "sm", value: location.notes || "" })] })] }), _jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 0.5, flex: "1 1 100%", children: [_jsxs(FormControl, { sx: {
363
+ flex: 1,
364
+ }, children: [_jsx(FormLabel, { children: "Location Scheduling Notes" }), _jsx(Textarea, { readOnly: readOnly, maxRows: 4, minRows: 4, onChange: (e) => {
365
+ setLocation({
366
+ ...location,
367
+ scheduling_notes: e.target.value,
368
+ });
369
+ }, size: "sm", value: location.scheduling_notes || "" })] }), _jsxs(FormControl, { sx: {
370
+ flex: 1,
371
+ }, children: [_jsx(FormLabel, { children: "Driver Instructions" }), _jsx(Textarea, { readOnly: readOnly, maxRows: 4, minRows: 4, onChange: (e) => {
372
+ setLocation({
373
+ ...location,
374
+ driver_instructions: e.target.value,
375
+ });
376
+ }, size: "sm", value: location.driver_instructions || "" })] })] })] }));
670
377
  }
671
378
  //# sourceMappingURL=locationFormSalesMain.js.map