Skip to content

Commit

Permalink
Reorganize files for /actions and /models, remove server action decla…
Browse files Browse the repository at this point in the history
…ration for GET requests (#86)
  • Loading branch information
JorWo authored Sep 18, 2024
1 parent 1064efb commit 4b37cd9
Show file tree
Hide file tree
Showing 34 changed files with 1,306 additions and 1,417 deletions.
30 changes: 15 additions & 15 deletions ui/components.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "slate",
"cssVariables": false,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/components/ui/utils"
}
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "slate",
"cssVariables": false,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
8 changes: 4 additions & 4 deletions ui/src/access/user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { MemberResult } from '@/models/groupings-api-results';
import { MemberResult } from '@/lib/types';
import Role from './role';

type User = {
roles: Role[]
} & MemberResult
roles: Role[];
} & MemberResult;

export const AnonymousUser: User = {
name: '',
Expand All @@ -12,6 +12,6 @@ export const AnonymousUser: User = {
uid: '',
uhUuid: '',
roles: [Role.ANONYMOUS] as const
}
};

export default User;
48 changes: 0 additions & 48 deletions ui/src/actions/email.ts

This file was deleted.

56 changes: 30 additions & 26 deletions ui/src/app/(home)/_components/after-login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Image from 'next/image';
import { KeyRound } from 'lucide-react';
import Link from 'next/link';
import { Button } from '@/components/ui/button';
import { getNumberOfGroupings, getNumberOfMemberships } from '@/actions/groupings-api';
import { getNumberOfGroupings, getNumberOfMemberships } from '@/lib/fetchers';
import { getCurrentUser } from '@/access/authentication';

const AfterLogin = async () => {
Expand All @@ -22,14 +22,15 @@ const AfterLogin = async () => {
const pageInfoItems = [
{
title: 'Admin',
description: 'Manage the list of Administrators for this service.' +
description:
'Manage the list of Administrators for this service.' +
' Search for and manage any grouping on behalf of the owner.',
href: '/admin',
icon: {
alt: 'key-solid',
src: '/uhgroupings/key-solid.svg',
width: 48,
height: 48,
height: 48
},
role: Role.ADMIN
},
Expand All @@ -41,15 +42,15 @@ const AfterLogin = async () => {
src: '/uhgroupings/id-card-solid.svg',
alt: 'id-card',
width: 54,
height: 48,
height: 48
},
number: numberOfMemberships,
role: Role.UH
},
{
title: 'Groupings',
description: 'Review members, manage Include and Exclude lists, ' +
'configure preferences, and export members.',
description:
'Review members, manage Include and Exclude lists, ' + 'configure preferences, and export members.',
href: '/groupings',
icon: {
alt: 'wrench-solid',
Expand All @@ -68,36 +69,37 @@ const AfterLogin = async () => {
<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">
<Image
src="/uhgroupings/user-solid.svg"
alt="user-solid"
width={56}
height={64}
/>
<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" width={56} height={64} />
<div
className="bg-blue-background rounded-full flex justify-center
items-center h-[30px] w-[30px] absolute left-3 bottom-0 ml-16">
<KeyRound className="fill-white stroke-none p-0.5" aria-label='key-round'/>
items-center h-[30px] w-[30px] absolute left-3 bottom-0 ml-16"
>
<KeyRound className="fill-white stroke-none p-0.5" aria-label="key-round" />
</div>
</div>
</div>
<div className="sm:col-span-9 md:col-span-10 text-center md:text-left">
<h1 className="whitespace-nowrap text-[1.75rem]"
data-testid="welcome-message">Welcome, <span
className="text-text-color">{currentUser.firstName}</span>!</h1>
<h1 className="whitespace-nowrap text-[1.75rem]" data-testid="role">Role: <span
className="text-text-color">{getHighestRole()}</span></h1>
<h1 className="whitespace-nowrap text-[1.75rem]" data-testid="welcome-message">
Welcome, <span className="text-text-color">{currentUser.firstName}</span>!
</h1>
<h1 className="whitespace-nowrap text-[1.75rem]" data-testid="role">
Role: <span className="text-text-color">{getHighestRole()}</span>
</h1>
</div>
</div>
</div>
</div>

<div className="container grid grid-cols-1 md:grid-cols-3 gap-6 md:gap-8 mt-10 mb-10">
{pageInfoItems
.filter((pageInfoItem) => currentUser.roles.includes(Role.ADMIN)
|| currentUser.roles.includes(pageInfoItem.role))
.filter(
(pageInfoItem) =>
currentUser.roles.includes(Role.ADMIN) || currentUser.roles.includes(pageInfoItem.role)
)
.map((pageInfoItem, index) => (
<div key={index} className="flex flex-col justify-between">
<div>
Expand All @@ -107,9 +109,11 @@ const AfterLogin = async () => {
src={pageInfoItem.icon.src}
width={pageInfoItem.icon.width}
height={pageInfoItem.icon.height}
className={`mr-5 mb-4 max-w-${pageInfoItem.icon.width} h-auto`}/>
{pageInfoItem.number !== null
&& <span className="text-[2.5rem] text-text-color">{pageInfoItem.number}</span>}
className={`mr-5 mb-4 max-w-${pageInfoItem.icon.width} h-auto`}
/>
{pageInfoItem.number !== null && (
<span className="text-[2.5rem] text-text-color">{pageInfoItem.number}</span>
)}
</div>
<h2 className="text-2xl text-text-color font-medium mb-2">{pageInfoItem.title}</h2>
<p className="mb-4 text-base font-normal">{pageInfoItem.description}</p>
Expand Down
17 changes: 8 additions & 9 deletions ui/src/app/(home)/_components/announcements.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { AlertCircle } from 'lucide-react';
import { getAnnouncements } from '@/actions/groupings-api';
import { getAnnouncements } from '@/lib/fetchers';

const Announcements = async () => {
const announcements = await getAnnouncements();
const activeAnnouncements = () => {
if (!announcements || !announcements.announcements) {
return []
return [];
}
return announcements.announcements
.filter((announcement) => announcement.state === 'Active')
.map((announcement) => announcement.message)
.map((announcement) => announcement.message);
};

return (
<div className="mt-5 mb-5">
{activeAnnouncements().map((announcement:string, index:number) => (
{activeAnnouncements().map((announcement: string, index: number) => (
<Alert key={index} className="bg-yellow-100 border border-yellow-200 mb-2">
<AlertCircle aria-label="icon" className="h-4 w-4"/>
<AlertCircle aria-label="icon" className="h-4 w-4" />
<AlertTitle className="font-semibold">Announcement</AlertTitle>
<AlertDescription>
{announcement}
</AlertDescription>
</Alert>))}
<AlertDescription>{announcement}</AlertDescription>
</Alert>
))}
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/feedback/_components/feedback-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '
import { z } from 'zod';
import { zodResolver } from '@hookform/resolvers/zod';
import { useForm } from 'react-hook-form';
import { sendFeedback } from '@/actions/email';
import { sendFeedback } from '@/lib/actions';
import User from '@/access/user';
import { Textarea } from '@/components/ui/textarea';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
Expand Down
Loading

0 comments on commit 4b37cd9

Please sign in to comment.