-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65d9ecb
commit 121eb32
Showing
18 changed files
with
865 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import React from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { useSafeAreaInsets } from 'react-native-safe-area-context'; | ||
import FontAwesome5Icon from 'react-native-vector-icons/FontAwesome5'; | ||
|
||
import { View, Text, StyleSheet, TouchableOpacity, Dimensions } from 'react-native'; | ||
|
||
import { ENV_TYPE } from '../../environment'; | ||
import HeaderV2 from '../Common/Header/HeaderV2'; | ||
import { Colors, Typography } from '../../styles'; | ||
import { IS_ANDROID, scaleSize } from '../../styles/mixins'; | ||
import { SET_APP_ENVIRONMENT } from '../../redux/slices/envSlice'; | ||
|
||
const { width, height } = Dimensions.get('screen'); | ||
|
||
const Environment = () => { | ||
const { currentEnv } = useSelector(state => state.envSlice); | ||
const dispatch = useDispatch(); | ||
const insects = useSafeAreaInsets(); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<HeaderV2 | ||
headingText="Environment" | ||
containerStyle={{ | ||
paddingHorizontal: 25, | ||
paddingTop: IS_ANDROID ? insects.top + 20 : insects.top, | ||
}} | ||
/> | ||
<View style={styles.btnCon}> | ||
<TouchableOpacity | ||
activeOpacity={0.7} | ||
onPress={() => dispatch(SET_APP_ENVIRONMENT(ENV_TYPE.STAGING))}> | ||
<View | ||
style={[ | ||
styles.btn, | ||
currentEnv === ENV_TYPE.STAGING && { | ||
backgroundColor: Colors.PRIMARY + '20', | ||
}, | ||
]}> | ||
<View style={styles.iconCon}> | ||
<FontAwesome5Icon name={'code'} size={30} color={Colors.PRIMARY} /> | ||
</View> | ||
<Text style={styles.drawerItemLabel}>Development</Text> | ||
</View> | ||
</TouchableOpacity> | ||
<TouchableOpacity | ||
activeOpacity={0.7} | ||
onPress={() => dispatch(SET_APP_ENVIRONMENT(ENV_TYPE.PROD))}> | ||
<View | ||
style={[ | ||
styles.btn, | ||
currentEnv === ENV_TYPE.PROD && { backgroundColor: Colors.PRIMARY + '20' }, | ||
]}> | ||
<View style={styles.iconCon}> | ||
<FontAwesome5Icon name={'laptop-code'} size={30} color={Colors.PRIMARY} /> | ||
</View> | ||
<Text style={styles.drawerItemLabel}>Production</Text> | ||
</View> | ||
</TouchableOpacity> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
export default Environment; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
}, | ||
btnCon: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-evenly', | ||
alignItems: 'center', | ||
}, | ||
btn: { | ||
borderRadius: 8, | ||
borderWidth: 2, | ||
width: width / 2.5, | ||
height: width / 2.5, | ||
marginVertical: height / 30, | ||
borderColor: Colors.PRIMARY, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
iconCon: { | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: Colors.PRIMARY + '40', | ||
borderRadius: 100, | ||
width: 70, | ||
height: 70, | ||
}, | ||
drawerItemLabel: { | ||
fontSize: Typography.FONT_SIZE_16, | ||
fontFamily: Typography.FONT_FAMILY_BOLD, | ||
marginTop: scaleSize(12), | ||
color: Colors.PRIMARY, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Config from 'react-native-config'; | ||
|
||
export enum ENV_TYPE { | ||
STAGING = 'STAGING', | ||
PROD = 'PRODUCTION', | ||
} | ||
|
||
export const ENVS = { | ||
STAGING: { | ||
BUGSNAP_CLIENT_KEY: Config.BUGSNAP_CLIENT_KEY, | ||
AUTH0_DOMAIN: 'accounts.plant-for-the-planet.org', | ||
AUTH0_CLIENT_ID: 'LiEqEef641Pzv8cBGn6i9Jt9jrnyLJEt', | ||
API_ENDPOINT: 'app-staging.plant-for-the-planet.org', | ||
CDN_URL: 'cdn.plant-for-the-planet.org/staging', | ||
WEB_APP_URL: 'dev.pp.eco', | ||
}, | ||
PRODUCTION: { | ||
BUGSNAP_CLIENT_KEY: 'e1b5d94f16186f8c6a2169882998ebda', | ||
AUTH0_DOMAIN: 'accounts.plant-for-the-planet.org', | ||
AUTH0_CLIENT_ID: 'LiEqEef641Pzv8cBGn6i9Jt9jrnyLJEt', | ||
API_ENDPOINT: 'app.plant-for-the-planet.org', | ||
CDN_URL: 'cdn.plant-for-the-planet.org', | ||
WEB_APP_URL: 'www1.plant-for-the-planet.org', | ||
REALM_DISABLE_ANALYTICS: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
import type { PayloadAction } from '@reduxjs/toolkit'; | ||
|
||
import { ENV_TYPE } from '../../environment'; | ||
import { modifyUserDetails } from '../../repositories/user'; | ||
|
||
interface EnvState { | ||
currentEnv: string; | ||
} | ||
|
||
const initialState: EnvState = { | ||
currentEnv: ENV_TYPE.STAGING, | ||
}; | ||
|
||
export const envSlice = createSlice({ | ||
name: 'envSlice', | ||
initialState, | ||
reducers: { | ||
SET_APP_ENVIRONMENT: (state, action: PayloadAction<string>) => { | ||
modifyUserDetails({ | ||
appEnvironment: action.payload, | ||
}); | ||
state.currentEnv = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { SET_APP_ENVIRONMENT } = envSlice.actions; | ||
export default envSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import envSlice from './slices/envSlice'; | ||
|
||
export const store = configureStore({ | ||
reducer: { | ||
envSlice, | ||
}, | ||
}); | ||
|
||
// Infer the `RootState` and `AppDispatch` types from the store itself | ||
export type RootState = ReturnType<typeof store.getState>; | ||
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState} | ||
export type AppDispatch = typeof store.dispatch; |
Oops, something went wrong.