Skip to content

Commit

Permalink
fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
FeimeiChen committed Mar 29, 2024
1 parent b9eb304 commit 2d0ca76
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 52 deletions.
30 changes: 19 additions & 11 deletions ui/src/app/(index)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import BeforeLogin from '@/components/home/BeforeLogin';
import AfterLogin from '@/components/home/AfterLogin';
import {getCurrentUser} from '@/access/AuthenticationService';
import Role from '@/access/Role';
import LoginButton from "@/components/home/LoginButton";
import {getAnnouncements, getNumberOfGroupings, getNumberOfMemberships} from "@/services/GroupingsApiService";
import React from "react";
import Announcement from "@/components/home/Announcement";
import LoginButton from '@/components/home/LoginButton';
import {getAnnouncements, getNumberOfGroupings, getNumberOfMemberships} from '@/services/GroupingsApiService';
import React from 'react';
import Announcement from '@/components/home/Announcement';

const Home = async () => {
const [currentUser, numberOfGroupings, numberOfMemberships, announcements] = await Promise.all([
Expand All @@ -16,15 +16,21 @@ const Home = async () => {
getAnnouncements()
]);

const handleAnnouncements = () => announcements.hasOwnProperty("announcements") ? announcements.announcements
.filter((announcement) => announcement.state === "Active")
.map((announcement) => announcement.message) : [];
const handleAnnouncements = () => {
if (Object.prototype.hasOwnProperty.call(announcements, 'announcements')) {
return announcements.announcements
.filter((announcement) => announcement.state !== 'Active')
.map((announcement) => announcement.message);
} else {
return [];
}
};

return (
<main>
<div className="container mt-5 mb-5">
{handleAnnouncements().map((announcement: String) => (
<div>
{handleAnnouncements().map((announcement: string, index: number) => (
<div key={index}>
<Announcement announcement={announcement}/>
</div>
))}
Expand Down Expand Up @@ -60,8 +66,10 @@ const Home = async () => {
</div>

{currentUser && currentUser.roles.includes(Role.UH) ? (
<AfterLogin currentUser={currentUser} numberOfGroupings={numberOfGroupings}
numberOfMemberships={numberOfMemberships}/>
<AfterLogin
currentUser={currentUser}
numberOfGroupings={numberOfGroupings}
numberOfMemberships={numberOfMemberships}/>
) : (
<BeforeLogin/>
)}
Expand Down
17 changes: 9 additions & 8 deletions ui/src/components/UHGroupingsInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from "react";
import Image from "next/image";
import About from "@/app/about/page";
import AboutInfoItem from "@/components/AboutInfoItem";
import React from 'react';
import AboutInfoItem from '@/components/AboutInfoItem';

const UHGroupingsInfo = ({h1Color, h1Weight, AboutInfoItemSize}: { h1Color: string, h1Weight: string, AboutInfoItemSize?: string }) => {
const textSize = AboutInfoItemSize ? AboutInfoItemSize : "text-base";
const textSize = AboutInfoItemSize ? AboutInfoItemSize : 'text-base';
return (
<div>
<div className="bg-seafoam pt-10 pb-10">
Expand All @@ -20,17 +18,20 @@ const UHGroupingsInfo = ({h1Color, h1Weight, AboutInfoItemSize}: { h1Color: stri
pSize={textSize}
src={"/uhgroupings/cogs.svg"}
alt={"Cogs icon"}
description={"Create groupings, manage grouping memberships, control members' self-service options, designate sync destinations, and more."}/>
description={"Create groupings, manage grouping memberships, control members' " +
"self-service options, designate sync destinations, and more."}/>
<AboutInfoItem
pSize={textSize}
src={"/uhgroupings/id-email.svg"}
alt={"Email icon"}
description={"Synchronize groupings email LISTSERV lists, attributes for access control via CAS and LDAP, etc.."}/>
description={"Synchronize groupings email LISTSERV lists," +
" attributes for access control via CAS and LDAP, etc.."}/>
<AboutInfoItem
pSize={textSize}
src={"/uhgroupings/watch.svg"}
alt={"Watch icon"}
description={"Leverage group data from official sources, which can substantially reduce the manual overhead of membership management."}/>
description={"Leverage group data from official sources," +
" which can substantially reduce the manual overhead of membership management."}/>
</div>
</div>
</div>
Expand Down
40 changes: 20 additions & 20 deletions ui/src/components/home/AfterLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import User from "@/access/User";
import Role from "@/access/Role";
import User from '@/access/User';
import Role from '@/access/Role';
import Image from 'next/image';
import React from "react";
import {KeyRound} from "lucide-react";
import UserInfoItem from "@/components/home/UserInfoItem";
import React from 'react';
import {KeyRound} from 'lucide-react';
import UserInfoItem from '@/components/home/UserInfoItem';

const AfterLogin = ({
currentUser,
numberOfGroupings,
numberOfMemberships
}: {
currentUser: User,
numberOfGroupings: number,
numberOfMemberships: number
}) => {
const AfterLogin = (
{
currentUser,
numberOfGroupings,
numberOfMemberships
}: {
currentUser: User,
numberOfGroupings: number,
numberOfMemberships: number
}) => {
const isAdmin = currentUser.roles.includes(Role.ADMIN);
const isOwner = currentUser.roles.includes(Role.OWNER);
const getHighestRole = () => isAdmin ? "Admin" : isOwner ? "Owner" : "Member";
const getHighestRole = () => isAdmin ? 'Admin' : isOwner ? 'Owner' : 'Member';

return (
<main>
<div className="bg-seafoam pt-5 pb-5">
<div className="container bg-seafoam pt-7 pb-7">
<div className="grid sm:grid-cols-12 text-center justify-center items-center gap-4">
<div className="sm:col-span-3 md:col-span-2">
<div
className="flex justify-center items-center rounded-full h-[100px] w-[100px] bg-white mx-auto relative lg:ml-0">
<div className="flex justify-center items-center rounded-full h-[100px] w-[100px] bg-white mx-auto relative lg:ml-0">
<Image
src="/uhgroupings/user-solid.svg"
alt="user-solid"
Expand All @@ -50,11 +50,11 @@ const AfterLogin = ({

<div className="container grid grid-cols-1 md:grid-cols-3 gap-6 md:gap-8 mt-10 mb-10">
{isAdmin && <UserInfoItem
alt={"key-soild"}
src={"uhgroupings/key-solid.svg"}
alt={'key-soild'}
src={'uhgroupings/key-solid.svg'}
number={0}
show={false}
title={"Administration"}
title={'Administration'}
description={"Manage the list of Administrators for this service. Search for and manage any grouping on behalf of the owner."}
link={"/admin"}
text={"Admin"}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/home/BeforeLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import UHGroupingsInfo from '@/components/UHGroupingsInfo';
const BeforeLogin = () => {
return (
<main className="bg-seafoam pb-10">
<UHGroupingsInfo h1Color={"text-text-color"} AboutInfoItemSize={"text-1.2"} h1Weight={"font-light"}/>
<UHGroupingsInfo h1Color={'text-text-color'} AboutInfoItemSize={'text-1.2'} h1Weight={'font-light'}/>
<div className="row">
<div className="text-center">
<LearnMoreButton/>
Expand Down
32 changes: 20 additions & 12 deletions ui/src/components/home/UserInfoItem.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import React from 'react';
import Image from 'next/image';
import Link from 'next/link';
import {Button} from "@/components/ui/button";
import {Button} from '@/components/ui/button';

const UserInfoItem = (
{alt, src, number, show, title, description, link, text}:
{
alt: string,
src: string,
number: number,
show: boolean,
title: string,
description: string,
link: string,
text: string
}) => {
{
alt,
src,
number,
show,
title,
description,
link,
text
}: {
alt: string,
src: string,
number: number,
show: boolean,
title: string,
description: string,
link: string,
text: string
}) => {
return (
<div className="flex flex-col justify-between">
<div>
Expand Down

0 comments on commit 2d0ca76

Please sign in to comment.