-
Notifications
You must be signed in to change notification settings - Fork 0
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: 동적으로 테이블이 변경되는 기능을 구현한다 #25
base: develop
Are you sure you want to change the base?
Conversation
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.
타입 오류 개선해주세요~
- 뭔가 복잡하게 돌아간 느낌이네요🤔
단순한 로직으로 개선할 수 있을 것 같아 보여요
))} | ||
<Button sx={{ color: '#fff', wordBreak: 'keep-all' }} onClick={() => handleClickMenu()}> | ||
{isLoggedIn ? '로그아웃' : '간편로그인'} | ||
</Button>{' '} |
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.
{' '}
지워주세요
const AdminTableBody = <T, K extends keyof T>({ data, columns }: TableRowsProps<T, K>) => { | ||
const { openModal } = modalActions; | ||
|
||
const handleOpenModal = () => { | ||
function handleOpenModal() { |
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.
컴포넌트는 function
, 이벤트 핸들러 등의 함수는 화살표 함수 써주세요
const [tableData, setTableData] = useState(stationMockData); | ||
const token = memberTokenStore.getState(); | ||
const { lastPage, stationSummaryList } = useFetchStations(token, 1); | ||
if (token === '') return <LoginModalContent />; |
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.
개행 주세여
function App() { | ||
const [tableTitle, setTableTitle] = useState('충전소 관리'); | ||
const [tableColumn, setTableColumn] = useState(stationColumns); | ||
const [tableData, setTableData] = useState(stationMockData); |
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.
여기 밑에도 개행 줘도 될 것 같아여
const memberColumns: ColumnType<MemberDetails, keyof MemberDetails>[] = [ | ||
{ | ||
key: 'id', | ||
header: 'ID', | ||
}, | ||
{ | ||
key: 'email', | ||
header: 'E-MAIL', | ||
}, | ||
{ | ||
key: 'role', | ||
header: '회원 권한', | ||
}, | ||
]; | ||
const faultReportColumns: ColumnType<FaultReportDetails, keyof FaultReportDetails>[] = [ | ||
{ | ||
key: 'id', | ||
header: 'ID', | ||
}, | ||
{ | ||
key: 'stationId', | ||
header: '충전소 ID', | ||
}, | ||
{ | ||
key: 'memberId', | ||
header: '회원 ID', | ||
}, | ||
]; |
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.
이렇게 만든 이유가 있을까요??
const memberColumns: ColumnType<MemberDetails, keyof MemberDetails>[] = [ | |
{ | |
key: 'id', | |
header: 'ID', | |
}, | |
{ | |
key: 'email', | |
header: 'E-MAIL', | |
}, | |
{ | |
key: 'role', | |
header: '회원 권한', | |
}, | |
]; | |
const faultReportColumns: ColumnType<FaultReportDetails, keyof FaultReportDetails>[] = [ | |
{ | |
key: 'id', | |
header: 'ID', | |
}, | |
{ | |
key: 'stationId', | |
header: '충전소 ID', | |
}, | |
{ | |
key: 'memberId', | |
header: '회원 ID', | |
}, | |
]; | |
const faultReportColumns = { | |
id: 'ID', | |
stationId: '충전소 ID' | |
.... | |
} | |
const faultRepoutColumnList = getTypedObjectEntries(faultReportColumns) |
이렇게 만들어서 쓰면 안되나요??
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.
저는 혹시 key, header 외의 다른 속성들을 넣을 수 있지 않을까라는 생각에 했습니다. 하지만 굳이 지금 단계에선 과하고 코드의 복잡도만 높아지겠네요 수정하겠습니다
'충전기 신고 관리', | ||
'간편 로그인', | ||
] as const; |
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.
간편 로그인 왜 사라졌죠? 🤔 처음에 로그인 해야만 보이는 걸로 바꿔서 없앴나요?
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.
아니요 간편 로그인은 클릭했을 때 간편로그인 창이 떠야하지만, 나머지 메뉴 버튼들은 table이 나와야해서 성격이 달라 map으로 적용하기가 어려운 부분이 있어서 성격이 비슷한 친구들만 묶었습니다..
} | ||
|
||
export const useFetchStations = (token: string, page: number) => { | ||
const [lastPage, setLastPage] = useState(1); | ||
const [stationSummaryList, setStationSummaryList] = useState<StationProps[]>([]); | ||
const [stationSummaryList, setStationSummaryList] = useState<StationDetails[]>([]); |
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.
타입 이름 stationSummary
가 아닐까요?
export const misinformnationMockData = Array.from( | ||
{ length: ROWS_PER_PAGE }, | ||
() => misinformationMock | ||
); | ||
|
||
export function getMockData<T>(title: string): Array<T> { | ||
switch (title) { | ||
case '충전소 관리': | ||
return stationMockData as Array<T>; | ||
case '충전소 제보 관리': | ||
return misinformnationMockData as Array<T>; |
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.
misinformation
으로 바꿔주세요~ 오타났습니다
role: string; | ||
} | ||
|
||
const memberColumns: ColumnType<MemberDetails, keyof MemberDetails>[] = [ |
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.
이게 왜 type에 있죠...? constant 아닌가요? 이하 동문입니다~
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.
네..
key: 'role', | ||
header: '회원 권한', | ||
}, | ||
]; |
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.
개행주세여
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.
네..
📄 Summary
🕰️ Actual Time of Completion
🙋🏻 More
close #14