Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Alder Whiteford authored and Alder Whiteford committed Jun 11, 2024
1 parent 290553f commit 4d98763
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 72 deletions.
4 changes: 2 additions & 2 deletions frontend/mobile/src/app/(app)/event/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import { Button } from '@/src/app/(design-system)/components/Button/Button';
import { description, events, tags } from '@/src/consts/event-page';

import { AboutEvent } from './components/about';
import { Description } from './components/description';
import { Location } from './components/location';
import { Overview } from './components/overview';
import { UpcomingEvent } from './components/upcoming-events';
import { Description } from './components/description';
import { RegisterBottomSheet } from './components/register';
import { ShareEventBottomSheet } from './components/share-event';
import { UpcomingEvent } from './components/upcoming-events';

type EventType = 'in-person' | 'virtual' | 'hybrid';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { Box } from '@/src/app/(design-system)/components/Box/Box';
import DayTimeSection, {
EventSection
} from '@/src/app/(design-system)/components/Calendar/DayTimeSection';
import { Text } from '@/src/app/(design-system)/components/Text/Text';
import NoEventsIcon from '@/src/assets/svg/NoSearchResult.svg';
import { formatTime } from '@/src/utils/time';

import { Text } from '@/src/app/(design-system)/components/Text/Text';

type DayProps = {
section: EventSection;
error?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion frontend/mobile/src/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { StatusBar } from 'expo-status-bar';
import FontAwesome from '@expo/vector-icons/FontAwesome';
import { ThemeProvider } from '@shopify/restyle';

import { theme } from './(design-system)';
import StoreProvider from '../store/StoreProvider';
import { useAppSelector } from '../store/store';
import { theme } from './(design-system)';

export { ErrorBoundary } from 'expo-router';

Expand Down
26 changes: 14 additions & 12 deletions frontend/mobile/src/store/StoreProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { Provider } from "react-redux";
import { PersistGate } from "redux-persist/integration/react";
import { persistor, store } from "@/src/store/store";
import { Provider } from 'react-redux';

import { PersistGate } from 'redux-persist/integration/react';

import { persistor, store } from '@/src/store/store';

type StoreProviderProps = {
children: React.ReactNode;
}
children: React.ReactNode;
};

/**
* The Redux store provider component. This makes the store accessible globally across the repository
*/
export default function StoreProvider({ children }: StoreProviderProps) {
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
{children}
</PersistGate>
</Provider>
)
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
{children}
</PersistGate>
</Provider>
);
}
20 changes: 8 additions & 12 deletions frontend/mobile/src/store/slices/userSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export type UserState = {
userId: string;
email: string;
accessToken?: string;
}
};

const initialState: UserState = {
userId: "",
email: "",
userId: '',
email: ''
};

export const userSlice = createSlice({
Expand All @@ -24,16 +24,12 @@ export const userSlice = createSlice({
setAccessToken: (state, action) => {
state.accessToken = action.payload;
},
resetAccessToken: state => {
resetAccessToken: (state) => {
state.accessToken = undefined;
}
}
})
});

export const {
setUser,
resetUser,
setAccessToken,
resetAccessToken
} = userSlice.actions;
export default userSlice.reducer;
export const { setUser, resetUser, setAccessToken, resetAccessToken } =
userSlice.actions;
export default userSlice.reducer;
92 changes: 50 additions & 42 deletions frontend/mobile/src/store/store.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,72 @@
import { baseApi } from "@generatesac/lib";
import { combineReducers, configureStore } from "@reduxjs/toolkit";
import { useDispatch, useSelector, useStore } from "react-redux";
import userReducer from "@/src/store/slices/userSlice";
import persistReducer from "redux-persist/es/persistReducer";
import { useDispatch, useSelector, useStore } from 'react-redux';

import { baseApi } from '@generatesac/lib';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { thunk } from "redux-thunk";
import { combineReducers, configureStore } from '@reduxjs/toolkit';
import {
FLUSH,
PAUSE,
PERSIST,
PURGE,
REGISTER,
REHYDRATE,
persistStore,
} from "redux-persist";
import autoMergeLevel2 from "redux-persist/es/stateReconciler/autoMergeLevel2";
FLUSH,
PAUSE,
PERSIST,
PURGE,
REGISTER,
REHYDRATE,
persistStore
} from 'redux-persist';
import persistReducer from 'redux-persist/es/persistReducer';
import autoMergeLevel2 from 'redux-persist/es/stateReconciler/autoMergeLevel2';
import { thunk } from 'redux-thunk';

import userReducer from '@/src/store/slices/userSlice';

const rootReducer = combineReducers({
user: userReducer,
[baseApi.reducerPath]: baseApi.reducer,
user: userReducer,
[baseApi.reducerPath]: baseApi.reducer
});

type RootReducer = ReturnType<typeof rootReducer>;

const persistanceConfig = {
key: "root",
storage: AsyncStorage,
stateReconciler: autoMergeLevel2,
blacklist: [baseApi.reducerPath],
whitelist: ["user"],
key: 'root',
storage: AsyncStorage,
stateReconciler: autoMergeLevel2,
blacklist: [baseApi.reducerPath],
whitelist: ['user']
};

const persistedReducer = persistReducer<RootReducer>(
persistanceConfig,
rootReducer,
persistanceConfig,
rootReducer
);

export const store =
configureStore({
export const store = configureStore({
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: {
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER],
}
})
.concat(baseApi.middleware)
.concat(thunk),

getDefaultMiddleware({
serializableCheck: {
ignoredActions: [
FLUSH,
REHYDRATE,
PAUSE,
PERSIST,
PURGE,
REGISTER
]
}
})
.concat(baseApi.middleware)
.concat(thunk),

reducer: persistedReducer,
devTools: process.env.NODE_ENV !== "production",
});
devTools: process.env.NODE_ENV !== 'production'
});

export const persistor = persistStore(store);

// Redux types:
export type AppStore = typeof store
export type RootState = ReturnType<AppStore['getState']>
export type AppDispatch = AppStore['dispatch']
export type AppStore = typeof store;
export type RootState = ReturnType<AppStore['getState']>;
export type AppDispatch = AppStore['dispatch'];

// Typed Redux interactive methods:
export const useAppDispatch = useDispatch.withTypes<AppDispatch>()
export const useAppSelector = useSelector.withTypes<RootState>()
export const useAppStore = useStore.withTypes<AppStore>()
export const useAppDispatch = useDispatch.withTypes<AppDispatch>();
export const useAppSelector = useSelector.withTypes<RootState>();
export const useAppStore = useStore.withTypes<AppStore>();
2 changes: 1 addition & 1 deletion frontend/mobile/src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ async function deleteToken(key: string) {
}
}

export { getToken, saveToken, deleteToken }
export { getToken, saveToken, deleteToken };

0 comments on commit 4d98763

Please sign in to comment.