Skip to content

Commit

Permalink
Feature/ listando grupos #9
Browse files Browse the repository at this point in the history
  • Loading branch information
AGoretti committed Nov 19, 2020
1 parent ece08bd commit 95bf4f8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
18 changes: 15 additions & 3 deletions mobile/DiarioSaude/src/components/groupItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@ import { View, Image, Text } from "react-native";
import styles from "./styles";
import { RectButton } from "react-native-gesture-handler";

function GroupItem() {
export interface Group {
users: [];
_id: String;
groupName: String;
idUBS: Number;
__v: Number;
}

interface GroupProp {
group: Group;
}

const GroupItem: React.FC<GroupProp> = ({ group }) => {
return (
<View style={styles.container}>
<View style={styles.profile}>
<View style={styles.profileInfo}>
<Text style={styles.name}>Nome Grupo</Text>
<Text style={styles.name}>{group.groupName}</Text>
</View>
</View>

Expand All @@ -23,6 +35,6 @@ function GroupItem() {
</View>
</View>
);
}
};

export default GroupItem;
32 changes: 26 additions & 6 deletions mobile/DiarioSaude/src/pages/Medico/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
import React, { useContext } from "react";
import React, { useContext, useEffect, useState } from "react";
import { Text, View, Image, ScrollView } from "react-native";
import styles from "./styles";
import { RectButton } from "react-native-gesture-handler";
import AuthContext from "../../contexts/auth";
import AsyncStorage from "@react-native-community/async-storage";
import GroupItem from "../../components/groupItem";
import GroupItem, { Group } from "../../components/groupItem";
import { useNavigation } from "@react-navigation/native";
import Axios from "axios";
import api from "../../services/api";

function Medico() {
const storagedUser = AsyncStorage.getItem("@DiarioSaude:user");
const [isLoading, setLoading] = useState(true);
const [Groups, setGroups] = useState([]);

useEffect(() => {
api.get("/group").then(response => {
setGroups(response.data);

setLoading(false);
});
}, []);

const { navigate } = useNavigation();

if (isLoading) {
return (
<View>
<Text>Carregando</Text>
</View>
);
}

return (
<ScrollView>
<GroupItem />
<GroupItem />
<GroupItem />
{Groups.map((group: Group, index) => {
return <GroupItem group={group} key={index} />;
})}

<RectButton
style={styles.contactButton}
onPress={() => {
Expand Down

0 comments on commit 95bf4f8

Please sign in to comment.