Repository navigation
[Refactor/#110] 멤버 관리 페이지 구조 및 UI 리팩토링 #116
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
260d08d
fix: 아이콘 경로 수정 및 네이밍 정리
jjjsun e96556c
fix: 아이콘 스타일 설정
jjjsun b20cf2f
fix: 멤버 초대 버튼 에러 수정
jjjsun 9d4d09a
fix: 직전 PR 코드래빗 수정사항 반영
jjjsun 867d442
chore: mail 아이콘 컬러 currentColor로 변경
jjjsun 5503ce9
feat: 멤버 삭제 확인 모달 임시 삭제 기능 구현
jjjsun ca023b5
fix: 관리자 변경 리스트에서 관리자만 보이도록 수정
jjjsun 7010679
refactor: 멤버 관리 상태를 상위 컴포넌트로 이동
jjjsun cf8e899
refactor: TTransferCandidate 타입 제거하고 멤버 타입을 TWorkspaceMember로 통일
jjjsun 1232ac4
feat: 권한 설정 변경사항 저장 버튼, 임시 상태 관리 draft 추가
jjjsun 42a9a67
feat: 관리자 변경 모달 내 멤버 선택 드랍다운 컴포넌트 재사용화 가능하도록 변경
jjjsun cd7bc86
style: 관리자 변경 리스트 padding 추가
jjjsun 43d1f02
refactor: 관리자/멤버 역할 디자인 변경
jjjsun e0bd5bd
fix: 코드래빗 수정사항 반영
jjjsun 874587a
refactor: 권한 타입 단순하게 변경
jjjsun c6365c9
fix: 역할설정 Dropdownmenu 컴포넌트 사용으로 변경
jjjsun 8b412d9
fix: 코드래빗 수정사항 반영
jjjsun 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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,159 @@ | ||
| import React, { useEffect, useId, useMemo, useRef, useState } from "react"; | ||
|
|
||
| import Input from "../input/Input"; | ||
|
|
||
| import SearchIcon from "@/assets/icon/common/search.svg?react"; | ||
|
|
||
| type TSearchSelectProps<T> = { | ||
| options: T[]; | ||
| selectedOption: T | null; | ||
| onSelect: (option: T) => void; | ||
| isOpen: boolean; | ||
| onOpenChange: (open: boolean) => void; | ||
| placeholder?: string; | ||
| getOptionKey: (option: T) => string | number; | ||
| getOptionLabel: (option: T) => string; | ||
| getSearchText: (option: T) => string; | ||
| renderOption: (option: T) => React.ReactNode; | ||
| emptyMessage?: string; | ||
| className?: string; | ||
| }; | ||
|
|
||
| export default function SearchSelect<T>({ | ||
| options, | ||
| selectedOption, | ||
| onSelect, | ||
| isOpen, | ||
| onOpenChange, | ||
| placeholder = "검색하세요", | ||
| getOptionKey, | ||
| getOptionLabel, | ||
| getSearchText, | ||
| renderOption, | ||
| emptyMessage = "검색 결과가 없습니다.", | ||
| className = "", | ||
| }: TSearchSelectProps<T>) { | ||
| const containerRef = useRef<HTMLDivElement>(null); | ||
| const inputId = useId(); | ||
| const listboxId = useId(); | ||
|
|
||
| const getOptionLabelRef = useRef(getOptionLabel); | ||
|
|
||
| const [keyword, setKeyword] = useState( | ||
| selectedOption ? getOptionLabel(selectedOption) : "", | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| getOptionLabelRef.current = getOptionLabel; | ||
| }, [getOptionLabel]); | ||
|
|
||
| useEffect(() => { | ||
| setKeyword(selectedOption ? getOptionLabelRef.current(selectedOption) : ""); | ||
| }, [selectedOption]); | ||
|
|
||
| useEffect(() => { | ||
| const handleOutsideClick = (e: MouseEvent) => { | ||
| if (!containerRef.current?.contains(e.target as Node)) { | ||
| onOpenChange(false); | ||
| } | ||
| }; | ||
|
|
||
| document.addEventListener("mousedown", handleOutsideClick); | ||
|
|
||
| return () => { | ||
| document.removeEventListener("mousedown", handleOutsideClick); | ||
| }; | ||
| }, [onOpenChange]); | ||
|
|
||
| const filteredOptions = useMemo(() => { | ||
| const trimmedKeyword = keyword.trim().toLowerCase(); | ||
|
|
||
| if (!trimmedKeyword) { | ||
| return options; | ||
| } | ||
|
|
||
| return options.filter((option) => | ||
| getSearchText(option).toLowerCase().includes(trimmedKeyword), | ||
| ); | ||
| }, [getSearchText, keyword, options]); | ||
|
|
||
| const handleFocus = () => { | ||
| onOpenChange(true); | ||
| }; | ||
|
|
||
| const handleChangeKeyword = (value: string) => { | ||
| setKeyword(value); | ||
| onOpenChange(true); | ||
| }; | ||
|
|
||
| const handleSelect = (option: T) => { | ||
| onSelect(option); | ||
| setKeyword(getOptionLabelRef.current(option)); | ||
| onOpenChange(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <div ref={containerRef} className={`relative w-full ${className}`}> | ||
| <div className="relative"> | ||
| <Input | ||
| id={inputId} | ||
| value={keyword} | ||
| onFocus={handleFocus} | ||
| onChange={(e) => handleChangeKeyword(e.target.value)} | ||
| placeholder={placeholder} | ||
| aria-label={placeholder} | ||
| role="combobox" | ||
| aria-expanded={isOpen} | ||
| aria-controls={listboxId} | ||
| aria-haspopup="listbox" | ||
| aria-autocomplete="list" | ||
| className="h-13 w-full rounded-component-md border border-status-blue px-4 pl-5 font-body1 outline-none transition-colors placeholder:text-text-placeholder focus:border-status-blue" | ||
| /> | ||
| <SearchIcon className="pointer-events-none absolute right-4 top-1/2 h-5 w-5 -translate-y-1/2 text-status-blue" /> | ||
| </div> | ||
|
|
||
| {isOpen && ( | ||
| <div className="absolute left-0 top-[calc(100%+8px)] z-20 w-full overflow-hidden rounded-component-md border border-gray-200 bg-white shadow-sm"> | ||
| {filteredOptions.length > 0 ? ( | ||
| <ul | ||
| id={listboxId} | ||
| role="listbox" | ||
| aria-labelledby={inputId} | ||
| className="max-h-60 overflow-y-auto py-2" | ||
| > | ||
| {filteredOptions.map((option) => { | ||
| const optionKey = getOptionKey(option); | ||
| const isSelected = | ||
| selectedOption !== null && | ||
| getOptionKey(selectedOption) === optionKey; | ||
|
|
||
| return ( | ||
| <li key={optionKey} role="presentation"> | ||
| <button | ||
| id={`${listboxId}-option-${optionKey}`} | ||
| type="button" | ||
| role="option" | ||
| aria-selected={isSelected} | ||
| onClick={() => handleSelect(option)} | ||
| className="w-full py-2 text-left hover:bg-gray-50" | ||
| > | ||
| {renderOption(option)} | ||
| </button> | ||
| </li> | ||
| ); | ||
| })} | ||
| </ul> | ||
| ) : ( | ||
| <div | ||
| role="status" | ||
| aria-live="polite" | ||
| className="px-4 py-5 font-body2 text-text-sub" | ||
| > | ||
| {emptyMessage} | ||
| </div> | ||
| )} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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,64 @@ | ||
| import type { TWorkspaceMember } from "@/types/workspace/workspace"; | ||
|
|
||
| import Button from "../common/button/Button"; | ||
| import Modal from "../common/modal/Modal"; | ||
|
|
||
| import WarnIcon from "@/assets/icon/common/warn-circle.svg?react"; | ||
|
|
||
| type TDeleteMemberModalProps = { | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| member: TWorkspaceMember | null; | ||
| onConfirm: (member: TWorkspaceMember) => void; | ||
| isLoading?: boolean; | ||
| }; | ||
|
|
||
| export default function DeleteMemberModal({ | ||
| isOpen, | ||
| onClose, | ||
| member, | ||
| onConfirm, | ||
| isLoading = false, | ||
| }: TDeleteMemberModalProps) { | ||
| const handleConfirm = () => { | ||
| if (!member || isLoading) return; | ||
| onConfirm(member); | ||
| }; | ||
| return ( | ||
| <Modal | ||
| isOpen={isOpen} | ||
| onClose={onClose} | ||
| size="lg" | ||
| padding="lg" | ||
| title="팀원 삭제 확인" | ||
| > | ||
| <div className="text-center px-2 py-6"> | ||
| <div className="flex justify-center mb-6"> | ||
| <WarnIcon className="text-status-red w-15 h-15" aria-hidden="true" /> | ||
| </div> | ||
| <h3 className="font-heading2 text-text-main mb-3"> | ||
| 팀원을 삭제하시겠습니까? | ||
| </h3> | ||
| <p className="font-body1 text-text-auth-sub mb-7"> | ||
| {member | ||
| ? `${member.name}님을 팀에서 삭제합니다` | ||
| : "선택한 팀원을 삭제합니다"} | ||
| <br />이 작업은 되돌릴 수 없습니다. | ||
| </p> | ||
| <div className="flex justify-center"> | ||
| <Button | ||
| variant="danger" | ||
| size="big" | ||
| aria-label="멤버 삭제 버튼" | ||
| onClick={handleConfirm} | ||
| className="w-auto tablet:w-full" | ||
| type="button" | ||
| disabled={!member || isLoading} | ||
| > | ||
| {isLoading ? "삭제 중.." : "삭제하기"} | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| </Modal> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.