Skip to content

Commit

Permalink
Merge pull request #51 from vaivk369/oblf
Browse files Browse the repository at this point in the history
Issue #000 UI fixes
  • Loading branch information
vaivk369 authored Feb 23, 2024
2 parents 5d434a8 + cd551a6 commit 2ac21c3
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 15 deletions.
27 changes: 24 additions & 3 deletions packages/cohort/src/pages/CohortDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ const CohortDetails = ({ footerLinks, setAlert, appName }) => {
const [selfAttendance, setSelfAttendance] = React.useState({});
const [showModal, setShowModal] = React.useState(false);
const [cohortDetails, setCohortDetails] = React.useState({});
const [cohortParentDetails, setCohortParentDetails] = React.useState(true);
const [toggleDetails, setToggleDetails] = React.useState(true);
const [fields, setFields] = React.useState([]);
const [loading, setLoading] = React.useState(true);
let newAvatar = localStorage.getItem("firstName");
let newAvatar = localStorage.getItem("fullName");
const [userId, setUserId] = React.useState();
const { cohortId } = useParams();
const [attendanceStatusData, setAttendanceStatusData] = React.useState();
Expand Down Expand Up @@ -138,6 +139,15 @@ const CohortDetails = ({ footerLinks, setAlert, appName }) => {
// },
];

let getInitials = function (string) {
let names = string.split(' '), initials = names[0].substring(0, 1).toUpperCase();

if (names.length > 1) {
initials += names[names.length - 1].substring(0, 1).toUpperCase();
}
return initials;
};

const getFieldValues = (cohortsFields) => {
let fieldVals = [];
cohortsFields.map((item) => {
Expand Down Expand Up @@ -202,6 +212,17 @@ const CohortDetails = ({ footerLinks, setAlert, appName }) => {
getFieldValues(result[0].fields);
setSelfAttendance(result[0]);
}
const parentResult = await cohortRegistryService.getCohortDetails(
{
cohortId: result[0].parentId,
},
{
tenantid: process.env.REACT_APP_TENANT_ID,
}
);
if (parentResult.length) {
setCohortParentDetails(parentResult[0]);
}
}
setLoading(false);
};
Expand All @@ -225,7 +246,7 @@ const CohortDetails = ({ footerLinks, setAlert, appName }) => {
>
<Layout
_header={{
title: cohortDetails?.name,
title: cohortParentDetails?.name + ", " + " Level " + cohortDetails?.name,
subHeading: moment().format("hh:mm A"),
iconComponent: (
<Pressable>
Expand All @@ -238,7 +259,7 @@ const CohortDetails = ({ footerLinks, setAlert, appName }) => {
size="50px"
/>
) : (
<Avatar>{newAvatar?.toUpperCase().substr(0, 2)}</Avatar>
<Avatar>{getInitials(newAvatar)}</Avatar>
)}
</Pressable>
),
Expand Down
32 changes: 26 additions & 6 deletions packages/cohort/src/pages/CohortMemberList.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function CohortMemberList({ footerLinks, appName }) {
const [width, height] = useWindowSize();
const [loading, setLoading] = React.useState(true);
const [cohortDetails, setCohortDetails] = React.useState({});
const [cohortParentDetails, setCohortParentDetails] = React.useState(true);
const [attendanceStatusData, setAttendanceStatusData] = React.useState();
let newAvatar = localStorage.getItem("firstName");

Expand All @@ -55,6 +56,14 @@ export default function CohortMemberList({ footerLinks, appName }) {
},
}
: {};
let getInitials = function (string) {
let names = string.split(' '), initials = names[0].substring(0, 1).toUpperCase();

if (names.length > 1) {
initials += names[names.length - 1].substring(0, 1).toUpperCase();
}
return initials;
};
useEffect(() => {
let ignore = false;
const getData = async () => {
Expand Down Expand Up @@ -124,6 +133,17 @@ export default function CohortMemberList({ footerLinks, appName }) {
setMembers(results[0]);
}
setCohortDetails(results[1][0]);
const parentResult = await cohortRegistryService.getCohortDetails(
{
cohortId: results[1][0].parentId,
},
{
tenantid: process.env.REACT_APP_TENANT_ID,
}
);
if (parentResult.length) {
setCohortParentDetails(parentResult[0]);
}
setLoading(false);
}
};
Expand All @@ -144,7 +164,7 @@ export default function CohortMemberList({ footerLinks, appName }) {
>
<Layout
_header={{
title: cohortDetails?.name,
title: loading ? "" : cohortParentDetails?.name + ", " + " Level " + cohortDetails?.name,
subHeading: moment().format("hh:mm A"),
iconComponent: (
<Pressable>
Expand All @@ -157,7 +177,7 @@ export default function CohortMemberList({ footerLinks, appName }) {
size="50px"
/>
) : (
<Avatar>{newAvatar?.toUpperCase().substr(0, 2)}</Avatar>
<Avatar>{getInitials(newAvatar)}</Avatar>
)}
</Pressable>
),
Expand Down Expand Up @@ -191,10 +211,10 @@ export default function CohortMemberList({ footerLinks, appName }) {
rounded={"lg"}
key={index}
style={{
background:
index % 2 === 0
? "linear-gradient(281.03deg, #FC5858 -21.15%, #F8AF5A 100.04%)"
: "linear-gradient(102.88deg, #D7BEE6 -5.88%, #B143F3 116.6%)",
background: "linear-gradient(315deg, #f1f2f6 0%, #c9c6c6 74%)"
// index % 2 === 0
// ? "linear-gradient(281.03deg, #FC5858 -21.15%, #F8AF5A 100.04%)"
// : "linear-gradient(102.88deg, #D7BEE6 -5.88%, #B143F3 116.6%)",
}}
_text={{
fontSize: "md",
Expand Down
13 changes: 10 additions & 3 deletions packages/teacher-app/src/pages/Generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ function Generic({ footerLinks, appName, setAlert }) {
},
}
: {};

let getInitials = function (string) {
let names = string.split(' '), initials = names[0].substring(0, 1).toUpperCase();

if (names.length > 1) {
initials += names[names.length - 1].substring(0, 1).toUpperCase();
}
return initials;
};
const widgetData = [
// {
// title: t("QUICK_CHECK"),
Expand Down Expand Up @@ -193,7 +200,7 @@ function Generic({ footerLinks, appName, setAlert }) {
size="50px"
/>
) : (
<Avatar>{newAvatar?.toUpperCase().substr(0, 2)}</Avatar>
<Avatar>{getInitials(fullName)}</Avatar>
)}
{selfAttendance?.attendance ? (
<IconByName
Expand Down Expand Up @@ -248,7 +255,7 @@ function Generic({ footerLinks, appName, setAlert }) {
uri: "https://png.pngtree.com/png-clipart/20210915/ourlarge/pngtree-user-avatar-placeholder-png-image_3918418.jpg",
}}
>
{fullName?.toUpperCase().substr(0, 2)}
{getInitials(fullName)}
</Avatar>
<Heading size="md" textAlign="center">
{fullName}
Expand Down
13 changes: 11 additions & 2 deletions packages/teacher-app/src/pages/MyClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ const MyClasses = ({ footerLinks, setAlert, appName }) => {
}
: {};

let getInitials = function (string) {
let names = string.split(' '), initials = names[0].substring(0, 1).toUpperCase();

if (names.length > 1) {
initials += names[names.length - 1].substring(0, 1).toUpperCase();
}
return initials;
};

React.useEffect(() => {
capture("PAGE");
}, []);
Expand Down Expand Up @@ -80,8 +89,8 @@ const MyClasses = ({ footerLinks, setAlert, appName }) => {
size="50px"
/>
) : (
<Avatar>{newAvatar?.toUpperCase().substr(0, 2)}</Avatar>
)}
<Avatar>{getInitials(newAvatar)}</Avatar>
)}
{selfAttendance?.attendance ? (
<IconByName
name={
Expand Down
10 changes: 9 additions & 1 deletion packages/teacher-app/src/pages/TeacherHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ function Home({ footerLinks, appName, setAlert }) {
},
}
: {};
let getInitials = function (string) {
let names = string.split(' '), initials = names[0].substring(0, 1).toUpperCase();

if (names.length > 1) {
initials += names[names.length - 1].substring(0, 1).toUpperCase();
}
return initials;
};

const widgetData = [
{
Expand Down Expand Up @@ -192,7 +200,7 @@ function Home({ footerLinks, appName, setAlert }) {
size="50px"
/>
) : (
<Avatar>{newAvatar?.toUpperCase().substr(0, 2)}</Avatar>
<Avatar>{getInitials(newAvatar)}</Avatar>
)}
{selfAttendance?.attendance ? (
<IconByName
Expand Down

0 comments on commit 2ac21c3

Please sign in to comment.