-
Notifications
You must be signed in to change notification settings - Fork 0
"관리자 회원 상세 조회 페이지" API 연결 ( feat/#348 ) #350
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
Changes from all commits
31add2f
14498eb
74f82c6
10c2177
7bf082f
821d359
c785fa4
f2aca09
dade372
8290df9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import type { ApiUserApplicantsData } from '../../models/admin/userDetail/userDetail.applicants'; | ||
| import type { ApiUserProjectDataResponse } from '../../models/admin/userDetail/userProjectData'; | ||
| import { httpClient } from '../http.api'; | ||
|
|
||
| export const postBanUser = async (id: string) => { | ||
| try { | ||
| await httpClient.post(`/ban/${id}`); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const postWarningUser = async (id: string) => { | ||
| try { | ||
| await httpClient.post(`/warning/${id}`); | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const getUserApplicants = async ( | ||
| projectId: number, | ||
| applicantId: number | ||
| ) => { | ||
| try { | ||
| const response = await httpClient.get<ApiUserApplicantsData>( | ||
| `/admin/project/${projectId}/full?applicantId=${applicantId}` | ||
| ); | ||
| return response.data; | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; | ||
|
|
||
| export const getUserProjectData = async (userId: number) => { | ||
| try { | ||
| const response = await httpClient.get<ApiUserProjectDataResponse>( | ||
| `/users/${userId}/projects` | ||
| ); | ||
| return response.data.data.appliedProjects; | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import { httpClient } from '../http.api'; | ||
| import type { ApiUserActivityResponse } from '../../models/admin/userDetail/userActivity'; | ||
|
|
||
| export const getUserActivityData = async (userId: number) => { | ||
| try { | ||
| const response = await httpClient.get<ApiUserActivityResponse>( | ||
| `/users/${userId}/activities` | ||
| ); | ||
| return response.data; | ||
| } catch (e) { | ||
| console.error(e); | ||
| throw e; | ||
| } | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,18 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { useGetMyInquiries } from '../../../../../hooks/user/useGetMyInquiries'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { useParams } from 'react-router-dom'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import useGetUserActivity from '../../../../../hooks/admin/useGetAllUserActivity'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import ContentBorder from '../../../../common/contentBorder/ContentBorder'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import NoContent from '../../../../common/noContent/NoContent'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import Spinner from '../../Spinner'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import * as S from './Inquiries.styled'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import Inquiry from './inquiry/Inquiry'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import type { MyInquiries } from '../../../../../models/activityLog'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| export default function Inquiries() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const { myInquiriesData, isLoading } = useGetMyInquiries(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| const { userId } = useParams(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| const { userActivityData, isLoading } = useGetUserActivity( | ||||||||||||||||||||||||||||||||||||||||||||||||
| Number(userId), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 'inquiries' | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. URL 파라미터 검증 누락
export default function Inquiries() {
const { userId } = useParams();
+
+ if (!userId || isNaN(Number(userId))) {
+ return (
+ <S.WrapperNoContentAppliedProjects data-type='noContent'>
+ <NoContent type='error' />
+ </S.WrapperNoContentAppliedProjects>
+ );
+ }
+
const { userActivityData, isLoading } = useGetUserActivity(
Number(userId),
'inquiries'
);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (isLoading) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -16,13 +22,15 @@ export default function Inquiries() { | |||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| if (!myInquiriesData || myInquiriesData?.length === 0) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (!userActivityData || userActivityData?.length === 0) | ||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| <S.WrapperNoContentAppliedProjects data-type='noContent'> | ||||||||||||||||||||||||||||||||||||||||||||||||
| <NoContent type='inquiries' /> | ||||||||||||||||||||||||||||||||||||||||||||||||
| </S.WrapperNoContentAppliedProjects> | ||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| const myInquiriesData = userActivityData as MyInquiries[]; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| <S.container> | ||||||||||||||||||||||||||||||||||||||||||||||||
| <S.InquiriesContainer> | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
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.
이거 데이터 없어도 [] 빈배열로 들어오지않나요? 그러면 이거는 항상 true 조건 아닌가요? 그래서 length로 했던것같은데