Skip to content

Commit 7c2adbd

Browse files
authored
Merge pull request #79 from CodeItBoost3/feature/post-ui-fix
내가 속한 그룹 목록 이미지 꺠짐 문제 해결
2 parents 209b1d7 + 1c20389 commit 7c2adbd

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/components/modal/SelectGroupModal.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import GroupList from "@/components/mypage/GroupList.jsx";
33
import userService from "@/services/user/userService";
44
import DummyImg from "@/assets/image/profile-basic2.svg";
55
import CreateMemory from "@/components/modal/CreateMemory";
6+
import {decodeImageUrl} from "../../utils/decodeImageUrl.js";
67

78
export default function SelectGroupModal({ onClose }) {
89
const [groups, setGroups] = useState([]);
@@ -16,7 +17,7 @@ export default function SelectGroupModal({ onClose }) {
1617
const groupList = response.data.groups.map((item) => ({
1718
id: item.group.groupId,
1819
name: item.group.groupName,
19-
image: item.group.imageUrl || DummyImg,
20+
image: item.group.imageUrl ? `${decodeImageUrl(item.group.imageUrl)}` : DummyImg,
2021
}));
2122

2223
setGroups(groupList);

src/components/mypage/GroupCard.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import userService from "@/services/user/userService";
44
import { useToast } from "@/hooks/useToast";
55
import DummyImg from "@/assets/image/profile-basic2.svg";
66
import useValidateLogin from "@/hooks/useValidateLogin.js";
7+
import {decodeImageUrl} from "@/utils/decodeImageUrl.js";
78

89
export default function GroupCard() {
910
const [groups, setGroups] = useState([]);
@@ -14,10 +15,11 @@ export default function GroupCard() {
1415
const fetchGroups = async () => {
1516
try {
1617
const response = await userService.getMyGroups();
18+
console.log(response);
1719
const groupList = response.data.groups.map((item) => ({
1820
id: item.group.groupId,
1921
name: item.group.groupName,
20-
image: item.group.imageUrl || DummyImg,
22+
image: item.group.imageUrl ? `${decodeImageUrl(item.group.imageUrl)}` : DummyImg,
2123
}));
2224

2325
setGroups(groupList);

src/pages/Main.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export default function Main() {
204204
</div>
205205
</div>
206206
{/* 섹션 2 */}
207-
<MemoryActions widthClass="flex-1" marginTop="mt-[7vh]" onClickGroup={handleGroupRegist}/>
207+
<MemoryActions widthClass="flex-1" marginTop="mt-[7vh]" onClickGroup={handleGroupRegist} isLogin={isLogin}/>
208208
</div>
209209
{isGroupMakeModalOpen && <CreateGroup onClose={() => setIsGroupMakeModalOpen(false)}/>}
210210
{isLoginModalOpen && <NeedLoginToGuest onClick={handleLoginModal}/>}

src/utils/decodeImageUrl.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const decodeImageUrl = (url) => {
2+
if (!url) return null;
3+
4+
try {
5+
const decodedUrl = decodeURIComponent(url);
6+
return `https://d1up383l0okfvw.cloudfront.net/${decodedUrl}`;
7+
} catch {
8+
return `https://d1up383l0okfvw.cloudfront.net/${url}`;
9+
}
10+
};

0 commit comments

Comments
 (0)