@open-tender/store 0.3.91 → 0.3.92

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.
@@ -31,7 +31,13 @@ export declare const selectLastOrderId: (state: AppState) => string | null;
31
31
  export declare const selectMenuPage: (state: AppState) => number | null;
32
32
  export declare const selectPosName: (state: AppState) => string | null;
33
33
  export declare const selectPosNotes: (state: AppState) => string | null;
34
- export declare const selectCashier: (state: AppState) => Cashier | null;
34
+ export declare const selectCashier: (state: AppState) => {
35
+ cashier: null;
36
+ isExpired: boolean;
37
+ } | {
38
+ cashier: Cashier;
39
+ isExpired: boolean;
40
+ };
35
41
  export declare const selectManager: (state: AppState) => Employee | null;
36
42
  export declare const selectIsOffline: (state: AppState) => boolean;
37
43
  export declare const selectPosFontSize: (state: AppState) => DeviceFontSize;
@@ -5,6 +5,8 @@ exports.posReducer = exports.selectPosColorScheme = exports.selectPosFontSize =
5
5
  var tslib_1 = require("tslib");
6
6
  var toolkit_1 = require("@reduxjs/toolkit");
7
7
  var types_1 = require("./types");
8
+ var config_1 = require("./config");
9
+ var utils_1 = require("../utils");
8
10
  var initialState = {
9
11
  cashier: null,
10
12
  manager: null,
@@ -137,7 +139,17 @@ var selectPosName = function (state) { return state.pos.name; };
137
139
  exports.selectPosName = selectPosName;
138
140
  var selectPosNotes = function (state) { return state.pos.notes; };
139
141
  exports.selectPosNotes = selectPosNotes;
140
- var selectCashier = function (state) { return state.pos.cashier; };
142
+ var selectCashier = function (state) {
143
+ var cashier = state.pos.cashier;
144
+ if (!cashier)
145
+ return { cashier: null, isExpired: false };
146
+ var tz = (0, config_1.selectTimezone)(state);
147
+ var businessDate = (0, utils_1.currentLocalDateStr)(tz);
148
+ var isExpired = businessDate !== cashier.businessDate;
149
+ if (isExpired)
150
+ return { cashier: null, isExpired: true };
151
+ return { cashier: cashier, isExpired: false };
152
+ };
141
153
  exports.selectCashier = selectCashier;
142
154
  var selectManager = function (state) { return state.pos.manager; };
143
155
  exports.selectManager = selectManager;
@@ -31,7 +31,13 @@ export declare const selectLastOrderId: (state: AppState) => string | null;
31
31
  export declare const selectMenuPage: (state: AppState) => number | null;
32
32
  export declare const selectPosName: (state: AppState) => string | null;
33
33
  export declare const selectPosNotes: (state: AppState) => string | null;
34
- export declare const selectCashier: (state: AppState) => Cashier | null;
34
+ export declare const selectCashier: (state: AppState) => {
35
+ cashier: null;
36
+ isExpired: boolean;
37
+ } | {
38
+ cashier: Cashier;
39
+ isExpired: boolean;
40
+ };
35
41
  export declare const selectManager: (state: AppState) => Employee | null;
36
42
  export declare const selectIsOffline: (state: AppState) => boolean;
37
43
  export declare const selectPosFontSize: (state: AppState) => DeviceFontSize;
@@ -2,6 +2,8 @@ var _a;
2
2
  import { __awaiter, __generator } from "tslib";
3
3
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
4
4
  import { ReducerType } from './types';
5
+ import { selectTimezone } from './config';
6
+ import { currentLocalDateStr } from '../utils';
5
7
  var initialState = {
6
8
  cashier: null,
7
9
  manager: null,
@@ -129,7 +131,17 @@ export var selectLastOrderId = function (state) { return state.pos.lastOrderId;
129
131
  export var selectMenuPage = function (state) { return state.pos.page; };
130
132
  export var selectPosName = function (state) { return state.pos.name; };
131
133
  export var selectPosNotes = function (state) { return state.pos.notes; };
132
- export var selectCashier = function (state) { return state.pos.cashier; };
134
+ export var selectCashier = function (state) {
135
+ var cashier = state.pos.cashier;
136
+ if (!cashier)
137
+ return { cashier: null, isExpired: false };
138
+ var tz = selectTimezone(state);
139
+ var businessDate = currentLocalDateStr(tz);
140
+ var isExpired = businessDate !== cashier.businessDate;
141
+ if (isExpired)
142
+ return { cashier: null, isExpired: true };
143
+ return { cashier: cashier, isExpired: false };
144
+ };
133
145
  export var selectManager = function (state) { return state.pos.manager; };
134
146
  export var selectIsOffline = function (state) { return state.pos.isOffline; };
135
147
  export var selectPosFontSize = function (state) { return state.pos.fontSize; };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "0.3.91",
3
+ "version": "0.3.92",
4
4
  "description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",