Skip to content
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
29 changes: 21 additions & 8 deletions src/app/routes/private/ArticlesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ export default function ArticlesPage() {
};

const [sortValue, setSortValue] = useState(
reverseSortMap[orderBy] || "게시일"
reverseSortMap[orderBy] || "게시일",
);
const [directionValue, setDirectionValue] = useState(
direction === "DESC" ? "내림차순" : "오름차순"
direction === "DESC" ? "내림차순" : "오름차순",
);

const fetchInitialData = useCallback(async () => {
Expand Down Expand Up @@ -225,7 +225,7 @@ export default function ArticlesPage() {
},
{
threshold: 0.8,
}
},
);
if (lastElementRef.current) {
observerRef.current.observe(lastElementRef.current);
Expand All @@ -238,13 +238,13 @@ export default function ArticlesPage() {

const interestNames = useMemo(
() => interests.map((interest) => interest.name),
[interests]
[interests],
);

const handleInterestChange = (value: string) => {
setSelectedInterest(value);
const selectedInterestData = interests.find(
(interest) => interest.name === value
(interest) => interest.name === value,
);

if (selectedInterestData) {
Expand Down Expand Up @@ -290,21 +290,21 @@ export default function ArticlesPage() {

newParams.set(
"direction",
directionValue === "오름차순" ? "ASC" : "DESC"
directionValue === "오름차순" ? "ASC" : "DESC",
);

if (fromDate) {
newParams.set(
"publishDateFrom",
`${fromDate.replace(/\./g, "-")}T00:00:00`
`${fromDate.replace(/\./g, "-")}T00:00:00`,
);
} else {
newParams.delete("publishDateFrom");
}
if (toDate) {
newParams.set(
"publishDateTo",
`${toDate.replace(/\./g, "-")}T23:59:59`
`${toDate.replace(/\./g, "-")}T23:59:59`,
);
} else {
newParams.delete("publishDateTo");
Expand All @@ -326,6 +326,19 @@ export default function ArticlesPage() {
fetchInterestData();
}, [fetchInterestData]);

useEffect(() => {
if (interests.length > 0 && interestId) {
const matchedInterest = interests.find(
(interest) => interest.id === interestId,
);
if (matchedInterest) {
setSelectedInterest(matchedInterest.name);
}
} else if (!interestId) {
setSelectedInterest("");
}
}, [interests, interestId]);

useEffect(() => {
setSortValue(reverseSortMap[orderBy] || "게시일");
setDirectionValue(direction === "DESC" ? "내림차순" : "오름차순");
Expand Down
2 changes: 1 addition & 1 deletion src/features/interests/components/InterestCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default function InterestCard({
</Button>
) : (
<Button
className="min-w-[80px]"
className="min-w-[91px]"
size="sm"
onClick={handleSubscribeClick}
>
Expand Down