diff --git a/ChangeLog.md b/ChangeLog.md
index 6a88724..97e3611 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -54,4 +54,5 @@
- Cancel Order on view order (no take-away option)
# v1.2.7 [10 мая 2019]
-- Fix on protocol in syncing
\ No newline at end of file
+- Fix on protocol in syncing
+- Added Device Id field
diff --git a/package.json b/package.json
index 3aa9a6d..a66cab0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "tailpos",
- "version": "1.2.6",
+ "version": "1.2.7",
"private": true,
"devDependencies": {
"babel-eslint": "8.1.0",
diff --git a/src/boot/index.js b/src/boot/index.js
index 5ac5914..fcd97c0 100644
--- a/src/boot/index.js
+++ b/src/boot/index.js
@@ -23,6 +23,7 @@ export default function() {
retrieveSettings().then(item => {
if (item) {
+ stores.stateStore.setDeviceId(item.deviceId);
stores.stateStore.setQueueHost(item.queueHost);
if (item.hasTailOrder) {
stores.stateStore.toggleTailOrder();
diff --git a/src/container/SettingsContainer/index.js b/src/container/SettingsContainer/index.js
index 543f5a9..11b77cb 100644
--- a/src/container/SettingsContainer/index.js
+++ b/src/container/SettingsContainer/index.js
@@ -7,7 +7,7 @@ import BluetoothSerial from "react-native-bluetooth-serial";
import { BluetoothStatus } from "react-native-bluetooth-status";
import Settings from "@screens/Settings";
import { syncObjectValues } from "../../store/PosStore/syncInBackground";
-import { saveToSettings } from "../../services/storage";
+import { saveConfig } from "../../services/storage";
// import { syncData } from "./sync";
@@ -663,11 +663,10 @@ export default class SettingsContainer extends React.Component {
password: this.props.stateStore.settings_state[0].password,
});
}
- // this.setState({
- // syncEditStatus: false,
- // });
+ saveConfig(this.props.stateStore);
this.props.stateStore.changeValue("syncEditStatus", false, "Settings");
};
+
onAddRoles(values) {
this.props.roleStore.add({
role: values.role,
@@ -676,6 +675,7 @@ export default class SettingsContainer extends React.Component {
canLogin: values.checkBoxValue,
});
}
+
onDeleteRoles = values => {
Alert.alert(
"Delete attendant", // title
@@ -709,20 +709,9 @@ export default class SettingsContainer extends React.Component {
}
onQueueSave = () => {
- const {
- setQueueNotEditing,
- queueHost,
- hasTailOrder,
- useDefaultCustomer,
- useDescription,
- } = this.props.stateStore;
+ const { setQueueNotEditing } = this.props.stateStore;
- saveToSettings({
- queueHost,
- hasTailOrder,
- useDescription,
- useDefaultCustomer,
- });
+ saveConfig(this.props.stateStore);
setQueueNotEditing();
};
@@ -827,6 +816,8 @@ export default class SettingsContainer extends React.Component {
isSyncing={stateStore.isSyncing}
isHttps={stateStore.isHttps}
toggleHttps={stateStore.toggleHttps}
+ deviceId={stateStore.deviceId}
+ setDeviceId={stateStore.setDeviceId}
/>
);
}
diff --git a/src/services/storage.js b/src/services/storage.js
index ab83ec3..4e41003 100644
--- a/src/services/storage.js
+++ b/src/services/storage.js
@@ -10,3 +10,13 @@ export const saveToSettings = value => {
const valueString = JSON.stringify(value);
return AsyncStorage.setItem("@Settings:Queue", valueString);
};
+
+export const saveConfig = settings => {
+ return saveToSettings({
+ deviceId: settings.deviceId,
+ queueHost: settings.queueHost,
+ hasTailOrder: settings.hasTailOrder,
+ useDescription: settings.useDescription,
+ useDefaultCustomer: settings.useDefaultCustomer,
+ });
+};
diff --git a/src/store/PosStore/DbFunctions.js b/src/store/PosStore/DbFunctions.js
index df13fe4..ee5f3f9 100644
--- a/src/store/PosStore/DbFunctions.js
+++ b/src/store/PosStore/DbFunctions.js
@@ -45,6 +45,7 @@ export function sync(jsonObject, type, trashObj, credentials, jobStatus) {
{
tailposData: JSON.parse(jsonObject),
trashObject: JSON.parse(trashObj),
+ deviceId: credentials.deviceId,
typeOfSync: type,
},
);
diff --git a/src/store/PosStore/syncInBackground.js b/src/store/PosStore/syncInBackground.js
index 089c68e..483cace 100644
--- a/src/store/PosStore/syncInBackground.js
+++ b/src/store/PosStore/syncInBackground.js
@@ -20,6 +20,7 @@ export function syncObjectValues(status, store, jobStatus) {
) {
const protocol = store.stateStore.isHttps ? "https://" : "http://";
const syncInfo = {
+ deviceId: store.stateStore.deviceId,
url: protocol + store.printerStore.sync[0].url,
user_name: store.printerStore.sync[0].user_name,
password: store.printerStore.sync[0].password,
diff --git a/src/store/StateStore/StateStore.js b/src/store/StateStore/StateStore.js
index 03ef16a..22ac727 100644
--- a/src/store/StateStore/StateStore.js
+++ b/src/store/StateStore/StateStore.js
@@ -39,6 +39,7 @@ const StateStore = types
isEditingQueue: types.optional(types.boolean, false),
useDescription: types.optional(types.boolean, false),
isHttps: types.optional(types.boolean, false),
+ deviceId: types.optional(types.string, ""),
// Is Syncing
isSyncing: types.optional(types.boolean, false),
@@ -170,6 +171,9 @@ const StateStore = types
toggleHttps() {
self.isHttps = !self.isHttps;
},
+ setDeviceId(deviceId) {
+ self.deviceId = deviceId;
+ },
}));
const Store = StateStore.create({});
diff --git a/src/stories/components/SyncComponent.js b/src/stories/components/SyncComponent.js
index 2114c1f..2f80f18 100644
--- a/src/stories/components/SyncComponent.js
+++ b/src/stories/components/SyncComponent.js
@@ -47,6 +47,8 @@ class CompanyComponent extends React.PureComponent {
isSyncing,
isHttps,
toggleIsHttps,
+ setDeviceId,
+ deviceId,
} = this.props;
const SyncStatus = isSyncing ? (
@@ -112,6 +114,14 @@ class CompanyComponent extends React.PureComponent {
placeholder="Password"
label="Password"
/>
+
{this.renderSyncButtons()}
diff --git a/src/stories/screens/Settings/index.js b/src/stories/screens/Settings/index.js
index 0bfc942..18dfdfd 100644
--- a/src/stories/screens/Settings/index.js
+++ b/src/stories/screens/Settings/index.js
@@ -147,6 +147,8 @@ class Settings extends React.Component {
// Sync
isSyncing,
+ setDeviceId,
+ deviceId,
// navigation
navigation,
@@ -215,6 +217,8 @@ class Settings extends React.Component {
password={password}
isHttps={isHttps}
toggleIsHttps={toggleHttps}
+ deviceId={deviceId}
+ setDeviceId={setDeviceId}
/>
);
}