diff --git a/apps/backend/src/main.ts b/apps/backend/src/main.ts index 0ecd081..23c571a 100644 --- a/apps/backend/src/main.ts +++ b/apps/backend/src/main.ts @@ -10,6 +10,7 @@ async function bootstrap() { whitelist: true, }) ); + app.enableCors(); await app.listen(3001); } bootstrap(); diff --git a/apps/frontend/package.json b/apps/frontend/package.json index ca4f32c..744972c 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -20,11 +20,14 @@ "@tanstack/react-table": "^8.20.5", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", - "framer-motion": "^11.14.4", + "axios": "^1.7.9", + "framer": "^2.4.1", + "framer-motion": "^11.15.0", "geist": "^1.3.1", "lucide-react": "^0.468.0", "next": "14.2.13", "next-themes": "^0.4.4", + "radix-ui": "^1.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", "shadcn": "^2.1.7", diff --git a/apps/frontend/src/app/profile/[id]/page.tsx b/apps/frontend/src/app/profile/[id]/page.tsx new file mode 100644 index 0000000..64c6767 --- /dev/null +++ b/apps/frontend/src/app/profile/[id]/page.tsx @@ -0,0 +1,5 @@ +import ProfilePageComponent from '@/components/profile-page'; + +export default function ProfilePage() { + return ; +} diff --git a/apps/frontend/src/components/profile-page.tsx b/apps/frontend/src/components/profile-page.tsx new file mode 100644 index 0000000..ca5aeaa --- /dev/null +++ b/apps/frontend/src/components/profile-page.tsx @@ -0,0 +1,72 @@ +'use client'; + +import axios from 'axios'; +import { useParams } from 'next/navigation'; +import { useEffect, useState } from 'react'; + +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; +import { Badge } from '@/components/ui/badge'; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { User } from '@/types/user-dto'; + +const url = 'http://localhost:3001/users/'; + +export default function ProfilePageComponent() { + const [user, setUser] = useState(); + const userId = useParams().id; + const finalURL = url + userId; + + const getUser = async () => { + axios.get(finalURL).then((res) => { + setUser(res.data); + }); + }; + + useEffect(() => { + getUser(); + }, []); + + return ( + + + + + + + {user?.name + .split(' ') + .map((n) => n[0]) + .join('')} + + + + {user?.name} + {user?.email} + + + + + + Phone Number + {user?.phone} + + + Room Number + {user?.roomNumber} + + + + + {user?.isDormResident ? 'Kolis' : 'Nem kolis'} + + + {user?.role === 'ADMIN' || user?.role === 'GATEKEEPER' ? 'Beengedő' : 'Felhasználó'} + + + + + + + + ); +} diff --git a/apps/frontend/src/components/ui/avatar.tsx b/apps/frontend/src/components/ui/avatar.tsx index d797adc..562202b 100644 --- a/apps/frontend/src/components/ui/avatar.tsx +++ b/apps/frontend/src/components/ui/avatar.tsx @@ -29,13 +29,8 @@ AvatarImage.displayName = AvatarPrimitive.Image.displayName; const AvatarFallback = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); + // eslint-disable-next-line @typescript-eslint/no-unused-vars +>(({ className, ...props }, ref) => ); AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; export { Avatar, AvatarFallback, AvatarImage }; diff --git a/apps/frontend/src/components/ui/badge.tsx b/apps/frontend/src/components/ui/badge.tsx new file mode 100644 index 0000000..ddffd45 --- /dev/null +++ b/apps/frontend/src/components/ui/badge.tsx @@ -0,0 +1,32 @@ +import { cva, type VariantProps } from 'class-variance-authority'; +import * as React from 'react'; + +import { cn } from '@/lib/utils'; + +const badgeVariants = cva( + 'inline-flex items-center rounded-full border border-slate-200 px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-slate-950 focus:ring-offset-2 dark:border-slate-800 dark:focus:ring-slate-300', + { + variants: { + variant: { + default: + 'border-transparent bg-orange-500 text-slate-50 hover:bg-orange-400/80 dark:bg-orange-700 dark:text-slate-50 dark:hover:bg-orange-500/80', + secondary: + 'border-transparent bg-slate-100 text-slate-900 hover:bg-slate-400/80 dark:bg-zinc-700 dark:text-slate-50 dark:hover:bg-zinc-500/80', + destructive: + 'border-transparent bg-red-500 text-slate-50 hover:bg-red-500/80 dark:bg-red-900 dark:text-slate-50 dark:hover:bg-red-900/80', + outline: 'text-slate-950 dark:text-slate-50', + }, + }, + defaultVariants: { + variant: 'default', + }, + } +); + +export interface BadgeProps extends React.HTMLAttributes, VariantProps {} + +function Badge({ className, variant, ...props }: BadgeProps) { + return ; +} + +export { Badge, badgeVariants }; diff --git a/apps/frontend/src/components/ui/card.tsx b/apps/frontend/src/components/ui/card.tsx new file mode 100644 index 0000000..45f7a8d --- /dev/null +++ b/apps/frontend/src/components/ui/card.tsx @@ -0,0 +1,49 @@ +/* eslint-disable react/prop-types */ +import * as React from 'react'; + +import { cn } from '@/lib/utils'; + +const Card = React.forwardRef>(({ className, ...props }, ref) => ( + +)); +Card.displayName = 'Card'; + +const CardHeader = React.forwardRef>( + ({ className, ...props }, ref) => ( + + ) +); +CardHeader.displayName = 'CardHeader'; + +const CardTitle = React.forwardRef>( + ({ className, ...props }, ref) => ( + + ) +); +CardTitle.displayName = 'CardTitle'; + +const CardDescription = React.forwardRef>( + ({ className, ...props }, ref) => ( + + ) +); +CardDescription.displayName = 'CardDescription'; + +const CardContent = React.forwardRef>( + ({ className, ...props }, ref) => +); +CardContent.displayName = 'CardContent'; + +const CardFooter = React.forwardRef>( + ({ className, ...props }, ref) => +); +CardFooter.displayName = 'CardFooter'; + +export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle }; diff --git a/apps/frontend/src/types/user-dto.tsx b/apps/frontend/src/types/user-dto.tsx new file mode 100644 index 0000000..ce56949 --- /dev/null +++ b/apps/frontend/src/types/user-dto.tsx @@ -0,0 +1,15 @@ +import { CardRight, ProfilePicture } from '@prisma/client'; + +export type User = { + id: number; + name: string; + email: string; + phone?: string; + isDormResident: boolean; + roomNumber?: string; + role: string; + cardRight?: CardRight; + profilePicture?: ProfilePicture; + created_at: string; + updated_at: string; +};
{user?.email}