Skip to content
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

[FE] 코멘트 리팩토링 #176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions fe/src/components/IssueDetail/IssueCommentContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,26 @@ export default function IssueCommentContainer({
useCallback(() => getComments(issueNumber, cursor), [issueNumber, cursor])
);

const handleScroll = useCallback(() => {
const scrollHeight = document.documentElement.scrollHeight;
const scrollTop = window.scrollY;
const clientHeight = window.innerHeight;
const margin = 200;

const isNearlyBottom = scrollHeight - (scrollTop + clientHeight) <= margin;
isNearlyBottom &&
issueComments?.hasMore &&
setCursor(issueComments.nextCursor);
}, [issueComments]);

useEffect(() => {
issueComments && setAllComments((prev) => [...prev, ...issueComments.data]);
}, [issueComments]);

useEffect(() => {
const handleScroll = () => {
const scrollHeight = document.documentElement.scrollHeight;
const scrollTop = window.scrollY;
const clientHeight = window.innerHeight;

const isBottom = scrollHeight - scrollTop === clientHeight;
isBottom && issueComments?.hasMore && setCursor(issueComments.nextCursor);
};

window.addEventListener("scroll", handleScroll);
return () => window.removeEventListener("scroll", handleScroll);
}, [issueComments]);
}, [handleScroll]);

const isFilled = !!newComment;

Expand Down
7 changes: 3 additions & 4 deletions fe/src/components/common/Sidebar/AssigneeField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ export default function AssigneeField({
}) {
const { data: userList } = useFetch(getUsers);

const assigneeDropdownList: DropdownItemType[] | undefined = userList?.map(
(user) => ({
const assigneeDropdownList: DropdownItemType[] =
userList?.map((user) => ({
id: user.userAccountId,
variant: "withImg",
name: "assignee",
content: user.username,
imgSrc: user.profileUrl,
})
);
})) || [];

const generateAssignees = (userList: User[]) => {
const currentAssignees = userList.filter((user) =>
Expand Down
7 changes: 3 additions & 4 deletions fe/src/components/common/Sidebar/LabelField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ export default function LabelField({
}) {
const { data: labelList } = useFetch(getLabels);

const labelDropdownList: DropdownItemType[] | undefined = labelList?.map(
(label) => ({
const labelDropdownList: DropdownItemType[] =
labelList?.map((label) => ({
id: label.labelId,
variant: "withColor",
name: "label",
content: label.name,
colorFill: label.backgroundColor,
})
);
})) || [];

const generateLabels = (labelList: Label[]) => {
const currentLabels = labelList.filter((label) =>
Expand Down
6 changes: 3 additions & 3 deletions fe/src/components/common/Sidebar/MilestoneField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ export default function MilestoneField({
onEditMilestone,
}: {
milestone: number;
onMilestoneChange: (milestoneId: number) => void;
onMilestoneChange: (milestone: number) => void;
onEditMilestone?: () => void;
}) {
const { data: milestonesList } = useFetch(getMilestones);

const milestoneDropdownList: DropdownItemType[] | undefined =
const milestoneDropdownList: DropdownItemType[] =
milestonesList?.map((milestone) => ({
id: milestone.milestoneId,
variant: "plain",
name: "milestone",
content: milestone.milestoneName,
}));
})) || [];

const generateMilestone = (milestonesList: Milestone[]) => {
const milestone = milestonesList.find(
Expand Down
2 changes: 1 addition & 1 deletion fe/src/pages/MainPage/NewIssuePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default function NewIssuePage() {
/>
<div className="form">
<TextInput
name="title"
name="제목"
variant="tall"
placeholder="제목"
value={newIssueInfo.title}
Expand Down