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.
single period, dynamic reporting periods
- Loading branch information
Showing
7 changed files
with
176 additions
and
35 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,9 @@ | ||
import SinglePeriod from '../../../components/SinglePeriod'; | ||
|
||
export default function Home() { | ||
return ( | ||
<main className='flex items-center justify-center bg-page-bg-color'> | ||
<SinglePeriod /> | ||
</main> | ||
); | ||
} |
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
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,101 @@ | ||
'use client'; | ||
|
||
import { useSearchParams } from 'next/navigation'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
import api from '../lib/axiosConfig'; | ||
|
||
export default function SinglePeriod() { | ||
const search = useSearchParams(); | ||
const start = search.get('start'); | ||
const end = search.get('end'); | ||
const numberOfTheWeek = search.get('numberOfTheWeek'); | ||
//------------------------------------ | ||
interface Task { | ||
projectId: string; | ||
} | ||
const [tasks, setTasks] = useState<Task[]>([]); | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [selected, setSelected] = useState<string | null>(null); | ||
const [showTextarea, setShowTextarea] = useState(false); | ||
const [textareaValue, setTextareaValue] = useState<string>(''); | ||
|
||
useEffect(() => { | ||
api.get('/tasks').then((res) => { | ||
setTasks(res.data); | ||
}); | ||
}, []); | ||
|
||
const handleDropdown = () => { | ||
setIsOpen((prev) => !prev); | ||
}; | ||
const handleTaskClick = (tasks: Task) => { | ||
setSelected(tasks.projectId); | ||
setIsOpen(false); | ||
setShowTextarea(true); | ||
setTextareaValue(''); | ||
}; | ||
const handleTextareaChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => { | ||
setTextareaValue(e.target.value); | ||
}; | ||
|
||
return ( | ||
<div className='w-3/5 flex px-8 py-8 mx-auto lg:py-0'> | ||
<div className='p-6 space-y-4 md:space-y-6 sm:p-8 w-full'> | ||
<h1 className='text-xl font-bold leading-tight tracking-tight text-text-color-h1 md:text-4xl dark:text-bg-color2 w-full text-center'> | ||
{numberOfTheWeek}. hét ({start} - {end}) | ||
</h1> | ||
<div> | ||
{!selected && ( | ||
<button | ||
className='text-text-color border mb-5 rounded-lg p-2 font-semibold text-sm border-[#8b97a4] hover:border-text-color hover:bg-[#2c3540] focus:ring-4 transition duration-300' | ||
onClick={handleDropdown} | ||
> | ||
+ feladat hozzáadása | ||
</button> | ||
)} | ||
|
||
{isOpen && ( | ||
<div className=''> | ||
{tasks.map((task) => ( | ||
<div | ||
key={task.projectId} | ||
onClick={() => handleTaskClick(task)} | ||
className='w-6 text-text-color border mb-2 rounded-lg p-2 font-semibold text-sm border-[#8b97a4] hover:border-text-color hover:bg-[#2c3540] focus:ring-4' | ||
> | ||
{task.projectId} | ||
</div> | ||
))} | ||
</div> | ||
)} | ||
{showTextarea && ( | ||
<div className='mb-10'> | ||
<p className='text-text-color text-l mb-2'>{selected ? `${selected} :` : 'Nincs kiválasztott projekt'}</p> | ||
<label htmlFor='textarea' /> | ||
<textarea | ||
id='textarea' | ||
value={textareaValue} | ||
onChange={handleTextareaChange} | ||
className='w-full h-60 bg-bg-color2 border border-[#8b97a4] text-white sm:text-sm rounded-lg block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-bg-color2 dark:focus:ring-blue-500 dark:focus:border-blue-500' | ||
placeholder='Írd le mit dolgoztál a héten' | ||
/> | ||
<button | ||
type='submit' | ||
className='mt-5 border font-semibold text-text-color rounded-lg text-sm px-5 py-2.5 text-center border-[#8b97a4] hover:border-text-color hover:bg-[#2c3540] focus:ring-4 transition duration-300' | ||
> | ||
Mentés | ||
</button> | ||
<button | ||
type='submit' | ||
className='float-right mt-5 border font-semibold text-text-color rounded-lg text-sm px-5 py-2.5 text-center border-[#8b97a4] hover:border-text-color hover:bg-red-500 hover:text-white focus:ring-4 transition duration-300' | ||
> | ||
Törlés | ||
</button> | ||
<hr className='mt-5 border border-y-0.5' /> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export function Footer() { | ||
return ( | ||
<footer className='bg-page-bg-color flex items-center justify-center'> | ||
<p className='text-gray-500 text-sm mb-8'>@Kir-Dev pod-oscar</p> | ||
<p className='text-gray-500 text-sm my-8'>@Kir-Dev pod-oscar</p> | ||
</footer> | ||
); | ||
} |