-
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.
Merge pull request #127 from softeerbootcamp4th/feature/122-admin-user
[feat] 어드민 유저 조회 페이지 구현
- Loading branch information
Showing
10 changed files
with
176 additions
and
17 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
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,9 @@ | ||
import Spinner from "@common/components/Spinner"; | ||
|
||
export default function Loading() { | ||
return ( | ||
<div className="flex justify-center items-center w-full h-[600px] bg-slate-50"> | ||
<Spinner /> | ||
</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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useQuery } from "@common/dataFetch/getQuery.js"; | ||
import { fetchServer } from "@common/dataFetch/fetchServer.js"; | ||
import Pagination from "@admin/components/Pagination"; | ||
import { useState } from "react"; | ||
|
||
export default function Comments({ searchString, category }) { | ||
searchString; | ||
const [page, setPage] = useState(1); | ||
const data = useQuery( | ||
"admin-users", | ||
() => | ||
fetchServer(`/api/v1/admin/event-users?page=${page - 1}&search=${searchString}&size=15`) | ||
.then((res) => { | ||
console.log(category); | ||
return res; | ||
}) | ||
.catch((e) => { | ||
console.log(e); | ||
}), | ||
[page, searchString], | ||
); | ||
|
||
return ( | ||
<div className="mt-1 mb-5 flex flex-col items-center gap-1 w-full"> | ||
{data.users.map((user) => ( | ||
<div | ||
key={user.id} | ||
className="w-full py-1 grid grid-cols-[1fr_1fr_2fr] bg-neutral-50 items-center hover:bg-blue-100 text-body-s place-items-center" | ||
> | ||
<span>{user.userName}</span> | ||
<span>{user.phoneNumber}</span> | ||
<span>{user.frameId}</span> | ||
</div> | ||
))} | ||
|
||
<Pagination currentPage={page} setPage={setPage} maxPage={data.totalPage} /> | ||
</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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import Suspense from "@common/components/Suspense"; | ||
import Loading from "./Loading.jsx"; | ||
import Users from "./Users.jsx"; | ||
import { useState } from "react"; | ||
|
||
export default function AdminCommentID() { | ||
const [formString, setFormString] = useState(""); | ||
const [searchString, setSearchString] = useState(""); | ||
const [category, setCategory] = useState("name"); | ||
|
||
function searchComment(e) { | ||
e.preventDefault(); | ||
setSearchString(formString); | ||
} | ||
|
||
return ( | ||
<div className="relative flex flex-col w-full items-center"> | ||
<div | ||
className={`absolute -top-6 flex gap-1 text-body-s self-start ${!searchString && "hidden"}`} | ||
> | ||
<span className={`pl-1 text-red-500`}>검색 문자열:</span> | ||
<span className={`text-red-500 italic`}>{searchString}</span> | ||
</div> | ||
|
||
<form onSubmit={searchComment} className="w-full relative"> | ||
<input | ||
type="text" | ||
value={formString} | ||
onChange={(e) => setFormString(e.target.value)} | ||
placeholder="유저 성명 검색" | ||
className="bg-neutral-50 focus:bg-white w-full px-4 py-2 rounded-lg text-body-s" | ||
/> | ||
|
||
<div className="absolute top-1/2 -translate-y-1/2 right-4 flex gap-3"> | ||
<select | ||
value={category} | ||
onChange={(e) => setCategory(e.target.value)} | ||
className="bg-transparent text-neutral-600" | ||
> | ||
<option value="name">성명</option> | ||
<option value="phoneNumber">전화번호</option> | ||
<option value="frameId">FrameId</option> | ||
</select> | ||
|
||
<img | ||
onClick={searchComment} | ||
src="/icons/search.png" | ||
alt="검색" | ||
className="cursor-pointer " | ||
/> | ||
</div> | ||
</form> | ||
|
||
<div className="mt-3 py-1 w-full grid grid-cols-[1fr_1fr_2fr] bg-blue-50 place-items-center text-body-s select-none"> | ||
<span>성명</span> | ||
<span>전화번호</span> | ||
<span>이벤트 frameId</span> | ||
</div> | ||
|
||
<Suspense fallback={<Loading />}> | ||
<Users searchString={searchString} category={category} /> | ||
</Suspense> | ||
</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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { http, HttpResponse } from "msw"; | ||
import getRandomString from "@common/mock/getRandomString"; | ||
|
||
function getRandomUsers() { | ||
let users = []; | ||
const num = 15; | ||
for (let i = 0; i < num; i++) { | ||
users = [ | ||
...users, | ||
{ | ||
id: i, | ||
userName: getRandomString(3), | ||
phoneNumber: "010-0000-0000", | ||
frameId: "event-test", | ||
}, | ||
]; | ||
} | ||
return { users: users, totalPage: 15 }; | ||
} | ||
|
||
const handlers = [http.get("/api/v1/admin/event-users", () => HttpResponse.json(getRandomUsers()))]; | ||
|
||
export default handlers; |
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,16 @@ | ||
import Container from "@admin/components/Container.jsx"; | ||
import Users from "../features/users"; | ||
|
||
function UsersPage() { | ||
return ( | ||
<Container> | ||
<div className="flex flex-col w-full p-20"> | ||
<span className="text-title-l pb-10">유저 조회</span> | ||
|
||
<Users /> | ||
</div> | ||
</Container> | ||
); | ||
} | ||
|
||
export default UsersPage; |
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