diff --git a/apps/frontend/package.json b/apps/frontend/package.json index e0a601e..6e0bc19 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -12,6 +12,9 @@ "lint": "next lint" }, "dependencies": { + "@radix-ui/react-avatar": "^1.1.1", + "@radix-ui/react-slot": "^1.1.0", + "axios": "^1.7.9", "class-variance-authority": "^0.7.0", "clsx": "^2.1.0", "lucide-react": "^0.372.0", @@ -25,9 +28,9 @@ "@types/node": "^20.12.7", "@types/react": "^18.2.79", "@types/react-dom": "^18.2.25", + "eslint-plugin-react": "^7.34.1", "postcss": "^8.4.38", "tailwindcss": "^3.4.3", - "typescript": "^5.4.5", - "eslint-plugin-react": "^7.34.1" + "typescript": "^5.4.5" } } 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..6f307df --- /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 '@/components/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 new file mode 100644 index 0000000..594cee6 --- /dev/null +++ b/apps/frontend/src/components/ui/avatar.tsx @@ -0,0 +1,44 @@ +/* eslint-disable react/prop-types */ +'use client'; + +import * as AvatarPrimitive from '@radix-ui/react-avatar'; +import * as React from 'react'; + +import { cn } from '@/lib/utils'; + +const Avatar = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +Avatar.displayName = AvatarPrimitive.Root.displayName; + +const AvatarImage = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +AvatarImage.displayName = AvatarPrimitive.Image.displayName; + +const AvatarFallback = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ 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..536e282 --- /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-slate-900 text-slate-50 hover:bg-slate-900/80 dark:bg-slate-50 dark:text-slate-900 dark:hover:bg-slate-50/80', + secondary: + 'border-transparent bg-slate-100 text-slate-900 hover:bg-slate-100/80 dark:bg-slate-800 dark:text-slate-50 dark:hover:bg-slate-800/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/button.tsx b/apps/frontend/src/components/ui/button.tsx new file mode 100644 index 0000000..79e1bab --- /dev/null +++ b/apps/frontend/src/components/ui/button.tsx @@ -0,0 +1,51 @@ +import { Slot } from '@radix-ui/react-slot'; +import { cva, type VariantProps } from 'class-variance-authority'; +import * as React from 'react'; + +import { cn } from '@/lib/utils'; + +const buttonVariants = cva( + 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 dark:ring-offset-slate-950 dark:focus-visible:ring-slate-300', + { + variants: { + variant: { + default: + 'bg-slate-900 text-slate-50 hover:bg-slate-900/90 dark:bg-slate-50 dark:text-slate-900 dark:hover:bg-slate-50/90', + destructive: + 'bg-red-500 text-slate-50 hover:bg-red-500/90 dark:bg-red-900 dark:text-slate-50 dark:hover:bg-red-900/90', + outline: + 'border border-slate-200 bg-white hover:bg-slate-100 hover:text-slate-900 dark:border-slate-800 dark:bg-slate-950 dark:hover:bg-slate-800 dark:hover:text-slate-50', + secondary: + 'bg-slate-100 text-slate-900 hover:bg-slate-100/80 dark:bg-slate-800 dark:text-slate-50 dark:hover:bg-slate-800/80', + ghost: 'hover:bg-slate-100 hover:text-slate-900 dark:hover:bg-slate-800 dark:hover:text-slate-50', + link: 'text-slate-900 underline-offset-4 hover:underline dark:text-slate-50', + }, + size: { + default: 'h-10 px-4 py-2', + sm: 'h-9 rounded-md px-3', + lg: 'h-11 rounded-md px-8', + icon: 'h-10 w-10', + }, + }, + defaultVariants: { + variant: 'default', + size: 'default', + }, + } +); + +export interface ButtonProps + extends React.ButtonHTMLAttributes, + VariantProps { + asChild?: boolean; +} + +const Button = React.forwardRef( + ({ className, variant, size, asChild = false, ...props }, ref) => { + const Comp = asChild ? Slot : 'button'; + return ; + } +); +Button.displayName = 'Button'; + +export { Button, buttonVariants }; diff --git a/apps/frontend/src/components/ui/card.tsx b/apps/frontend/src/components/ui/card.tsx new file mode 100644 index 0000000..3e39dd3 --- /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/components/user-dto.tsx b/apps/frontend/src/components/user-dto.tsx new file mode 100644 index 0000000..ce56949 --- /dev/null +++ b/apps/frontend/src/components/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}