generated from kir-dev/next-nest-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* admin panel separation * tinder card * kinda ready animations and more detailed data maybe? * does not build but works xd * builds * icons and little mod * fixes * set to manufactured button fix * merge fix * icon fix * builds i guess
- Loading branch information
1 parent
b7541d9
commit 6a9c0e4
Showing
14 changed files
with
378 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use client'; | ||
import { useRouter } from 'next/navigation'; | ||
import React from 'react'; | ||
import { FiGrid, FiShield, FiUserCheck } from 'react-icons/fi'; | ||
|
||
import Th1 from '@/components/typography/typography'; | ||
import { Button } from '@/components/ui/button'; | ||
|
||
export default function Page() { | ||
const router = useRouter(); | ||
return ( | ||
<> | ||
<Th1>Admin</Th1> | ||
<div className='flex w-full gap-4 max-lg:flex-col'> | ||
<Button onClick={() => router.push('/profile-picture-check')}> | ||
<FiUserCheck /> | ||
Profileképek ellenőrzése | ||
</Button> | ||
<Button onClick={() => router.push('/roles')}> | ||
<FiShield /> | ||
Szerepkörök kezelése | ||
</Button> | ||
<Button onClick={() => router.push('/periods')}> | ||
<FiGrid /> | ||
Időszakok kezelése | ||
</Button> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use client'; | ||
import { useRouter } from 'next/navigation'; | ||
import React from 'react'; | ||
|
||
import api from '@/components/network/apiSetup'; | ||
import { Th2 } from '@/components/typography/typography'; | ||
import { Button } from '@/components/ui/button'; | ||
import { Card } from '@/components/ui/card'; | ||
import LoadingCard from '@/components/ui/LoadingCard'; | ||
import ProfilePictureTinderCard from '@/components/ui/ProfilePictureTinderCard'; | ||
import { usePendingPictures } from '@/hooks/usePendingPictures'; | ||
|
||
export default function Page() { | ||
const [counter, setCounter] = React.useState(0); | ||
const { data, isLoading, mutate } = usePendingPictures(); | ||
const [currentPicture, setCurrentPicture] = React.useState(0); | ||
const [isMutating, setIsMutating] = React.useState(false); | ||
const onAccept = async () => { | ||
if (!data) return; | ||
await api.patch(`users/${data![currentPicture].user.authSchId}/profile-picture/ACCEPTED`); | ||
await showNextPicture(); | ||
}; | ||
const onReject = async () => { | ||
if (!data) return; | ||
await api.patch(`users/${data![currentPicture].user.authSchId}/profile-picture/REJECTED`); | ||
await showNextPicture(); | ||
}; | ||
const onSkip = async () => { | ||
await showNextPicture(); | ||
}; | ||
const showNextPicture = async () => { | ||
if (!data) return; | ||
setIsMutating(true); | ||
setCounter(counter + 1); | ||
if (currentPicture === data!.length - 1) { | ||
await mutate(); | ||
setCurrentPicture(data.length === 0 ? -1 : 0); | ||
} else { | ||
setCurrentPicture(currentPicture + 1); | ||
} | ||
setIsMutating(false); | ||
}; | ||
|
||
const router = useRouter(); | ||
|
||
return ( | ||
<Card className='flex flex-col items-center w-full gap-4 p-8'> | ||
{isLoading && <LoadingCard />} | ||
{data && data.length === 0 && <p>Most nincs elbirálandó kép</p>} | ||
{data && currentPicture > -1 && data[currentPicture] && ( | ||
<> | ||
<ProfilePictureTinderCard | ||
user={data[currentPicture].user} | ||
onAccept={onAccept} | ||
onReject={onReject} | ||
onSkip={onSkip} | ||
isMutating={isLoading || isMutating} | ||
/> | ||
<Th2>{counter} húzás</Th2> | ||
</> | ||
)} | ||
<Button | ||
onClick={() => { | ||
router.push('/admin'); | ||
}} | ||
variant='secondary' | ||
> | ||
Vissza | ||
</Button> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
apps/frontend/src/components/ui/ProfilePictureTinderCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import React, { useState } from 'react'; | ||
import { FiCheck, FiX } from 'react-icons/fi'; | ||
|
||
import { Button } from '@/components/ui/button'; | ||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; | ||
import { useKeyboardShortcut } from '@/lib/useKeyboardShortcut'; | ||
import { UserEntity } from '@/types/user-entity'; | ||
|
||
type ProfilePictureTinderCardProps = { | ||
user: UserEntity; | ||
onAccept: () => Promise<void>; | ||
onReject: () => Promise<void>; | ||
onSkip: () => Promise<void>; | ||
isMutating: boolean; | ||
}; | ||
|
||
export default function ProfilePictureTinderCard({ | ||
user, | ||
onAccept, | ||
onReject, | ||
onSkip, | ||
isMutating, | ||
}: ProfilePictureTinderCardProps) { | ||
const [slideDirection, setSlideDirection] = useState<string | null>(null); | ||
const [isSliding, setIsSliding] = useState(false); | ||
|
||
const handleSlideOut = async (direction: 'left' | 'right') => { | ||
setIsSliding(true); | ||
setSlideDirection(direction); | ||
|
||
if (direction === 'left') { | ||
await onReject().then(() => { | ||
setTimeout(() => { | ||
setIsSliding(false); | ||
setSlideDirection(null); | ||
}, 200); | ||
}); | ||
} else { | ||
await onAccept().then(() => { | ||
setTimeout(() => { | ||
setIsSliding(false); | ||
setSlideDirection(null); | ||
}, 200); | ||
}); | ||
} | ||
}; | ||
|
||
useKeyboardShortcut(['f'], () => handleSlideOut('left')); | ||
useKeyboardShortcut(['j'], () => handleSlideOut('right')); | ||
|
||
return ( | ||
<Card className='w-fit flex flex-col items-center overflow-hidden'> | ||
<CardHeader> | ||
<CardTitle>Elfogadod ezt a képet?</CardTitle> | ||
</CardHeader> | ||
<CardContent className='flex flex-col items-center gap-4'> | ||
<div className='relative'> | ||
<div | ||
className={`overflow-hidden rounded transition-all duration-500 ${ | ||
slideDirection === 'left' ? '-translate-x-96 opacity-0' : '' | ||
} ${slideDirection === 'right' ? 'translate-x-96 opacity-0' : ''} ${ | ||
isSliding ? '' : 'translate-x-0 opacity-100 duration-150 transition-opacity' | ||
}`} | ||
> | ||
<img | ||
src={ | ||
isMutating | ||
? '' | ||
: `${process.env.NEXT_PUBLIC_API_URL}/users/${user.authSchId}/profile-picture?cb=${Date.now()}` | ||
} | ||
className='h-96 rounded hover:animate-zoom-in object-cover w-72' | ||
/> | ||
<div className='absolute bottom-0 left-0 text-white bg-gradient-to-t from-black to-transparent h-fit w-full p-2 rounded-b'> | ||
<p className='font-bold'>{isMutating ? 'Betöltés' : user.fullName}</p> | ||
<p className='text-xs'>{isMutating ? '...' : user.email}</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div className='flex gap-4'> | ||
<Button variant='destructive' onClick={() => handleSlideOut('left')}> | ||
<div className='border p-0.5 text-xs rounded px-1.5'>F</div> | ||
<FiX /> | ||
</Button> | ||
<Button variant='secondary' onClick={onSkip}> | ||
Átugrom | ||
</Button> | ||
<Button onClick={() => handleSlideOut('right')}> | ||
<FiCheck /> | ||
<div className='border p-0.5 text-xs rounded px-1.5'>J</div> | ||
</Button> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
); | ||
} |
Oops, something went wrong.