Skip to content

Commit

Permalink
Merge pull request #332 from ashifkhn/form-notification
Browse files Browse the repository at this point in the history
Form updated for goals
  • Loading branch information
shreya-mishra authored Nov 16, 2023
2 parents eb5f059 + 25fe550 commit 3d03144
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 7 deletions.
Binary file added assets/dropdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dropup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
140 changes: 135 additions & 5 deletions src/components/ToDoComponent/SettingGoals/CreateGoals.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,46 @@
import React, { useState } from 'react';
import React, { useState,useEffect,useContext } from 'react';
import 'react-native-gesture-handler';
import {
Text,
TextInput,
View,
ScrollView,
StyleSheet,
TouchableOpacity,
Image,
FlatList
} from 'react-native';
import DeadLineDatePicker from './SettingGoalsComponents/DeadLineDatePicker';
import { AuthContext } from '../../../context/AuthContext';
import { getAllUsers } from '../../../screens/AuthScreen/Util';

const MainScreen = ({ navigation }) => {
const [selectedMember, setSelectedMember] = React.useState('');
const [titleText, setTitleText] = useState('');
const [descriptionText, setDescriptionText] = useState('');
const [isDropDownSelected, setIsDropDownSelected] =useState(false)
const [searchQuery, setSearchQuery] = useState('');
const [allUsers,setAllUsers] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const { loggedInUserData } = useContext(AuthContext);



const selectDropDown =()=>{
setIsDropDownSelected(!isDropDownSelected)
}

useEffect(() => {
fetchData();
});

const fetchData = async () => {
const allUser = await getAllUsers (loggedInUserData?.token);
setAllUsers(allUser);
setIsLoading(false)
};

return (
<ScrollView style={styles.container}>
<View style={styles.container}>
<View
style={{
borderWidth: 3,
Expand Down Expand Up @@ -45,6 +70,7 @@ const MainScreen = ({ navigation }) => {
value={titleText}
onChangeText={setTitleText}
placeholder="Enter title max of 50 characters."
placeholderTextColor="red"
/>
<Text style={styles.titleText}>Description</Text>
<TextInput
Expand All @@ -53,10 +79,11 @@ const MainScreen = ({ navigation }) => {
onChangeText={setDescriptionText}
maxLength={200}
placeholder="Enter max 200 characters."
placeholderTextColor="red"
/>
{/* <Text style={styles.titles}>Duration</Text>
<DurationDropDown /> */}
<Text style={styles.titles}>Assigned To</Text>
<Text style={styles.titles}>Assign To</Text>
{/* <DurationDropDown /> */}
<TouchableOpacity
onPress={() =>
Expand All @@ -70,6 +97,62 @@ const MainScreen = ({ navigation }) => {
{selectedMember ? selectedMember : "Enter member's name"}
</Text>
</TouchableOpacity>
<View>


<Text style={styles.titles}>Assign To Dropdown</Text>
<TouchableOpacity style={styles.dropDownSelector} onPress={selectDropDown}>
<Text style={{color:"red"}}>
Select User
</Text>
{
!isDropDownSelected?
<Image source={require("./../../../../assets/dropdown.png")} style={styles.dropDownIcon}/>:
<Image source={require("./../../../../assets/dropup.png")} style={styles.dropDownIcon}/>
}
</TouchableOpacity>
{
isDropDownSelected?
<View style={styles.dropDownArea}>
<TextInput
style={[styles.inputStyle, { marginTop: 10, marginHorizontal: 5 }]}
value={searchQuery}
onChangeText={(text) => setSearchQuery(text)}
maxLength={200}
placeholder="Search User"
/>
{
isLoading?<Text>Loading...</Text>:
<FlatList
data={allUsers.filter(
(item) =>
item.first_name.toLowerCase().includes(searchQuery.toLowerCase()) ||
item.last_name.toLowerCase().includes(searchQuery.toLowerCase()) ||
item.github_id.toLowerCase().includes(searchQuery.toLowerCase())
)}
renderItem={({ item, index }) => {
return (
<TouchableOpacity key={index} onPress={() => console.log(item)} style={styles.userDetails}>
{item.picture && item.picture.url ? (
<Image source={{ uri: item.picture.url }} style={styles.userImageDropDown} />
) : (
<View style={styles.defaultImageContainer}>
<Text style={styles.defaultImageText}>
{item.first_name.charAt(0)} {item.last_name.charAt(0)}
</Text>
</View>
)}
<Text style={styles.userNameDropDown}>{item.first_name} {item.last_name}</Text>
</TouchableOpacity>
);
}}
/>
}

</View>
:null
}
</View>
<Text style={styles.titles}>DeadLine</Text>
<DeadLineDatePicker />
<TouchableOpacity
Expand All @@ -79,7 +162,7 @@ const MainScreen = ({ navigation }) => {
<Text style={styles.createButtonText}>Create</Text>
</TouchableOpacity>
</View>
</ScrollView>
</View>
);
};

Expand Down Expand Up @@ -138,6 +221,53 @@ const styles = StyleSheet.create({
backgroundColor: '#2827CC',
},
titleText: {},
dropDownSelector:{
padding: 10,
borderRadius: 5,
elevation: 2,
fontSize: 12,
borderWidth: 2,
height:40,
display:"flex",
flexDirection:"row",
justifyContent:"space-between"
},
dropDownIcon:{
width:20,
height:20,
},
dropDownArea:{
height:250,
backgroundColor:"grey",
marginTop:10,
borderRadius:5
},
userNameDropDown:{
padding:20,
borderBottomColor:'white',
width:"90%",alignSelf:"center"
},
userDetails:{
display:"flex",
flexDirection:"row",
marginLeft:10
},
userImageDropDown:{
width:50,
height:50,
borderRadius:50

},
defaultImageContainer:{
width:50,
display:"flex",
justifyContent:"center",
alignItems:"center",
height:50,
backgroundColor:"rgb(29,18,131)",
borderRadius:50
},

});

export default MainScreen;
4 changes: 2 additions & 2 deletions src/constants/apiConstant/HomeApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const HomeApi = {
GET_USER_STATUS: 'https://api.realdevsquad.com/users/status/self',
UPDATE_STATUS:
'https://api.realdevsquad.com/users/status/self?userStatusFlag=true',
UPDATE_STATUS:'https://api.realdevsquad.com/users/status/self?userStatusFlag=true',
GET_ALL_USERS:'https://api.realdevsquad.com/users'
};
21 changes: 21 additions & 0 deletions src/screens/AuthScreen/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@ export const getUsersStatus = async (token) => {
}
};

export const getAllUsers = async (token) => {
try {
const res = await axios.get(HomeApi.GET_ALL_USERS, {
headers: {
'Content-type': 'application/json',
cookie: `rds-session=${token}`,
},
});
if (res?.data?.users) {
return res?.data?.users;
}
else {
return 'Something went wrong';
}
}

catch (err) {
return 'Something went wrong';
}
};

export const submitOOOForm = async (data, token) => {
console.log('data', data);
const options = {
Expand Down

0 comments on commit 3d03144

Please sign in to comment.