Browse Source

feat: added zustand global storage

Oleksandr Honcharov 1 year ago
parent
commit
0040790993
2 changed files with 37 additions and 1 deletions
  1. 4 1
      package.json
  2. 33 0
      src/storage/zustand.ts

+ 4 - 1
package.json

@@ -24,6 +24,7 @@
     "expo-image-picker": "~14.3.2",
     "expo-splash-screen": "~0.20.5",
     "expo-status-bar": "~1.6.0",
+    "formik": "^2.4.5",
     "moment": "^2.29.4",
     "patch-package": "^8.0.0",
     "postinstall-postinstall": "^2.1.0",
@@ -32,7 +33,9 @@
     "react-native-calendar-picker": "^7.1.4",
     "react-native-safe-area-context": "4.6.3",
     "react-native-screens": "~3.22.0",
-    "react-native-svg": "13.9.0"
+    "react-native-svg": "13.9.0",
+    "yup": "^1.3.3",
+    "zustand": "^4.4.7"
   },
   "devDependencies": {
     "@babel/core": "^7.20.0",

+ 33 - 0
src/storage/zustand.ts

@@ -0,0 +1,33 @@
+import { create } from 'zustand';
+
+type State = {
+  inApp: {};
+  registration: {
+    user: {
+      username: string;
+      email: string;
+      password: string;
+    };
+  };
+};
+
+type Action = {
+  registration: {
+    updateRegistrationUserData: (registration: State['registration']['user']) => void;
+  };
+};
+
+const store = create<State & Action>((set) => ({
+  inApp: {},
+  registration: {
+    user: {
+      username: '',
+      email: '',
+      password: ''
+    },
+    updateRegistrationUserData: (userData) =>
+      set((state) => ({ registration: { ...state.registration, user: userData } }))
+  }
+}));
+
+export default store;