@open-tender/cloud
Version:
A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.
37 lines (36 loc) • 1.4 kB
JavaScript
;
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.geolocationReducer = exports.selectGeoLatLng = exports.selectGeo = exports.setGeoLoading = exports.setGeoError = exports.setGeoLatLng = exports.resetGeolocation = void 0;
const toolkit_1 = require("@reduxjs/toolkit");
const initialState = {
latLng: null,
error: null,
loading: false
};
const geolocationSlice = (0, toolkit_1.createSlice)({
name: 'geolocation',
initialState,
reducers: {
resetGeolocation: () => initialState,
setGeoLatLng: (state, action) => {
state.latLng = action.payload;
state.error = null;
state.loading = false;
},
setGeoError: (state, action) => {
state.latLng = null;
state.error = action.payload;
state.loading = false;
},
setGeoLoading: state => {
state.loading = true;
}
}
});
_a = geolocationSlice.actions, exports.resetGeolocation = _a.resetGeolocation, exports.setGeoLatLng = _a.setGeoLatLng, exports.setGeoError = _a.setGeoError, exports.setGeoLoading = _a.setGeoLoading;
const selectGeo = (state) => state.geolocation;
exports.selectGeo = selectGeo;
const selectGeoLatLng = (state) => state.geolocation.latLng;
exports.selectGeoLatLng = selectGeoLatLng;
exports.geolocationReducer = geolocationSlice.reducer;