Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/6/group memberships #34

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 4 additions & 65 deletions frontend/components/profile-page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use client';

import { motion } from 'framer-motion';
import { Badge } from '@/components/ui/badge';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { CalendarIcon } from 'lucide-react';

import { GroupMemberships } from '@/components/profile/group-memberships';

import { ProfileHeader } from './profile/profile-header';
import { ProfilePointsHighlights } from './profile/profile-points-highlights';

Expand All @@ -19,68 +19,7 @@ export function ProfilePageComponent() {
<ProfileHeader />

{/* Groups Section */}
<Card>
<CardHeader>
<CardTitle className='text-2xl font-semibold text-gray-800'>Group Memberships</CardTitle>
</CardHeader>
<CardContent className='p-6'>
<div className='grid gap-4 sm:grid-cols-2 lg:grid-cols-4'>
{[
{
name: 'Student Council',
startDate: '2022-09-01',
currentRole: 'President',
pastRoles: ['Secretary'],
primary: true,
},
{
name: 'Debate Club',
startDate: '2021-09-01',
currentRole: 'Member',
pastRoles: ['Vice President'],
endDate: '2023-05-31',
},
{ name: 'Chess Club', startDate: '2022-01-15', currentRole: 'Treasurer', pastRoles: [] },
{ name: 'Environmental Society', startDate: '2023-03-01', currentRole: 'Member', pastRoles: [] },
].map((membership, index) => (
<motion.div key={index} whileHover={{ scale: 1.03 }} whileTap={{ scale: 0.98 }}>
<Card
key={index}
className={`h-full transition-shadow hover:shadow-md ${membership.primary ? 'border-blue-500' : ''} bg-gradient-to-br from-blue-50 to-purple-50`}
>
<CardHeader className='p-4'>
<CardTitle className='text-lg flex items-center justify-between text-gray-800'>
{membership.name}
{membership.primary && (
<Badge variant='secondary' className='bg-blue-100 text-blue-800'>
Primary
</Badge>
)}
</CardTitle>
<CardDescription className='text-xs text-gray-500'>
<div className='flex items-center'>
<CalendarIcon className='mr-1 h-3 w-3' />
Started: {membership.startDate}
{membership.endDate && ` | Ended: ${membership.endDate}`}
</div>
</CardDescription>
</CardHeader>
<CardContent className='p-4 pt-0'>
<p className='text-sm text-gray-600'>
<strong>Role:</strong> {membership.currentRole}
</p>
{membership.pastRoles.length > 0 && (
<p className='text-sm text-gray-600 mt-1'>
<strong>Past:</strong> {membership.pastRoles.join(', ')}
</p>
)}
</CardContent>
</Card>
</motion.div>
))}
</div>
</CardContent>
</Card>
<GroupMemberships />

<ProfilePointsHighlights />
</motion.div>
Expand Down
41 changes: 41 additions & 0 deletions frontend/components/profile/group-membership-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { CalendarIcon } from 'lucide-react';

import { Membership } from '@/components/profile/user.dto';
import { Badge } from '@/components/ui/badge';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';

export function GroupMembershipCard({ membership }: { membership: Membership }) {
return (
<Card
className={`h-full transition-shadow hover:shadow-md ${membership.primary ? 'border-blue-500' : ''} bg-gradient-to-br from-blue-50 to-purple-50`}
>
<CardHeader className='p-4'>
<CardTitle className='text-lg flex items-center justify-between text-gray-800'>
{membership.name}
{membership.primary && (
<Badge variant='secondary' className='bg-blue-100 text-blue-800'>
Primary
</Badge>
)}
</CardTitle>
<CardDescription className='text-xs text-gray-500'>
<div className='flex items-center'>
<CalendarIcon className='mr-1 h-3 w-3' />
Started: {membership.startDate}
{membership.endDate && ` | Ended: ${membership.endDate}`}
</div>
</CardDescription>
</CardHeader>
<CardContent className='p-4 pt-0'>
<p className='text-sm text-gray-600'>
<strong>Role:</strong> {membership.currentRole}
</p>
{membership.pastRoles.length > 0 && (
<p className='text-sm text-gray-600 mt-1'>
<strong>Past:</strong> {membership.pastRoles.join(', ')}
</p>
)}
</CardContent>
</Card>
);
}
42 changes: 42 additions & 0 deletions frontend/components/profile/group-memberships.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { motion } from 'framer-motion';

import { GroupMembershipCard } from '@/components/profile/group-membership-card';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';

export function GroupMemberships() {
const memberships = [
{
name: 'Student Council',
startDate: '2022-09-01',
currentRole: 'President',
pastRoles: ['Secretary'],
primary: true,
},
{
name: 'Debate Club',
startDate: '2021-09-01',
currentRole: 'Member',
pastRoles: ['Vice President'],
endDate: '2023-05-31',
},
{ name: 'Chess Club', startDate: '2022-01-15', currentRole: 'Treasurer', pastRoles: [] },
{ name: 'Environmental Society', startDate: '2023-03-01', currentRole: 'Member', pastRoles: [] },
];

return (
<Card>
<CardHeader>
<CardTitle className='text-2xl font-semibold text-gray-800'>Group Memberships</CardTitle>
</CardHeader>
<CardContent className='p-6'>
<div className='grid gap-4 sm:grid-cols-2 lg:grid-cols-4'>
{memberships.map((membership, index) => (
<motion.div key={index} whileHover={{ scale: 1.03 }} whileTap={{ scale: 0.98 }}>
<GroupMembershipCard membership={membership} />
</motion.div>
))}
</div>
</CardContent>
</Card>
);
}
216 changes: 108 additions & 108 deletions frontend/components/profile/user.dto.ts
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
export enum Dormitory {
UNKNOWN = "UNKNOWN",
// Add other dormitory options as needed
}
export enum Gender {
UNKNOWN = "UNKNOWN",
MALE = "MALE",
FEMALE = "FEMALE",
OTHER = "OTHER",
}
export enum StudentStatus {
UNKNOWN = "UNKNOWN",
ACTIVE = "ACTIVE",
INACTIVE = "INACTIVE",
// Add other status options as needed
}
export interface Username {
id: string;
username: string;
createdAt: Date;
}
export interface Membership {
id: string;
name: string;
startDate: Date;
endDate?: Date;
}
export interface Role {
id: string;
name: string;
}
export interface EntryAwardRequest {
id: string;
description: string;
date: Date;
}
export interface Evaluation {
id: string;
points: number;
evaluatedAt: Date;
}
export interface ExternalAccountLink {
id: string;
provider: string;
accountId: string;
}
export interface SensitiveInfoPrivacy {
id: string;
infoType: string;
isPrivate: boolean;
}
export interface Notification {
id: string;
message: string;
createdAt: Date;
read: boolean;
}
export interface PointHistory {
id: string;
points: number;
reason: string;
createdAt: Date;
}
export interface UserDTO {
// Unique Identifiers
id: string;
authSchId: string;
usernames: Username[];
// Personal Data
firstName: string;
lastName: string;
nickname: string;
isArchived: boolean;
cellPhone: string;
homeAddress: string;
dateOfBirth: Date;
room: string;
dormitory: Dormitory;
gender: Gender;
studentStatus: StudentStatus;
createdAt?: Date;
lastLogin?: Date;
// Relationships
memberships: Membership[];
roles: Role[];
requestedEntryAwards: EntryAwardRequest[];
evaluatedPointAwards: Evaluation[];
evaluatedEntryAwards: EntryAwardRequest[];
externalAccounts: ExternalAccountLink[];
sensitiveInfoPrivacies: SensitiveInfoPrivacy[];
receivedNotifications: Notification[];
sentNotifications: Notification[];
entries: EntryAwardRequest[];
points: PointHistory[];
}
UNKNOWN = 'UNKNOWN',
// Add other dormitory options as needed
}

