Skip to content

Commit

Permalink
feat: add types to store
Browse files Browse the repository at this point in the history
  • Loading branch information
LeleDallas committed May 4, 2023
1 parent 6ffe670 commit a67d3c0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/reducers/allOrganization.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { createSlice } from '@reduxjs/toolkit'
import { Building, Organization } from '../types';

const organizationData = localStorage.getItem("allOrganization");
const allBuildingsData = localStorage.getItem("allBuildings");

const initialState = {
interface InitState {
organization: Organization
allBuildings: Array<Building>
}

const initialState: InitState = {
organization: organizationData ? JSON.parse(organizationData) : null,
allBuildings: allBuildingsData ? JSON.parse(allBuildingsData) : null
};
Expand Down
7 changes: 6 additions & 1 deletion src/reducers/allUsers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { createSlice } from '@reduxjs/toolkit'
import { UserProps } from '../types';


const user = localStorage.getItem("allOrganization");

const initialState = {
interface InitState {
user: Array<UserProps>
}

const initialState: InitState = {
user: user ? JSON.parse(user) : {},
}

Expand Down
8 changes: 7 additions & 1 deletion src/reducers/buildings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { createSlice } from '@reduxjs/toolkit'
import { Building } from '../types'


const buildings = localStorage.getItem("buildings")
const initialState = {

interface InitState {
buildings: Building
}

const initialState: InitState = {
buildings: buildings ? JSON.parse(buildings) : {},
}

Expand Down
7 changes: 6 additions & 1 deletion src/reducers/organization.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { createSlice } from '@reduxjs/toolkit'
import { Organization } from '../types'

const organization = localStorage.getItem("organization")

const initialState = {
interface InitState {
organization: Organization
}

const initialState: InitState = {
organization: organization ? JSON.parse(organization) : {},
}

Expand Down
7 changes: 6 additions & 1 deletion src/reducers/preference.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@

import { createSlice } from '@reduxjs/toolkit'
import { UserPreference } from '../types'

const preference = localStorage.getItem("preference")

const initialState = {
interface initState {
preference: UserPreference
}

const initialState: initState = {
preference: preference ? JSON.parse(preference) : {},
}

Expand Down
4 changes: 3 additions & 1 deletion src/reducers/user.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { createSlice } from '@reduxjs/toolkit'
import { User } from '../types';


const user = localStorage.getItem("user");
const logged = localStorage.getItem("logged");

const initialState = {

const initialState: User = {
user: user ? JSON.parse(user) : {},
logged: logged === "true"
}
Expand Down

0 comments on commit a67d3c0

Please sign in to comment.