-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Feat] left pages #1484 #1490
Merged
Merged
[Feat] left pages #1484 #1490
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
caac3df
feat: index ui
cweedlee a6feeab
feat: pageController ui
cweedlee 091f092
feat: api μ°κ²° λ° μμ
cweedlee 2e35a78
fix: ui λ° λ¦¬λ€μ΄λ μ
cweedlee 1ff71bc
fix: λ©μΈ νμ΄μ§ μ λ° ui
cweedlee 4a58021
feat: agena λ°λ‘κ°κΈ° μμ±
cweedlee a190232
fix: agendaList λ΄λΆ width μλͺ» μμ ν¨
cweedlee 899bc5b
feat: ticket page UI
cweedlee da86508
feat: profile intraid λ°μμ€λλ‘ μμ
cweedlee 1fb9f18
feat: μ»΄ν¬λνΈ ui λ° ν°μΌλ°κΈ api μ°κ²°
cweedlee 95f02e8
feat: ν°μΌ νμ€ν 리 μ‘°ν
cweedlee 9632c9e
feat: λ©μΈ 리μ€νΈ ν°μΌνμΈ μΆκ°
cweedlee 06fcba3
style: λ§μ΄μμ λ€ μ°μ λ ¬
cweedlee 3e28f36
feat: ν°μΌλ΄μ λ°λ‘κ°κΈ° μΆκ°
cweedlee 3cb5f61
style: λκΈ°λ λͺ¨μ
cweedlee 913f284
feat: μΊλ¬μ
μλμ ν λ° μ€λ³΅ν΄λ¦ λ°©μ§
cweedlee 95e5461
Merge branch 'agenda' of https://github.com/42organization/42gg.clienβ¦
cweedlee a5e5c8d
fix: conflict
cweedlee ec35ee3
fix: νμ΄μ§λ€μ΄μ
μΌλ‘ λ°λμ΄μ νμ± ν°μ§ λΆλΆ
cweedlee a879d07
feat: usePageNation
cweedlee eb494cc
feat: μ½λ λ¨μν
cweedlee 3f8376c
feat: ν°μΌ λ°κΈμ€μΈμ§ νμΈνλ λ‘μ§ apiμμ λ°μμ€λ κ²μΌλ‘ λ³κ²½
cweedlee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,87 @@ | ||
import Link from 'next/link'; | ||
import { instanceInAgenda } from 'utils/axios'; | ||
import useFetchGet from 'hooks/agenda/useFetchGet'; | ||
import styles from 'styles/agenda/Ticket/Ticket.module.scss'; | ||
interface TicketProps { | ||
ticketCount: number; | ||
} | ||
|
||
const Ticket = ({ type }: { type: string }) => { | ||
const { data } = useFetchGet<TicketProps>('/ticket'); | ||
let status = localStorage.getItem('ticket-issue-status') || false; | ||
return type === 'page' ? ( | ||
<div className={styles.container}> | ||
<h1 className={styles.h1}>λ΄ ν°μΌ</h1> | ||
<div className={styles.ticketSection}> | ||
<div className={styles.ticketFrame}> | ||
<h1>{data && data.ticketCount}</h1> | ||
</div> | ||
<h1>κ°</h1> | ||
</div> | ||
<div className={styles.section}> | ||
<h3>λ°κΈ λ°©λ²</h3> | ||
<div className={styles.line} /> | ||
<p>λ°κΈ μμ λλ₯΄κΈ°</p> | ||
<div className={styles.arrowDown} /> | ||
<p> | ||
νκ° ν¬μΈνΈ κΈ°λΆνκΈ° | ||
<br /> | ||
{`(μ΅λ 2κ°κΉμ§ λ°μ)`} | ||
</p> | ||
<div className={styles.arrowDown} /> | ||
<p>νμ¬ νμ΄μ§λ‘ λμμ λ°κΈμλ£ λλ₯΄κΈ°</p> | ||
</div> | ||
{status ? ( | ||
<button | ||
className={styles.submitButton} | ||
onClick={() => { | ||
instanceInAgenda.patch('/ticket').then((res) => { | ||
console.log(res); | ||
localStorage.removeItem('ticket-issue-status'); | ||
status = false; | ||
}); | ||
}} | ||
> | ||
λ°κΈ μλ£ | ||
</button> | ||
) : ( | ||
<button | ||
className={styles.submitButton} | ||
onClick={() => { | ||
instanceInAgenda.post('/ticket').then(() => { | ||
alert('ν°μΌ λ°κΈ μμ'); | ||
status = true; | ||
localStorage.setItem('ticket-issue-status', 'true'); | ||
location.href = 'https://profile.intra.42.fr/'; | ||
}); | ||
}} | ||
> | ||
λ°κΈ μμ | ||
</button> | ||
)} | ||
<Link href='/agenda/ticket/history' style={{ width: '100%' }}> | ||
<button className={styles.logButton}>λ΄μ 보기</button> | ||
</Link> | ||
</div> | ||
) : ( | ||
<div className={styles.container}> | ||
<h1 className={styles.h1}>λ΄ ν°μΌ</h1> | ||
<div | ||
className={styles.ticketSection} | ||
style={{ gap: '2rem', alignItems: 'center' }} | ||
> | ||
<Link href='/agenda/ticket'> | ||
<button className={styles.submitButton}>λ°κΈνλ¬κ°κΈ°</button> | ||
</Link> | ||
<div className={styles.ticketSection}> | ||
<div className={styles.ticketFrame}> | ||
<h1>{data && data.ticketCount}</h1> | ||
</div> | ||
<h1>κ°</h1> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Ticket; |
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,55 @@ | ||
import { | ||
TableCell, | ||
TableRow, | ||
Table, | ||
TableHead, | ||
TableBody, | ||
} from '@mui/material'; | ||
import { TicketHistoryProps } from 'types/aganda/ticketTypes'; | ||
import styles from 'styles/agenda/Ticket/Ticket.module.scss'; | ||
|
||
const TicketHistory = ({ data }: { data: TicketHistoryProps[] | null }) => { | ||
return ( | ||
<div className={styles.container}> | ||
<h1 className={styles.h1}>ν°μΌ λ°κΈ λ΄μ</h1> | ||
<Table sx={{ minWidth: 340 }} aria-label='simple table'> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell>idx</TableCell> | ||
<TableCell align='center'>λ°κΈμμ²μΌ</TableCell> | ||
<TableCell align='center'>μΉμΈμ¬λΆ</TableCell> | ||
<TableCell align='center'>μΉμΈμΌ</TableCell> | ||
<TableCell align='center'>μ¬μ©μ¬λΆ</TableCell> | ||
<TableCell align='center'>μ¬μ©μ²</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{data && | ||
data.map((d, index) => { | ||
return ( | ||
<TableRow | ||
key={index} | ||
sx={{ '&:last-child td, &:last-child th': { border: 0 } }} | ||
> | ||
<TableCell component='th' scope='row'> | ||
{d.idx} | ||
</TableCell> | ||
<TableCell align='center'>{d.createdAt}</TableCell> | ||
<TableCell align='center'> | ||
{d.approved ? 'βοΈ' : 'β'} | ||
</TableCell> | ||
<TableCell align='center'>{d.approvedAt}</TableCell> | ||
<TableCell align='center'>{d.isUsed ? 'βοΈ' : 'β'}</TableCell> | ||
<TableCell align='center'> | ||
{d.usedAt ? d.usedAt : ''} | ||
</TableCell> | ||
</TableRow> | ||
); | ||
})} | ||
</TableBody> | ||
</Table> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TicketHistory; |
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,114 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { AgendaDataProps } from 'types/agenda/agendaDetail/agendaTypes'; | ||
import { instanceInAgenda } from 'utils/axios'; | ||
import styles from 'styles/agenda/utils/PageController.module.scss'; | ||
import AgendaInfo from '../Home/AgendaInfo'; | ||
|
||
interface PageControllerNavigatorProps { | ||
currentPage: number; | ||
maxPage: number; | ||
onClick: (page: number) => void; | ||
} | ||
|
||
const PageControllerNavigator = ({ | ||
currentPage, | ||
maxPage, | ||
onClick, | ||
}: PageControllerNavigatorProps) => { | ||
const buttons = []; | ||
for (let i = 0; i < maxPage; i++) { | ||
if (i === currentPage) | ||
buttons.push( | ||
<button key={i} onClick={() => onClick(i)} className={styles.current} /> | ||
); | ||
else | ||
buttons.push( | ||
<button key={i} onClick={() => onClick(i)} className={styles.rest} /> | ||
); | ||
} | ||
return ( | ||
<div className={styles.navContainer}>{buttons.map((button) => button)}</div> | ||
); | ||
}; | ||
|
||
const PageController = ({ | ||
handleNavigation, | ||
}: { | ||
handleNavigation: (path: string) => void; | ||
}) => { | ||
const [current, setCurrent] = useState(0); | ||
const [data, setData] = useState<AgendaDataProps[]>([]); | ||
const max = data.length; | ||
|
||
const fetchAgendaList = async () => { | ||
const url = '/list'; | ||
const data = await instanceInAgenda | ||
.get(url) | ||
.then((res) => { | ||
return res.data; | ||
}) | ||
.catch((error) => { | ||
if (error.view === 403) return []; | ||
else return []; // μλ¬μ²λ¦¬ νμ ERROR | ||
}); | ||
return data; | ||
}; | ||
|
||
useEffect(() => { | ||
fetchAgendaList().then((data) => { | ||
setData(data); | ||
}); | ||
}, []); | ||
useEffect(() => { | ||
const interval = setInterval(moveNext, 2000); | ||
return () => clearInterval(interval); | ||
}); | ||
|
||
function moveNext() { | ||
setCurrent(current + 1 < max ? current + 1 : 0); | ||
} | ||
function movePrev() { | ||
setCurrent(current - 1 >= 0 ? current - 1 : max - 1); | ||
} | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<button | ||
className={styles.agendaInfoContainer} | ||
onClick={(e) => { | ||
const target = e.target as HTMLElement; | ||
console.log(target); | ||
if ( | ||
target.className.includes(styles.moveButton) || | ||
target.closest(styles.moveButton) | ||
) | ||
return; | ||
data.length && data[current] | ||
? handleNavigation('/agenda/' + data[current].agendaKey) | ||
: null; | ||
}} | ||
> | ||
<button | ||
onClick={movePrev} | ||
className={`${styles.moveButton} ${styles.moveButtonPrev}`} | ||
> | ||
<div className={styles.prev} /> | ||
</button> | ||
<button | ||
className={`${styles.moveButton} ${styles.moveButtonNext}`} | ||
onClick={moveNext} | ||
> | ||
<div className={styles.next} /> | ||
</button> | ||
<AgendaInfo agendaInfo={data[current]} key={current || 0} /> | ||
</button> | ||
<PageControllerNavigator | ||
currentPage={current} | ||
maxPage={data.length} | ||
onClick={setCurrent} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PageController; |
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,58 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
import { instanceInAgenda } from 'utils/axios'; | ||
|
||
const usePageNation = <T>({ | ||
url, | ||
size, | ||
useIdx, | ||
}: { | ||
url: string; | ||
size?: number; // νμ΄μ§ μ¬μ΄μ¦ | ||
useIdx?: boolean; // μΈλ±μ± μΆκ° μ¬λΆ : ν΄λΉ λ°μ΄ν° νμ μ idx?: number; μΆκ° νμ | ||
}) => { | ||
if (!size) size = 20; | ||
const getData = async (page: number) => { | ||
const res = await instanceInAgenda.get(`${url}?page=${page}&size=${size}`); | ||
res.data.totalSize ? res.data.totalSize : 0; | ||
res.data.content ? res.data.content : []; | ||
if (useIdx) { | ||
res.data.content = res.data.content.map((c: T, idx: number) => { | ||
const temp = c as T & { idx: number }; | ||
temp.idx = idx + 1 + size * (page - 1); | ||
return temp; | ||
}); | ||
} | ||
return res.data as { totalSize: number; content: T[] }; | ||
}; | ||
// const data = getData(0); | ||
const [currentPage, setCurrentPage] = useState<number>(1); | ||
const [content, setContent] = useState<T[] | null>(null); | ||
const totalPages = useRef(1); | ||
|
||
const pageChangeHandler = async (pageNumber: number) => { | ||
if (pageNumber < 1 || pageNumber > totalPages.current) return; | ||
await getData(pageNumber).then((res) => { | ||
setCurrentPage(pageNumber); | ||
setContent(res.content); | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
const data = await getData(currentPage); | ||
totalPages.current = Math.ceil(data.totalSize / size); | ||
setContent(data.content); | ||
}; | ||
fetchData(); | ||
}); | ||
|
||
const PagaNationElementProps = { | ||
curPage: currentPage, | ||
totalPages: totalPages.current, | ||
pageChangeHandler: pageChangeHandler, | ||
}; | ||
|
||
return { content, PagaNationElementProps }; | ||
}; | ||
|
||
export default usePageNation; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
λ°κΈ μλ£λ§ λλ¬λ ν°μΌ κ°μκ° λμ΄λλ λΆλΆ λ°±μλμͺ½μ νμΈνμ!