export enum Gender {
UNKNOWN = 'UNKNOWN',
MALE = 'MALE',
FEMALE = 'FEMALE',
OTHER = 'OTHER',
}

export enum StudentStatus {
UNKNOWN = 'UNKNOWN',
ACTIVE = 'ACTIVE',
INACTIVE = 'INACTIVE',
// Add other status options as needed
}

export interface Username {
id: string;
username: string;
createdAt: Date;
}

export interface Membership {
id: string;
name: string;
startDate: Date;
endDate?: Date;
}

export interface Role {
id: string;
name: string;
}

export interface EntryAwardRequest {
id: string;
description: string;
date: Date;
}

export interface Evaluation {
id: string;
points: number;
evaluatedAt: Date;
}

export interface ExternalAccountLink {
id: string;
provider: string;
accountId: string;
}

export interface SensitiveInfoPrivacy {
id: string;
infoType: string;
isPrivate: boolean;
}

export interface Notification {
id: string;
message: string;
createdAt: Date;
read: boolean;
}

export interface PointHistory {
id: string;
points: number;
reason: string;
createdAt: Date;
}

export interface UserDTO {
// Unique Identifiers
id: string;
authSchId: string;
usernames: Username[];

// Personal Data
firstName: string;
lastName: string;
nickname: string;
isArchived: boolean;
cellPhone: string;
homeAddress: string;
dateOfBirth: Date;
room: string;
dormitory: Dormitory;
gender: Gender;
studentStatus: StudentStatus;
createdAt?: Date;
lastLogin?: Date;

// Relationships
memberships: Membership[];
roles: Role[];
requestedEntryAwards: EntryAwardRequest[];
evaluatedPointAwards: Evaluation[];
evaluatedEntryAwards: EntryAwardRequest[];
externalAccounts: ExternalAccountLink[];
sensitiveInfoPrivacies: SensitiveInfoPrivacy[];
receivedNotifications: Notification[];
sentNotifications: Notification[];
entries: EntryAwardRequest[];
points: PointHistory[];
}
Loading
Loading