@open-tender/cloud
Advanced tools
Comparing version 0.1.92 to 0.1.93
import { AppState } from '../../app'; | ||
import { GroupOrder, GroupOrderExpanded, GroupOrders, GroupOrdersExpanded, RequestError, RequestStatus } from '@open-tender/types'; | ||
import { GroupOrder, GroupOrderExpanded, GroupOrdersExpanded, RequestError, RequestStatus } from '@open-tender/types'; | ||
import { OrderState } from '../order'; | ||
@@ -67,3 +67,3 @@ export interface CustomerGroupOrdersState { | ||
} | null; | ||
export declare const updateCustomerGroupOrder: import("@reduxjs/toolkit").AsyncThunk<GroupOrders, { | ||
export declare const updateCustomerGroupOrder: import("@reduxjs/toolkit").AsyncThunk<void, { | ||
cartId: number; | ||
@@ -70,0 +70,0 @@ callback?: (() => void) | undefined; |
@@ -74,3 +74,2 @@ "use strict"; | ||
exports.updateCustomerGroupOrder = (0, toolkit_1.createAsyncThunk)(CustomerGroupOrdersActionType.UpdateCustomerGroupOrder, ({ cartId, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
var _b; | ||
try { | ||
@@ -87,10 +86,12 @@ const api = getState().config.api; | ||
dispatch((0, order_1.setRequestedAt)(response.requested_at)); | ||
const tz = utils_1.timezoneMap[(_b = revenueCenter === null || revenueCenter === void 0 ? void 0 : revenueCenter.timezone) !== null && _b !== void 0 ? _b : 'US/Central']; | ||
const requestedAtText = (0, utils_1.makeRequestedAtStr)(response.requested_at, tz); | ||
dispatch((0, order_1.addMessage)(`Requested time updated to ${requestedAtText}`)); | ||
if (revenueCenter) { | ||
const tz = utils_1.timezoneMap[revenueCenter.timezone]; | ||
const requestedAtText = (0, utils_1.makeRequestedAtStr)(response.requested_at, tz); | ||
dispatch((0, order_1.addMessage)(`Requested time updated to ${requestedAtText}`)); | ||
} | ||
} | ||
const payload = Object.assign(Object.assign({}, (0, groupOrder_1.makeCartPayload)(response)), { isCartOwner: true }); | ||
dispatch((0, groupOrder_1.adjustGroupOrder)(payload)); | ||
if (callback) | ||
callback(); | ||
return payload; | ||
} | ||
@@ -236,4 +237,5 @@ catch (err) { | ||
}) | ||
.addCase(exports.updateCustomerGroupOrder.fulfilled, (state, action) => { | ||
return Object.assign(Object.assign(Object.assign({}, state), action.payload), { loading: 'idle', error: null }); | ||
.addCase(exports.updateCustomerGroupOrder.fulfilled, state => { | ||
state.error = null; | ||
state.loading = 'idle'; | ||
}) | ||
@@ -240,0 +242,0 @@ .addCase(exports.updateCustomerGroupOrder.pending, state => { |
import { AppState } from '../../app'; | ||
import { GroupOrder, GroupOrderExpanded, GroupOrders, GroupOrdersExpanded, RequestError, RequestStatus } from '@open-tender/types'; | ||
import { GroupOrder, GroupOrderExpanded, GroupOrdersExpanded, RequestError, RequestStatus } from '@open-tender/types'; | ||
import { OrderState } from '../order'; | ||
@@ -67,3 +67,3 @@ export interface CustomerGroupOrdersState { | ||
} | null; | ||
export declare const updateCustomerGroupOrder: import("@reduxjs/toolkit").AsyncThunk<GroupOrders, { | ||
export declare const updateCustomerGroupOrder: import("@reduxjs/toolkit").AsyncThunk<void, { | ||
cartId: number; | ||
@@ -70,0 +70,0 @@ callback?: (() => void) | undefined; |
@@ -6,3 +6,3 @@ import { __awaiter } from "tslib"; | ||
import { checkAuth, selectToken } from './account'; | ||
import { makeCartPayload, resetGroupOrder } from '../groupOrder'; | ||
import { adjustGroupOrder, makeCartPayload, resetGroupOrder } from '../groupOrder'; | ||
import { addMessage, resetAlert, setAlert, setCart, setRequestedAt, setRevenueCenter } from '../order'; | ||
@@ -70,3 +70,2 @@ import { makeRequestedAtStr, makeSimpleCart, rehydrateCart, timezoneMap } from '@open-tender/utils'; | ||
export const updateCustomerGroupOrder = createAsyncThunk(CustomerGroupOrdersActionType.UpdateCustomerGroupOrder, ({ cartId, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a; | ||
try { | ||
@@ -83,10 +82,12 @@ const api = getState().config.api; | ||
dispatch(setRequestedAt(response.requested_at)); | ||
const tz = timezoneMap[(_a = revenueCenter === null || revenueCenter === void 0 ? void 0 : revenueCenter.timezone) !== null && _a !== void 0 ? _a : 'US/Central']; | ||
const requestedAtText = makeRequestedAtStr(response.requested_at, tz); | ||
dispatch(addMessage(`Requested time updated to ${requestedAtText}`)); | ||
if (revenueCenter) { | ||
const tz = timezoneMap[revenueCenter.timezone]; | ||
const requestedAtText = makeRequestedAtStr(response.requested_at, tz); | ||
dispatch(addMessage(`Requested time updated to ${requestedAtText}`)); | ||
} | ||
} | ||
const payload = Object.assign(Object.assign({}, makeCartPayload(response)), { isCartOwner: true }); | ||
dispatch(adjustGroupOrder(payload)); | ||
if (callback) | ||
callback(); | ||
return payload; | ||
} | ||
@@ -232,4 +233,5 @@ catch (err) { | ||
}) | ||
.addCase(updateCustomerGroupOrder.fulfilled, (state, action) => { | ||
return Object.assign(Object.assign(Object.assign({}, state), action.payload), { loading: 'idle', error: null }); | ||
.addCase(updateCustomerGroupOrder.fulfilled, state => { | ||
state.error = null; | ||
state.loading = 'idle'; | ||
}) | ||
@@ -236,0 +238,0 @@ .addCase(updateCustomerGroupOrder.pending, state => { |
{ | ||
"name": "@open-tender/cloud", | ||
"version": "0.1.92", | ||
"version": "0.1.93", | ||
"description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20620
911621