Skip to content

Commit

Permalink
Merge pull request #24 from itsvick/main
Browse files Browse the repository at this point in the history
Issue #1 feat: Added details
  • Loading branch information
itsvick authored Nov 8, 2023
2 parents 022127b + af64470 commit 85d63be
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions packages/cohort/src/pages/CohortDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
Heading,
HStack,
Center,
Button,
ArrowDownIcon,
ArrowUpIcon,
} from "native-base";
import { useTranslation } from "react-i18next";
import {
Expand All @@ -26,6 +29,7 @@ import {
import moment from "moment";
import manifest from "../manifest.json";
import { useParams } from "react-router-dom";
import Collapse from "@mui/material/Collapse";

const colors = overrideColorTheme();

Expand All @@ -34,6 +38,7 @@ const CohortDetails = ({ footerLinks, setAlert, appName }) => {
const [selfAttendance, setSelfAttendance] = React.useState({});
const [showModal, setShowModal] = React.useState(false);
const [cohortDetails, setCohortDetails] = React.useState({});
const [toggleDetails, setToggleDetails] = React.useState(true);
const [fields, setFields] = React.useState([]);
const [loading, setLoading] = React.useState(true);
let newAvatar = localStorage.getItem("firstName");
Expand Down Expand Up @@ -145,7 +150,11 @@ const CohortDetails = ({ footerLinks, setAlert, appName }) => {
}
});
setFields(fieldVals);
}
};

const handleToggleDetails = () => {
setToggleDetails(!toggleDetails);
};

React.useEffect(() => {
const getData = async () => {
Expand Down Expand Up @@ -210,16 +219,30 @@ const CohortDetails = ({ footerLinks, setAlert, appName }) => {
>
{fields.length && (
<Stack space={3} alignItems="start" ml={6}>
<Heading textAlign="center" mb="2">
Details
</Heading>
<Button
variant="outline"
leftIcon={
toggleDetails ? (
<ArrowUpIcon size="4" />
) : (
<ArrowDownIcon size="4" />
)
}
onPress={handleToggleDetails}
>
{toggleDetails ? "Hide Details" : "Show Details"}
</Button>

{fields.map((item, index) => {
return <HStack space={3} alignItems="center" key={index}>
<Text bold>{item.label}:</Text>
<Text>{item.values}</Text>
</HStack>
})}
<Collapse in={toggleDetails}>
{fields.map((item, index) => {
return (
<HStack space={3} alignItems="center" key={index}>
<Text bold>{item.label}:</Text>
<Text>{item.values}</Text>
</HStack>
);
})}
</Collapse>
</Stack>
)}
<VStack space={2}>
Expand Down

0 comments on commit 85d63be

Please sign in to comment.