@nerdjs/sales-kit 2.4.16 → 2.4.18
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/entities/load/load.d.ts +2 -2
- package/dist/entities/load/load.js +1 -1
- package/dist/entities/load/load.js.map +1 -1
- package/dist/entities/shipcon/helper.d.ts +1 -0
- package/dist/entities/shipcon/helper.js +16 -0
- package/dist/entities/shipcon/helper.js.map +1 -1
- package/dist/hooks/lep/constants.d.ts +2 -0
- package/dist/hooks/lep/constants.js +74 -0
- package/dist/hooks/lep/constants.js.map +1 -1
- package/dist/hooks/lep/lepActionBar.d.ts +2 -1
- package/dist/hooks/lep/lepActionBar.js +32 -4
- package/dist/hooks/lep/lepActionBar.js.map +1 -1
- package/dist/hooks/lep/loadEditPanel.d.ts +2 -1
- package/dist/hooks/lep/loadEditPanel.js +2 -2
- package/dist/hooks/lep/loadEditPanel.js.map +1 -1
- package/dist/hooks/locationsForm/index.d.ts +2 -2
- package/dist/hooks/locationsForm/index.js +2 -2
- package/dist/hooks/locationsForm/index.js.map +1 -1
- package/dist/hooks/locationsForm/{locationsForm.js → locationForm.js} +1 -1
- package/dist/hooks/locationsForm/locationForm.js.map +1 -0
- package/dist/hooks/locationsForm/locationFormSales/archerLocationAutocomplete.d.ts +6 -0
- package/dist/hooks/locationsForm/locationFormSales/archerLocationAutocomplete.js +41 -0
- package/dist/hooks/locationsForm/locationFormSales/archerLocationAutocomplete.js.map +1 -0
- package/dist/hooks/locationsForm/locationFormSales/index.d.ts +5 -0
- package/dist/hooks/locationsForm/locationFormSales/index.js +6 -0
- package/dist/hooks/locationsForm/locationFormSales/index.js.map +1 -0
- package/dist/hooks/locationsForm/locationFormSales/locationAccessorialsList.d.ts +8 -0
- package/dist/hooks/locationsForm/locationFormSales/locationAccessorialsList.js +181 -0
- package/dist/hooks/locationsForm/locationFormSales/locationAccessorialsList.js.map +1 -0
- package/dist/hooks/locationsForm/locationFormSales/locationDocumentsList.d.ts +8 -0
- package/dist/hooks/locationsForm/locationFormSales/locationDocumentsList.js +149 -0
- package/dist/hooks/locationsForm/locationFormSales/locationDocumentsList.js.map +1 -0
- package/dist/hooks/locationsForm/locationFormSales/locationFormSales.d.ts +19 -0
- package/dist/hooks/locationsForm/locationFormSales/locationFormSales.js +119 -0
- package/dist/hooks/locationsForm/locationFormSales/locationFormSales.js.map +1 -0
- package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.d.ts +26 -0
- package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.js +671 -0
- package/dist/hooks/locationsForm/locationFormSales/locationFormSalesMain.js.map +1 -0
- package/dist/hooks/quote/helpers.js +1 -1
- package/dist/hooks/quote/helpers.js.map +1 -1
- package/dist/locales/en/components.json +2 -1
- package/dist/locales/index.d.ts +1 -0
- package/dist/redux/api/salesApi.d.ts +1 -1
- package/dist/redux/apiTender/apiTenderEndpoints.d.ts +10 -10
- package/dist/redux/appointmentArrival/appointmentArrivalEndpoints.d.ts +12 -12
- package/dist/redux/appointmentIssue/appointmentIssueEndpoints.d.ts +10 -10
- package/dist/redux/appointmentIssueCategory/appointmentIssueCategoryEndpoints.d.ts +11 -11
- package/dist/redux/appointmentIssueSubcategory/appointmentIssueSubcategoryEndpoints.d.ts +10 -10
- package/dist/redux/appointmentNote/appointmentNoteEndpoints.d.ts +10 -10
- package/dist/redux/appointmentNoteType/appointmentNoteTypeEndpoints.d.ts +10 -10
- package/dist/redux/appointmentTrip/appointmentTripEndpoints.d.ts +10 -10
- package/dist/redux/archerFile/archerFileEndpoints.d.ts +13 -13
- package/dist/redux/area/areaEndpoints.d.ts +9 -9
- package/dist/redux/asset/assetEndpoints.d.ts +12 -12
- package/dist/redux/billingKickback/billingKickbackEndpoints.d.ts +11 -11
- package/dist/redux/billingKickbackResponse/billingKickbackResponseEndpoints.d.ts +10 -10
- package/dist/redux/billingKickbackResponseAccessorial/billingKickbackResponseAccessorialEndpoints.d.ts +10 -10
- package/dist/redux/billingMessage/billingMessageEndpoints.d.ts +9 -9
- package/dist/redux/billingNote/billingNoteEndpoints.d.ts +10 -10
- package/dist/redux/cargoConsolidation/cargoConsolidationEndpoints.d.ts +19 -19
- package/dist/redux/cargoConsolidationCommodityPiece/cargoConsolidationCommodityPieceEndpoints.d.ts +10 -10
- package/dist/redux/carrier/carrierEndpoints.d.ts +19 -19
- package/dist/redux/carrierInsurance/carrierInsuranceEndpoints.d.ts +10 -10
- package/dist/redux/carrierName/carrierNameEndpoints.d.ts +12 -12
- package/dist/redux/carrierPayContract/carrierPayContractEndpoints.d.ts +11 -11
- package/dist/redux/carrierTender/carrierTenderEndpoints.d.ts +10 -10
- package/dist/redux/carrierTenderAccessorial/carrierTenderAccessorialEndpoints.d.ts +10 -10
- package/dist/redux/carrierTenderDeduction/carrierTenderDeductionEndpoints.d.ts +10 -10
- package/dist/redux/carrierTenderEdge/carrierTenderEdgeEndpoints.d.ts +9 -9
- package/dist/redux/carrierTenderV1/carrierTenderV1Endpoints.d.ts +20 -20
- package/dist/redux/claim/claimEndpoints.d.ts +16 -16
- package/dist/redux/claimStatus/claimStatusEndpoints.d.ts +9 -9
- package/dist/redux/commodity/commodityEndpoints.d.ts +10 -10
- package/dist/redux/commodityV1/commodityV1Endpoints.d.ts +11 -11
- package/dist/redux/companyLocation/companyLocationEndpoints.d.ts +10 -10
- package/dist/redux/contact/contactEndpoints.d.ts +10 -10
- package/dist/redux/contract/contractEndpoints.d.ts +10 -10
- package/dist/redux/contractsRecord/contractsRecordEndpoints.d.ts +12 -12
- package/dist/redux/creditTerm/creditTermEndpoints.d.ts +9 -9
- package/dist/redux/customer/customerEndpoints.d.ts +18 -18
- package/dist/redux/customerContract/customerContractEndpoints.d.ts +10 -10
- package/dist/redux/customersAccessorial/customersAccessorialEndpoints.d.ts +9 -9
- package/dist/redux/deduction/deductionEndpoints.d.ts +9 -9
- package/dist/redux/departmentPhone/departmentPhoneEndpoints.d.ts +10 -10
- package/dist/redux/dispatch/dispatchEndpoints.d.ts +10 -10
- package/dist/redux/driver/driverEndpoints.d.ts +10 -10
- package/dist/redux/driverName/driverNameEndpoints.d.ts +9 -9
- package/dist/redux/driverV1/driverV1Endpoints.d.ts +9 -9
- package/dist/redux/ediAccount/ediAccountEndpoints.d.ts +10 -10
- package/dist/redux/ediLoadTender/ediLoadTenderEndpoints.d.ts +10 -10
- package/dist/redux/employeeName/employeeNameEndpoints.d.ts +9 -9
- package/dist/redux/flag/flagEndpoints.d.ts +9 -9
- package/dist/redux/generalLedgerAccount/generalLedgerAccountEndpoints.d.ts +10 -10
- package/dist/redux/genericTender/genericTenderEndpoints.d.ts +12 -12
- package/dist/redux/holiday/holidayEndpoints.d.ts +10 -10
- package/dist/redux/invoice/invoiceEndpoints.d.ts +10 -10
- package/dist/redux/invoiceAdjustment/invoiceAdjustmentEndpoints.d.ts +10 -10
- package/dist/redux/invoiceV1/invoiceV1Endpoints.d.ts +11 -11
- package/dist/redux/load/loadEndpoints.d.ts +12 -12
- package/dist/redux/loadAdjustment/loadAdjustmentEndpoints.d.ts +10 -10
- package/dist/redux/loadAdjustmentV1/loadAdjustmentV1Endpoints.d.ts +10 -10
- package/dist/redux/loadTender/loadTenderEndpoints.d.ts +12 -12
- package/dist/redux/loadTenderView/loadTenderViewEndpoints.d.ts +10 -10
- package/dist/redux/loadV1/loadV1Endpoints.d.ts +58 -58
- package/dist/redux/location/locationEndpoints.d.ts +16 -15
- package/dist/redux/location/locationEndpoints.js +7 -1
- package/dist/redux/location/locationEndpoints.js.map +1 -1
- package/dist/redux/locationV1/locationV1Endpoints.d.ts +19 -19
- package/dist/redux/manualCheckCall/manualCheckCallEndpoints.d.ts +10 -10
- package/dist/redux/mapUpdate/mapUpdateEndpoints.d.ts +3 -3
- package/dist/redux/nmfcClass/nmfcClassEndpoints.d.ts +9 -9
- package/dist/redux/node/nodeEndpoints.d.ts +8 -8
- package/dist/redux/nodeName/nodeNameEndpoints.d.ts +10 -10
- package/dist/redux/nodeType/nodeTypeEndpoints.d.ts +8 -8
- package/dist/redux/nodeTypeNode/nodeTypeNodeEndpoints.d.ts +8 -8
- package/dist/redux/notification/notificationEndpoints.d.ts +13 -13
- package/dist/redux/otrDispatch/otrDispatchEndpoints.d.ts +23 -23
- package/dist/redux/person/personEndpoints.d.ts +12 -12
- package/dist/redux/personName/personNameEndpoints.d.ts +10 -10
- package/dist/redux/position/positionEndpoints.d.ts +10 -10
- package/dist/redux/possibleIssueItem/possibleIssueItemEndpoints.d.ts +10 -10
- package/dist/redux/quote/quoteCustomerPortalEndpoints.d.ts +15 -15
- package/dist/redux/quote/quoteHooks.d.ts +2 -2
- package/dist/redux/quote/quoteSalesEndpoints.d.ts +16 -16
- package/dist/redux/quoteAccessorial/quoteAccessorialEndpoints.d.ts +9 -9
- package/dist/redux/quoteAccessorialV1/quoteAccessorialV1Endpoints.d.ts +10 -10
- package/dist/redux/rateReview/rateReviewEndpoints.d.ts +10 -10
- package/dist/redux/rejectionReason/rejectionReasonEndpoints.d.ts +9 -9
- package/dist/redux/relayCode/relayCodeEndpoints.d.ts +11 -11
- package/dist/redux/shipConDispatch/shipConDispatchEndpoints.d.ts +11 -11
- package/dist/redux/shipConETA/shipConETAEndpoints.d.ts +10 -10
- package/dist/redux/shipcon/shipconEndpoints.d.ts +11 -11
- package/dist/redux/shipconV1/shipconV1Endpoints.d.ts +18 -18
- package/dist/redux/tender/tenderEndpoints.d.ts +9 -9
- package/dist/redux/trailerAvailability/customerEndpoints.d.ts +4 -4
- package/dist/redux/trailerCode/trailerCodeEndpoints.d.ts +9 -9
- package/dist/redux/unitV1/unitV1Endpoints.d.ts +9 -9
- package/dist/redux/userNoteV1/userNoteV1Endpoints.d.ts +10 -10
- package/package.json +1 -1
- package/dist/hooks/locationsForm/locationsForm.js.map +0 -1
- /package/dist/hooks/locationsForm/{locationsForm.d.ts → locationForm.d.ts} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Autocomplete, AutocompleteOption, Box, CircularProgress, Typography, } from "@mui/joy";
|
|
3
|
+
import { useMemo, useState, } from "react";
|
|
4
|
+
import { useLazySearchActiveLocationsQuery } from "../../../redux";
|
|
5
|
+
import { unstable_debounce as debounce } from "@mui/utils";
|
|
6
|
+
export const ArcherLocationAutocomplete = ({ onChange, autoCompleteProps, }) => {
|
|
7
|
+
const [locationInputValue, setLocationInputValue] = useState("");
|
|
8
|
+
const [searchLocation, { data: locationSuggestions, isFetching }] = useLazySearchActiveLocationsQuery();
|
|
9
|
+
const handleValueChange = (_, newValue) => {
|
|
10
|
+
onChange(newValue);
|
|
11
|
+
};
|
|
12
|
+
const debouncedChangeHandler = useMemo(() => debounce(searchLocation, 500), []);
|
|
13
|
+
return (_jsx(_Fragment, { children: _jsx(Autocomplete, { size: "sm", ...autoCompleteProps, slotProps: {
|
|
14
|
+
...autoCompleteProps?.slotProps,
|
|
15
|
+
listbox: {
|
|
16
|
+
...autoCompleteProps?.slotProps?.listbox,
|
|
17
|
+
sx: {
|
|
18
|
+
zIndex: (theme) => theme.zIndex.modal,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
}, options: [...(locationSuggestions ?? [])], filterOptions: (x) => x, onChange: handleValueChange, inputValue: locationInputValue, onInputChange: (_e, v) => {
|
|
22
|
+
setLocationInputValue(v);
|
|
23
|
+
if (v.length >= 3)
|
|
24
|
+
debouncedChangeHandler(v);
|
|
25
|
+
}, getOptionLabel: (option) => {
|
|
26
|
+
return option.name || "";
|
|
27
|
+
}, endDecorator: isFetching ? (_jsx(CircularProgress, { sx: {
|
|
28
|
+
"--CircularProgress-size": "18px",
|
|
29
|
+
"--CircularProgress-trackThickness": "3px",
|
|
30
|
+
"--CircularProgress-progressThickness": "3px",
|
|
31
|
+
} })) : null, renderOption: (props, c) => typeof c !== "string" ? (_jsx(LocationOption, { props: props, c: c }, c.id)) : (c) }) }));
|
|
32
|
+
};
|
|
33
|
+
const LocationOption = (params) => {
|
|
34
|
+
const { c, props } = params;
|
|
35
|
+
return (_jsx(AutocompleteOption, { ...props, sx: {
|
|
36
|
+
"&.Mui-focusVisible": {
|
|
37
|
+
outline: "none",
|
|
38
|
+
},
|
|
39
|
+
}, children: _jsxs(Box, { children: [_jsx(Typography, { level: "body-sm", color: "primary", children: c.name }), _jsx(Typography, { level: "body-xs", children: c.line1 }), _jsx(Box, { sx: { display: "flex", gap: 1, alignItems: "center" }, children: _jsx(Typography, { level: "body-xs", children: `${c.city}, ${c.state} ${c.zip}` }) })] }) }));
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=archerLocationAutocomplete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archerLocationAutocomplete.js","sourceRoot":"","sources":["../../../../src/hooks/locationsForm/locationFormSales/archerLocationAutocomplete.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAElB,GAAG,EACH,gBAAgB,EAChB,UAAU,GACX,MAAM,UAAU,CAAC;AAElB,OAAO,EAIL,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EACzC,QAAQ,EACR,iBAAiB,GAOlB,EAAE,EAAE;IACH,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACjE,MAAM,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,UAAU,EAAE,CAAC,GAC/D,iCAAiC,EAAE,CAAC;IAEtC,MAAM,iBAAiB,GAAG,CACxB,CAAiC,EACjC,QAAkC,EAClC,EAAE;QACF,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrB,CAAC,CAA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,KAAK,EAAE,CAAC,EAAE,CAAC,IAAO,CAAC,CAAC,EAAE,CAAI,CAClD,CAAC,CAAC,CAAC,CACF,CAAC,CACF,GAEH,GACD,CACJ,CAAC;AACJ,CAAC,CAAC;AAOF,MAAM,cAAc,GAAG,CAAC,MAA2B,EAAgB,EAAE;IACnE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAE5B,OAAO,CACL,KAAC,kBAAkB,OACb,KAAK,EACT,EAAE,EAAE;YACF,oBAAoB,EAAE;gBACpB,OAAO,EAAE,MAAM;aAChB;SACF,YAED,MAAC,GAAG,eACF,KAAC,UAAU,IAAC,KAAK,EAAC,SAAS,EAAC,KAAK,EAAC,SAAS,YACxC,CAAC,CAAC,IAAI,GACI,EACb,KAAC,UAAU,IAAC,KAAK,EAAC,SAAS,YAAE,CAAC,CAAC,KAAK,GAAc,EAClD,KAAC,GAAG,IAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,YACxD,KAAC,UAAU,IAAC,KAAK,EAAC,SAAS,YAAE,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,EAAE,GAAc,GACvE,IACF,GACa,CACtB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/locationsForm/locationFormSales/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Box } from "@mui/joy";
|
|
3
|
+
import { NerdCurrencyFieldDataGridAdapter } from "@nerdjs/nerd-ui";
|
|
4
|
+
import { useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { useCreateLocationAccessorialV1Mutation, useDeleteLocationAccessorialsV1Mutation, useGetAccessorialsV1Query, useGetLocationAccessorialsV1Query, useUpdateLocationAccessorialsV1Mutation, } from "../../../redux/locationV1";
|
|
6
|
+
import { DateTime } from "luxon";
|
|
7
|
+
import { DataGridPremium, GridActionsCellItem, GridRowEditStopReasons, GridRowModes, } from "@mui/x-data-grid-premium";
|
|
8
|
+
import { usdFormatter } from "../../quote/constants";
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param root0
|
|
12
|
+
* @param root0.locationID
|
|
13
|
+
*/
|
|
14
|
+
export function LocationAccessorialsList({ locationID, }) {
|
|
15
|
+
const { data: _accessorials } = useGetAccessorialsV1Query();
|
|
16
|
+
const { data, isFetching } = useGetLocationAccessorialsV1Query({
|
|
17
|
+
id: locationID,
|
|
18
|
+
});
|
|
19
|
+
const [createLocationAccessorial] = useCreateLocationAccessorialV1Mutation();
|
|
20
|
+
const [updateLocationAccessorial] = useUpdateLocationAccessorialsV1Mutation();
|
|
21
|
+
const [deleteLocationAccessorial] = useDeleteLocationAccessorialsV1Mutation();
|
|
22
|
+
const [rows, setRows] = useState(data || []);
|
|
23
|
+
const [rowModesModel, setRowModesModel] = useState({});
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setRows(data || []);
|
|
26
|
+
}, [data]);
|
|
27
|
+
const handleEditClick = (id) => () => {
|
|
28
|
+
setRowModesModel({ ...rowModesModel, [id]: { mode: GridRowModes.Edit } });
|
|
29
|
+
};
|
|
30
|
+
const handleSaveClick = (id) => () => {
|
|
31
|
+
setRowModesModel({ ...rowModesModel, [id]: { mode: GridRowModes.View } });
|
|
32
|
+
};
|
|
33
|
+
const handleDeleteClick = (id) => () => {
|
|
34
|
+
deleteLocationAccessorial(Number(id));
|
|
35
|
+
};
|
|
36
|
+
const handleCancelClick = (id) => () => {
|
|
37
|
+
setRowModesModel({
|
|
38
|
+
...rowModesModel,
|
|
39
|
+
[id]: { mode: GridRowModes.View, ignoreModifications: true },
|
|
40
|
+
});
|
|
41
|
+
const editedRow = rows.find((row) => row.id === id);
|
|
42
|
+
if (editedRow?.isNew) {
|
|
43
|
+
setRows(rows.filter((row) => row.id !== id));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const processRowUpdate = (newRow) => {
|
|
47
|
+
const { isNew, ...row } = newRow;
|
|
48
|
+
if (isNew) {
|
|
49
|
+
createLocationAccessorial({ locationaccessorial: row });
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
updateLocationAccessorial({
|
|
53
|
+
id: row.id,
|
|
54
|
+
body: { locationaccessorial: row },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return row;
|
|
58
|
+
};
|
|
59
|
+
const handleRowEditStop = (params, event) => {
|
|
60
|
+
if (params.reason === GridRowEditStopReasons.rowFocusOut) {
|
|
61
|
+
event.defaultMuiPrevented = true;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const accessorials = useMemo(() => _accessorials?.map((a) => ({
|
|
65
|
+
value: a.id,
|
|
66
|
+
label: a.name,
|
|
67
|
+
})), [_accessorials]);
|
|
68
|
+
const columns = useMemo(() => [
|
|
69
|
+
{
|
|
70
|
+
field: "accessorial_id",
|
|
71
|
+
headerName: "Accessorial",
|
|
72
|
+
flex: 1,
|
|
73
|
+
editable: true,
|
|
74
|
+
type: "singleSelect",
|
|
75
|
+
valueOptions() {
|
|
76
|
+
return accessorials || [];
|
|
77
|
+
},
|
|
78
|
+
valueFormatter(params) {
|
|
79
|
+
return _accessorials?.find((a) => a.id == params.value)?.name || "";
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
field: "cost_amount",
|
|
84
|
+
headerName: "Amount",
|
|
85
|
+
type: "number",
|
|
86
|
+
flex: 1,
|
|
87
|
+
editable: true,
|
|
88
|
+
renderEditCell(params) {
|
|
89
|
+
return _jsx(NerdCurrencyFieldDataGridAdapter, { cellParams: params });
|
|
90
|
+
},
|
|
91
|
+
valueSetter(params) {
|
|
92
|
+
return {
|
|
93
|
+
...params.row,
|
|
94
|
+
cost_amount: params.value !== undefined ? params.value : 0,
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
renderCell(params) {
|
|
98
|
+
return usdFormatter.format(params.value);
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
field: "load_type",
|
|
103
|
+
headerName: "Load Type",
|
|
104
|
+
flex: 1,
|
|
105
|
+
editable: true,
|
|
106
|
+
type: "singleSelect",
|
|
107
|
+
valueOptions: [
|
|
108
|
+
{ value: "all", label: "All" },
|
|
109
|
+
{ value: "tl", label: "TL" },
|
|
110
|
+
{ value: "ltl", label: "LTL" },
|
|
111
|
+
],
|
|
112
|
+
valueFormatter(params) {
|
|
113
|
+
return (params.value.charAt(0).toUpperCase() + params.value.substring(1));
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
field: "contract",
|
|
118
|
+
headerName: "Contract",
|
|
119
|
+
type: "boolean",
|
|
120
|
+
flex: 1,
|
|
121
|
+
editable: true,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
field: "actions",
|
|
125
|
+
type: "actions",
|
|
126
|
+
headerName: "Actions",
|
|
127
|
+
width: 100,
|
|
128
|
+
cellClassName: "actions",
|
|
129
|
+
getActions: ({ id }) => {
|
|
130
|
+
const isInEditMode = rowModesModel[id]?.mode === GridRowModes.Edit;
|
|
131
|
+
if (isInEditMode) {
|
|
132
|
+
return [
|
|
133
|
+
_jsx(GridActionsCellItem, { icon: _jsx("i", { className: "fa-solid fa-floppy-disk" }), label: "Save", sx: {
|
|
134
|
+
color: "primary.main",
|
|
135
|
+
}, onClick: handleSaveClick(id) }, "save"),
|
|
136
|
+
_jsx(GridActionsCellItem, { icon: _jsx("i", { className: "fa-solid fa-circle-xmark" }), label: "Cancel", className: "textPrimary", onClick: handleCancelClick(id), color: "inherit" }, "cancel"),
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
return [
|
|
140
|
+
_jsx(GridActionsCellItem, { icon: _jsx("i", { className: "fa-solid fa-pen-to-square" }), label: "Edit", className: "textPrimary", onClick: handleEditClick(id), color: "inherit" }, "edit"),
|
|
141
|
+
_jsx(GridActionsCellItem, { icon: _jsx("i", { className: "fa-solid fa-trash" }), label: "Delete", onClick: handleDeleteClick(id), color: "inherit" }, "delete"),
|
|
142
|
+
];
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
], [_accessorials, rowModesModel]);
|
|
146
|
+
return (_jsx(DataGridPremium, { editMode: "row", density: "compact", rowModesModel: rowModesModel, processRowUpdate: processRowUpdate, onRowEditStop: handleRowEditStop, onRowModesModelChange: (v) => setRowModesModel(v), hideFooter: true, slots: {
|
|
147
|
+
toolbar: CustomToolbar,
|
|
148
|
+
}, slotProps: {
|
|
149
|
+
toolbar: { setRows, setRowModesModel, locationID },
|
|
150
|
+
}, loading: isFetching, rows: rows || [], columns: columns }));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
* @param props
|
|
155
|
+
* @returns {ReactElement} Custom toolbar for Datagrid
|
|
156
|
+
*/
|
|
157
|
+
function CustomToolbar(props) {
|
|
158
|
+
const { setRowModesModel, setRows, locationID } = props;
|
|
159
|
+
const handleClick = () => {
|
|
160
|
+
const id = DateTime.now().toMillis();
|
|
161
|
+
setRows((oldRows) => [
|
|
162
|
+
...oldRows,
|
|
163
|
+
{
|
|
164
|
+
id,
|
|
165
|
+
name: "",
|
|
166
|
+
accessorial_id: 0,
|
|
167
|
+
contract: false,
|
|
168
|
+
cost_amount: 0,
|
|
169
|
+
load_type: "all",
|
|
170
|
+
location_id: locationID,
|
|
171
|
+
isNew: true,
|
|
172
|
+
},
|
|
173
|
+
]);
|
|
174
|
+
setRowModesModel((oldModel) => ({
|
|
175
|
+
...oldModel,
|
|
176
|
+
[id]: { mode: GridRowModes.Edit, fieldToFocus: "accessorial_id" },
|
|
177
|
+
}));
|
|
178
|
+
};
|
|
179
|
+
return (_jsx(_Fragment, { children: _jsx(Box, { sx: { display: "flex", gap: 1, p: 1, position: "relative" }, children: _jsx(Button, { variant: "soft", size: "sm", onClick: handleClick, children: "+ Accessorial" }) }) }));
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=locationAccessorialsList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locationAccessorialsList.js","sourceRoot":"","sources":["../../../../src/hooks/locationsForm/locationFormSales/locationAccessorialsList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAgB,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,EACL,sCAAsC,EACtC,uCAAuC,EACvC,yBAAyB,EACzB,iCAAiC,EACjC,uCAAuC,GACxC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EACL,eAAe,EACf,mBAAmB,EAInB,sBAAsB,EAGtB,YAAY,GAKb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,EACvC,UAAU,GAGX;IACC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,yBAAyB,EAAE,CAAC;IAC5D,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,iCAAiC,CAAC;QAC7D,EAAE,EAAE,UAAU;KACf,CAAC,CAAC;IACH,MAAM,CAAC,yBAAyB,CAAC,GAAG,sCAAsC,EAAE,CAAC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F,CAAC,CAAC;QACH,gBAAgB,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC9B,GAAG,QAAQ;YACX,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,gBAAgB,EAAE;SAClE,CAAC,CAAC,CAAC;IACN,CAAC,CAAC;IACF,OAAO,CACL,4BACE,KAAC,GAAG,IAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,YAC9D,KAAC,MAAM,IAAC,OAAO,EAAC,MAAM,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,WAAW,8BAE5C,GACL,GACL,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Typography, Grid, CircularProgress, Modal, ModalDialog, Box, } from "@mui/joy";
|
|
3
|
+
import { NerdClickToCopy, NerdFileUpload, showNotification, useNerdConfirm, } from "@nerdjs/nerd-ui";
|
|
4
|
+
import { useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { useDispatch } from "react-redux";
|
|
6
|
+
import { DataGridPremium, GridActionsCellItem, } from "@mui/x-data-grid-premium";
|
|
7
|
+
import { useDeleteArcherFileMutation, useShareArcherFileMutation, useUploadArcherFileMutation, } from "../../../redux/archerFile";
|
|
8
|
+
import { Person } from "../../../entities";
|
|
9
|
+
import { useGetLocationFilesQuery, useGetPeopleQuery } from "../../../redux";
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param root0
|
|
13
|
+
* @param root0.locationID
|
|
14
|
+
*/
|
|
15
|
+
export function LocationDocumentsList({ locationID }) {
|
|
16
|
+
const confirm = useNerdConfirm();
|
|
17
|
+
const [shareFileAction, { isLoading }] = useShareArcherFileMutation();
|
|
18
|
+
const [deleteFile] = useDeleteArcherFileMutation();
|
|
19
|
+
const { data: rows, isLoading: loadingRows } = useGetLocationFilesQuery(locationID);
|
|
20
|
+
const [iframe, setIframe] = useState("");
|
|
21
|
+
const [iframeLoading, setIframeLoading] = useState(true);
|
|
22
|
+
const [shareFile, setShareFile] = useState(null);
|
|
23
|
+
const params = {
|
|
24
|
+
filters: JSON.stringify([
|
|
25
|
+
{ name: "people.company_id", comparison: "eq", value: 1 },
|
|
26
|
+
{ name: "people.active", comparison: "eq", value: true },
|
|
27
|
+
]),
|
|
28
|
+
};
|
|
29
|
+
const { data: _personNames } = useGetPeopleQuery(params);
|
|
30
|
+
const columns = useMemo(() => [
|
|
31
|
+
{ field: "name", headerName: "File", flex: 1 },
|
|
32
|
+
{
|
|
33
|
+
field: "description",
|
|
34
|
+
headerName: "Type",
|
|
35
|
+
flex: 1,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
field: "person_id",
|
|
39
|
+
headerName: "Uploaded By",
|
|
40
|
+
flex: 1,
|
|
41
|
+
renderCell(params) {
|
|
42
|
+
return _personNames?.entities[params.value]
|
|
43
|
+
? new Person(_personNames?.entities[params.value]).name()
|
|
44
|
+
: "";
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
field: "actions",
|
|
49
|
+
type: "actions",
|
|
50
|
+
headerName: "Actions",
|
|
51
|
+
getActions: ({ row }) => [
|
|
52
|
+
_jsx(GridActionsCellItem, { icon: _jsx("i", { className: "fa-solid fa-eye" }), label: `View File`, onClick: () => {
|
|
53
|
+
setIframe(`${window._APP_CONFIG?.api?.endpoint}/v3/file-service/files/${row.id}?inline=1`);
|
|
54
|
+
} }, "view"),
|
|
55
|
+
_jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-download" }), label: `Download File`, onClick: () => {
|
|
56
|
+
const link = document.createElement("a");
|
|
57
|
+
link.href = `${window._APP_CONFIG?.api?.endpoint}/v3/file-service/files/${row.id}`;
|
|
58
|
+
link.click();
|
|
59
|
+
link.remove();
|
|
60
|
+
} }, "download"),
|
|
61
|
+
_jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-trash" }), label: `Delete File`, onClick: () => {
|
|
62
|
+
confirm.setOpen({
|
|
63
|
+
onConfirm() {
|
|
64
|
+
deleteFile(row.id);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
} }, "delete"),
|
|
68
|
+
_jsx(GridActionsCellItem, { showInMenu: true, icon: _jsx("i", { className: "fa-solid fa-share" }), label: `Share File`, onClick: () => {
|
|
69
|
+
setShareFile(row);
|
|
70
|
+
} }, "share"),
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
], [_personNames]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (rows && shareFile) {
|
|
76
|
+
setShareFile(rows.find((r) => r.id === shareFile.id) || null);
|
|
77
|
+
}
|
|
78
|
+
else
|
|
79
|
+
setShareFile(null);
|
|
80
|
+
}, [rows]);
|
|
81
|
+
const handleClose = () => {
|
|
82
|
+
setIframe("");
|
|
83
|
+
setIframeLoading(true);
|
|
84
|
+
};
|
|
85
|
+
return (_jsxs(_Fragment, { children: [_jsx(DataGridPremium, { hideFooter: true, loading: loadingRows, rows: rows || [], columns: columns, slots: {
|
|
86
|
+
toolbar: DocumentListCustomToolbar,
|
|
87
|
+
}, slotProps: {
|
|
88
|
+
toolbar: {
|
|
89
|
+
locationID,
|
|
90
|
+
},
|
|
91
|
+
} }), _jsx(Modal, { open: Boolean(iframe), onClose: handleClose, children: _jsxs(ModalDialog, { sx: {
|
|
92
|
+
width: { xs: "85vw", lg: "40vw" },
|
|
93
|
+
height: { xs: "55vh", lg: "70vh" },
|
|
94
|
+
}, children: [iframeLoading && (_jsx(Box, { sx: {
|
|
95
|
+
position: "absolute",
|
|
96
|
+
top: 0,
|
|
97
|
+
left: 0,
|
|
98
|
+
width: "100%",
|
|
99
|
+
height: "100%",
|
|
100
|
+
display: "flex",
|
|
101
|
+
alignItems: "center",
|
|
102
|
+
justifyContent: "center",
|
|
103
|
+
}, children: _jsx(CircularProgress, {}) })), _jsx("iframe", { style: {
|
|
104
|
+
opacity: iframeLoading ? 0 : 1,
|
|
105
|
+
border: "none",
|
|
106
|
+
height: "100%",
|
|
107
|
+
width: "100%",
|
|
108
|
+
}, src: iframe, onLoad: () => setIframeLoading(false) })] }) }), _jsx(Modal, { open: Boolean(shareFile), onClose: () => setShareFile(null), children: _jsx(ModalDialog, { sx: {
|
|
109
|
+
maxWidth: 400,
|
|
110
|
+
}, children: _jsx(Grid, { container: true, spacing: 1, children: shareFile?.token ? (_jsxs(_Fragment, { children: [_jsx(Grid, { xs: 12, children: _jsx(NerdClickToCopy, { typographyProps: {
|
|
111
|
+
sx: {
|
|
112
|
+
lineBreak: "anywhere",
|
|
113
|
+
},
|
|
114
|
+
}, children: `${window._APP_CONFIG?.api?.endpoint}${window._APP_CONFIG?.api?.routePrefix}/shared_files/${shareFile.id}?token=${shareFile.token}` }) }), _jsx(Grid, { xs: 12, children: _jsx(Button, { fullWidth: true, onClick: () => {
|
|
115
|
+
shareFileAction({ id: shareFile.id, share: false });
|
|
116
|
+
}, children: "Unshare" }) })] })) : (_jsxs(_Fragment, { children: [_jsx(Grid, { xs: 12, children: _jsx(Typography, { children: "By sharing this file it will be publicly viewable to people outside of the White Arrow organization. Do you wish to continue?" }) }), _jsx(Grid, { xs: 12, children: _jsx(Button, { loading: isLoading, fullWidth: true, onClick: () => {
|
|
117
|
+
if (shareFile?.id)
|
|
118
|
+
shareFileAction({ id: shareFile.id, share: true });
|
|
119
|
+
}, children: "Share" }) })] })) }) }) })] }));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* @param root0
|
|
124
|
+
* @param root0.locationID
|
|
125
|
+
*/
|
|
126
|
+
function DocumentListCustomToolbar({ locationID, }) {
|
|
127
|
+
const dispatch = useDispatch();
|
|
128
|
+
const [uploadFile] = useUploadArcherFileMutation();
|
|
129
|
+
const handleUpload = (file) => {
|
|
130
|
+
uploadFile({
|
|
131
|
+
file,
|
|
132
|
+
description: "Location Form",
|
|
133
|
+
modelID: locationID,
|
|
134
|
+
modelType: "Location",
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
return (_jsx(_Fragment, { children: _jsx(Box, { sx: { display: "flex", gap: 1, p: 1, position: "relative" }, children: _jsx(NerdFileUpload, { uploadFile: handleUpload, slotProps: {
|
|
138
|
+
root: {
|
|
139
|
+
variant: "soft",
|
|
140
|
+
size: "sm",
|
|
141
|
+
},
|
|
142
|
+
}, maxSize: 30000000, onError: (error) => dispatch(showNotification({
|
|
143
|
+
severity: "danger",
|
|
144
|
+
title: error.message,
|
|
145
|
+
autohide: true,
|
|
146
|
+
variant: "non-intrusive",
|
|
147
|
+
})) }) }) }));
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=locationDocumentsList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locationDocumentsList.js","sourceRoot":"","sources":["../../../../src/hooks/locationsForm/locationFormSales/locationDocumentsList.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,GAAG,GACJ,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAgB,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,eAAe,EACf,mBAAmB,GAEpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AACnC,OA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AAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,YAC9D,KAAC,cAAc,IACb,UAAU,EAAE,YAAY,EACxB,SAAS,EAAE;oBACT,IAAI,EAAE;wBACJ,OAAO,EAAE,MAAM;wBACf,IAAI,EAAE,IAAI;qBACX;iBACF,EACD,OAAO,EAAE,QAAQ,EACjB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,QAAQ,CACN,gBAAgB,CAAC;oBACf,QAAQ,EAAE,QAAQ;oBAClB,KAAK,EAAE,KAAK,CAAC,OAAO;oBACpB,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,eAAe;iBACzB,CAAC,CACH,GAEH,GACE,GACL,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import Location_Entity from "../../../entities/location/location";
|
|
4
|
+
import { LocationV1_Entity } from "../../../entities/locationV1";
|
|
5
|
+
interface LocationFormSalesProps {
|
|
6
|
+
onCreateLocation: (location: LocationV1_Entity) => void;
|
|
7
|
+
open: boolean;
|
|
8
|
+
place: Location_Entity | google.maps.GeocoderResult | undefined;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
onSaveLocation?: (location: LocationV1_Entity) => void;
|
|
11
|
+
onCompare?: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {LocationFormSalesProps} props props
|
|
16
|
+
* @returns {ReactElement} LocationForm
|
|
17
|
+
*/
|
|
18
|
+
export declare function LocationFormSales({ onCreateLocation, open, place, onClose, onCompare, }: LocationFormSalesProps): ReactElement;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Typography, Modal, ModalDialog, Tabs, TabList, tabClasses, Tab, TabPanel, Box, useTheme, IconButton, Tooltip, } from "@mui/joy";
|
|
3
|
+
import { NerdDraggableDialog } from "@nerdjs/nerd-ui";
|
|
4
|
+
import { useEffect, useMemo, useState, } from "react";
|
|
5
|
+
import salesKitI18n from "../../../i18n";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
import { locationEntityTypeGuard, } from "../../../entities/location/location";
|
|
8
|
+
import { useCreateLocationV1Mutation, useGetLocationV1Query, } from "../../../redux/locationV1";
|
|
9
|
+
import { useMediaQuery } from "@mui/system";
|
|
10
|
+
import { LocationFormSalesMain } from "./locationFormSalesMain";
|
|
11
|
+
import { LocationAccessorialsList } from "./locationAccessorialsList";
|
|
12
|
+
import { LocationDocumentsList } from "./locationDocumentsList";
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {LocationFormSalesProps} props props
|
|
16
|
+
* @returns {ReactElement} LocationForm
|
|
17
|
+
*/
|
|
18
|
+
export function LocationFormSales({ onCreateLocation, open, place, onClose, onCompare, }) {
|
|
19
|
+
const { t } = useTranslation("common", { i18n: salesKitI18n });
|
|
20
|
+
const [createLocation] = useCreateLocationV1Mutation();
|
|
21
|
+
const { data } = useGetLocationV1Query(locationEntityTypeGuard(place) && place.id ? place.id : 0, { skip: locationEntityTypeGuard(place) && place.id ? false : true });
|
|
22
|
+
const [location, setLocation] = useState(data || {});
|
|
23
|
+
const [isValid, setIsValid] = useState(true);
|
|
24
|
+
const isCreateForm = useMemo(() => {
|
|
25
|
+
if (place && "id" in place && place.id) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
else
|
|
29
|
+
return true;
|
|
30
|
+
}, [place]);
|
|
31
|
+
const handleCreateLocation = () => {
|
|
32
|
+
createLocation(location)
|
|
33
|
+
.unwrap()
|
|
34
|
+
.then((l) => {
|
|
35
|
+
onCreateLocation(l);
|
|
36
|
+
})
|
|
37
|
+
.catch(() => {
|
|
38
|
+
return;
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
setLocation(data || {});
|
|
43
|
+
}, [data]);
|
|
44
|
+
const handleClose = () => {
|
|
45
|
+
setLocation({});
|
|
46
|
+
onClose();
|
|
47
|
+
};
|
|
48
|
+
return (_jsx(Wrapper, { handleClose: handleClose, open: open, children: _jsxs(Box, { display: "flex", flexDirection: "column", height: "100%", children: [_jsxs(Box, { id: "draggable-title", sx: {
|
|
49
|
+
display: "flex",
|
|
50
|
+
cursor: "move",
|
|
51
|
+
alignItems: "center",
|
|
52
|
+
p: 0.5,
|
|
53
|
+
}, children: [_jsx(Typography, { level: "h4", children: location?.id ? t("Edit Location") : t("New Location") }), onCompare ? (_jsx(Tooltip, { title: t("components:lepShipcons.compareWith"), size: "sm", children: _jsx(IconButton, { id: "cancel-drag", color: "primary", sx: {
|
|
54
|
+
ml: "auto",
|
|
55
|
+
}, size: "sm", onClick: onCompare, children: _jsx("i", { className: "fa-solid fa-rectangle-vertical-history" }) }) })) : null] }), _jsx(Box, { id: "draggable-content", sx: {
|
|
56
|
+
overflow: "auto",
|
|
57
|
+
height: "100%",
|
|
58
|
+
}, children: _jsxs(Tabs, { defaultValue: 0, sx: {
|
|
59
|
+
bgcolor: "transparent",
|
|
60
|
+
overflowY: "auto",
|
|
61
|
+
overflowX: "hidden",
|
|
62
|
+
height: "100%",
|
|
63
|
+
}, size: "sm", children: [_jsxs(TabList, { size: "sm", sx: {
|
|
64
|
+
p: 0.5,
|
|
65
|
+
gap: 0.5,
|
|
66
|
+
borderRadius: "xl",
|
|
67
|
+
bgcolor: "background.level1",
|
|
68
|
+
[`& .${tabClasses.root}[aria-selected="true"]`]: {
|
|
69
|
+
boxShadow: "sm",
|
|
70
|
+
bgcolor: "background.surface",
|
|
71
|
+
},
|
|
72
|
+
}, children: [_jsx(Tab, { disableIndicator: true, children: "Main" }), !isCreateForm ? (_jsxs(_Fragment, { children: [_jsx(Tab, { disableIndicator: true, children: "Accessorials" }), _jsx(Tab, { disableIndicator: true, children: "Documents" })] })) : null] }), _jsx(TabPanel, { value: 0, sx: {
|
|
73
|
+
overflow: "auto",
|
|
74
|
+
}, children: _jsx(LocationFormSalesMain, { value: location, onChange: (location) => setLocation(location), place: place, onValidate: (validationObject) => {
|
|
75
|
+
const obj = { ...validationObject };
|
|
76
|
+
delete obj.phone;
|
|
77
|
+
setIsValid(Object.values(obj).every(Boolean) ? true : false);
|
|
78
|
+
} }) }), place && "id" in place && place.id ? (_jsxs(_Fragment, { children: [_jsx(TabPanel, { value: 1, sx: {
|
|
79
|
+
overflow: "auto",
|
|
80
|
+
height: "100%",
|
|
81
|
+
}, children: _jsx(Box, { sx: {
|
|
82
|
+
height: "100%",
|
|
83
|
+
}, children: _jsx(LocationAccessorialsList, { locationID: place.id }) }) }), _jsx(TabPanel, { value: 2, sx: {
|
|
84
|
+
overflow: "auto",
|
|
85
|
+
height: "100%",
|
|
86
|
+
}, children: _jsx(Box, { sx: {
|
|
87
|
+
height: "100%",
|
|
88
|
+
}, children: _jsx(LocationDocumentsList, { locationID: place.id }) }) })] })) : null] }) }), _jsxs(Box, { sx: {
|
|
89
|
+
display: "flex",
|
|
90
|
+
pt: 2,
|
|
91
|
+
gap: 1,
|
|
92
|
+
justifyContent: "flex-end",
|
|
93
|
+
}, children: [_jsx(Button, { variant: "soft", color: "neutral", onClick: () => {
|
|
94
|
+
handleClose();
|
|
95
|
+
}, children: !isCreateForm ? t("Close") : t("Cancel") }), isCreateForm ? (_jsx(Button, { onClick: () => {
|
|
96
|
+
handleCreateLocation();
|
|
97
|
+
handleClose();
|
|
98
|
+
}, disabled: !isValid, children: t("Create") })) : null] })] }) }));
|
|
99
|
+
}
|
|
100
|
+
const Wrapper = ({ children, open, handleClose, }) => {
|
|
101
|
+
const theme = useTheme();
|
|
102
|
+
const matches = useMediaQuery(theme.breakpoints.down("md"));
|
|
103
|
+
if (matches)
|
|
104
|
+
return (_jsx(Modal, { open: open, onClose: handleClose, children: _jsx(ModalDialog, { layout: "fullscreen", children: children }) }));
|
|
105
|
+
else if (open)
|
|
106
|
+
return (_jsx(NerdDraggableDialog, { draggableProps: {
|
|
107
|
+
handle: "#draggable-title",
|
|
108
|
+
cancel: "#draggable-content, #cancel-drag",
|
|
109
|
+
}, resizable: true, initialHeight: 820, initialWidth: 820, resizableProps: {
|
|
110
|
+
minConstraints: [300, 300],
|
|
111
|
+
}, sheetProps: {
|
|
112
|
+
sx: {
|
|
113
|
+
p: 1,
|
|
114
|
+
},
|
|
115
|
+
}, children: children }));
|
|
116
|
+
else
|
|
117
|
+
return _jsx(_Fragment, {});
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=locationFormSales.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locationFormSales.js","sourceRoot":"","sources":["../../../../src/hooks/locationsForm/locationFormSales/locationFormSales.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,UAAU,EACV,KAAK,EACL,WAAW,EACX,IAAI,EACJ,OAAO,EACP,UAAU,EACV,GAAG,EACH,QAAQ,EACR,GAAG,EACH,QAAQ,EACR,UAAU,EACV,OAAO,GACR,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAGL,SAAS,EACT,OAAO,EACP,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAwB,EACtB,uBAAuB,GACxB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EA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,CAAC,CAAC,IAAI,IACJ,IACF,GACE,CACX,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,EACf,QAAQ,EACR,IAAI,EACJ,WAAW,GACmD,EAAE,EAAE;IAClE,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5D,IAAI,OAAO;QACT,OAAO,CACL,KAAC,KAAK,IAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,YACrC,KAAC,WAAW,IAAC,MAAM,EAAC,YAAY,YAAE,QAAQ,GAAe,GACnD,CACT,CAAC;SACC,IAAI,IAAI;QACX,OAAO,CACL,KAAC,mBAAmB,IAClB,cAAc,EAAE;gBACd,MAAM,EAAE,kBAAkB;gBAC1B,MAAM,EAAE,kCAAkC;aAC3C,EACD,SAAS,QACT,aAAa,EAAE,GAAG,EAClB,YAAY,EAAE,GAAG,EACjB,cAAc,EAAE;gBACd,cAAc,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;aAC3B,EACD,UAAU,EAAE;gBACV,EAAE,EAAE;oBACF,CAAC,EAAE,CAAC;iBACL;aACF,YAEA,QAAQ,GACW,CACvB,CAAC;;QACC,OAAO,mBAAK,CAAC;AACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="google.maps" />
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { LocationV1_Entity } from "../../../entities/locationV1";
|
|
4
|
+
import { Location_Entity } from "../../../entities";
|
|
5
|
+
type ValidationObject = {
|
|
6
|
+
name: boolean;
|
|
7
|
+
address: boolean;
|
|
8
|
+
phone: boolean;
|
|
9
|
+
openTime: boolean;
|
|
10
|
+
closeTime: boolean;
|
|
11
|
+
FCFSIN: boolean;
|
|
12
|
+
FCFSOUT: boolean;
|
|
13
|
+
};
|
|
14
|
+
interface LocationFormSalesMainProps {
|
|
15
|
+
place: Location_Entity | google.maps.GeocoderResult | undefined;
|
|
16
|
+
onValidate?: (validationObject: ValidationObject) => void;
|
|
17
|
+
value: Partial<LocationV1_Entity>;
|
|
18
|
+
onChange: (location: Partial<LocationV1_Entity>) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param {LocationFormSalesMainProps} props props
|
|
23
|
+
* @returns {ReactElement} locationsFormSalesMain
|
|
24
|
+
*/
|
|
25
|
+
export declare function LocationFormSalesMain({ place, onValidate, onChange: setLocation, value: location, }: LocationFormSalesMainProps): ReactElement;
|
|
26
|
+
export {};
|