diff --git a/src/components/Certification/MyAllCurrentCertification/MyProfile/MyProfile.tsx b/src/components/Certification/MyAllCurrentCertification/MyProfile/MyProfile.tsx
index d175b163..0ebd241b 100644
--- a/src/components/Certification/MyAllCurrentCertification/MyProfile/MyProfile.tsx
+++ b/src/components/Certification/MyAllCurrentCertification/MyProfile/MyProfile.tsx
@@ -3,6 +3,7 @@ import { FRAMEID } from "@/constants/localStorageKey";
import { decrypt } from "@/hooks/useCrypto";
import { useGetUserProfile } from "@/hooks/queries/useProfileQuery";
import { profileImageFrame } from "@/data/frameData";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
interface Props {
decryptedUserId: number;
@@ -24,7 +25,7 @@ function MyProfile({ decryptedUserId }: Props) {
/>
)}
diff --git a/src/components/Certification/OthersAllCurrentCertification/OthersProfile/OthersProfile.tsx b/src/components/Certification/OthersAllCurrentCertification/OthersProfile/OthersProfile.tsx
index 58f494a5..1e8c78f0 100644
--- a/src/components/Certification/OthersAllCurrentCertification/OthersProfile/OthersProfile.tsx
+++ b/src/components/Certification/OthersAllCurrentCertification/OthersProfile/OthersProfile.tsx
@@ -1,6 +1,7 @@
import { Profile } from "@/components/Common/Profile/Profile";
import { useGetUserProfile } from "@/hooks/queries/useProfileQuery";
import { profileImageFrame } from "@/data/frameData";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
interface Props {
decryptedUserId: number;
@@ -20,7 +21,7 @@ function OthersProfile({ decryptedUserId }: Props) {
/>
)}
diff --git a/src/components/ChallengeDetail/ChallengeDetailContent/ChallengeDetailContent.tsx b/src/components/ChallengeDetail/ChallengeDetailContent/ChallengeDetailContent.tsx
index ce99d8df..9207060f 100644
--- a/src/components/ChallengeDetail/ChallengeDetailContent/ChallengeDetailContent.tsx
+++ b/src/components/ChallengeDetail/ChallengeDetailContent/ChallengeDetailContent.tsx
@@ -4,6 +4,7 @@ import Image from "@/components/ChallengeDetail/Image/Image";
import Information from "@/components/ChallengeDetail/Information/Information";
import Line from "@/components/ChallengeDetail/Line/Line";
import ParticipationCancelButton from "@/components/ChallengeDetail/ParticipationCancelButton/ParticipationCancelButton";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
import { useGetChallengeDetail } from "@/hooks/queries/useInstanceDetailQuery";
interface Props {
@@ -26,7 +27,7 @@ function ChallengeDetailContent({ decryptId }: Props) {
return (
<>
-
+
onClick(encrypt(item.instanceId))}
>
diff --git a/src/components/Home/InfiniteNewChallenge/InfiniteNewChallenge.tsx b/src/components/Home/InfiniteNewChallenge/InfiniteNewChallenge.tsx
index 9804629f..c3f8272b 100644
--- a/src/components/Home/InfiniteNewChallenge/InfiniteNewChallenge.tsx
+++ b/src/components/Home/InfiniteNewChallenge/InfiniteNewChallenge.tsx
@@ -27,7 +27,7 @@ function InfiniteNewChallenge() {
)}
-
+
{data?.pages.map((page) => (
))}
diff --git a/src/components/Home/PopularChallengeItems/PopularChallengeItems.tsx b/src/components/Home/PopularChallengeItems/PopularChallengeItems.tsx
index 75e658bc..2aaab7f6 100644
--- a/src/components/Home/PopularChallengeItems/PopularChallengeItems.tsx
+++ b/src/components/Home/PopularChallengeItems/PopularChallengeItems.tsx
@@ -8,6 +8,7 @@ import { useState } from "react";
import { encrypt } from "@/hooks/useCrypto";
import { useGetPopularInstance } from "@/hooks/queries/useHomeInstanceQuery";
import EmptyDataComponent from "../EmptyDataComponent/EmptyDataComponent";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
function PopularChallengeItems() {
const [clickPossible, setClickPossible] = useState
(true);
@@ -45,7 +46,7 @@ function PopularChallengeItems() {
onClick={() => onClick(item.instanceId, clickPossible)}
>
diff --git a/src/components/Home/SuggestionChallengeItems/SuggestionChallengeItems.tsx b/src/components/Home/SuggestionChallengeItems/SuggestionChallengeItems.tsx
index f080131e..f5cefbe1 100644
--- a/src/components/Home/SuggestionChallengeItems/SuggestionChallengeItems.tsx
+++ b/src/components/Home/SuggestionChallengeItems/SuggestionChallengeItems.tsx
@@ -8,6 +8,7 @@ import { useState } from "react";
import { encrypt } from "@/hooks/useCrypto";
import { useGetRecommendInstance } from "@/hooks/queries/useHomeInstanceQuery";
import EmptyDataComponent from "../EmptyDataComponent/EmptyDataComponent";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
function SuggestionChallengeItems() {
const [clickPossible, setClickPossible] = useState(true);
@@ -43,7 +44,7 @@ function SuggestionChallengeItems() {
onClick={() => onClick(item.instanceId, clickPossible)}
>
diff --git a/src/components/Main/MyChallenge/MyChallengeActivityList/MyChallengeActivityList.tsx b/src/components/Main/MyChallenge/MyChallengeActivityList/MyChallengeActivityList.tsx
index 8b700e3a..da002959 100644
--- a/src/components/Main/MyChallenge/MyChallengeActivityList/MyChallengeActivityList.tsx
+++ b/src/components/Main/MyChallenge/MyChallengeActivityList/MyChallengeActivityList.tsx
@@ -11,6 +11,7 @@ import CertificationModal from "@/components/Main/MyChallenge/MyChallengeModal/C
import { EmptyDataView } from "@/components/Common/EmptyDataView/EmptyDataView";
import { PATH } from "@/constants/path";
import { useModalStore } from "@/stores/modalStore";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
interface PassItemModal {
e: React.MouseEvent;
@@ -70,7 +71,7 @@ const MyChallengeActivityList = () => {
diff --git a/src/components/Main/MyChallenge/MyChallengeDoneList/MyChallengeDoneList.tsx b/src/components/Main/MyChallenge/MyChallengeDoneList/MyChallengeDoneList.tsx
index 055ed82c..acbf3254 100644
--- a/src/components/Main/MyChallenge/MyChallengeDoneList/MyChallengeDoneList.tsx
+++ b/src/components/Main/MyChallenge/MyChallengeDoneList/MyChallengeDoneList.tsx
@@ -9,6 +9,7 @@ import React from "react";
import { EmptyDataView } from "@/components/Common/EmptyDataView/EmptyDataView";
import { useModalStore } from "@/stores/modalStore";
import { useGetMyDoneChallenges } from "@/hooks/queries/useMyChallengeQuery";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
const MyChallengeDoneList = () => {
const { setModal } = useModalStore();
@@ -60,7 +61,7 @@ const MyChallengeDoneList = () => {
diff --git a/src/components/Main/MyChallenge/MyChallengePreActivityList/MyChallengePreActivityList.tsx b/src/components/Main/MyChallenge/MyChallengePreActivityList/MyChallengePreActivityList.tsx
index 53b19e50..7c180249 100644
--- a/src/components/Main/MyChallenge/MyChallengePreActivityList/MyChallengePreActivityList.tsx
+++ b/src/components/Main/MyChallenge/MyChallengePreActivityList/MyChallengePreActivityList.tsx
@@ -6,6 +6,7 @@ import MyChallengeWrap from "../MyChallengeWrap/MyChallengeWrap";
import { useGetMyPreActivityChallenges } from "@/hooks/queries/useMyChallengeQuery";
import { EmptyDataView } from "@/components/Common/EmptyDataView/EmptyDataView";
import { PATH } from "@/constants/path";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
function MyChallengePreActivityList() {
const { data } = useGetMyPreActivityChallenges();
@@ -29,7 +30,7 @@ function MyChallengePreActivityList() {
diff --git a/src/components/MyPage/InterestChallenge/InfiniteInterestChallenge/InfiniteInterestChallenge.tsx b/src/components/MyPage/InterestChallenge/InfiniteInterestChallenge/InfiniteInterestChallenge.tsx
index f716152d..284c90d2 100644
--- a/src/components/MyPage/InterestChallenge/InfiniteInterestChallenge/InfiniteInterestChallenge.tsx
+++ b/src/components/MyPage/InterestChallenge/InfiniteInterestChallenge/InfiniteInterestChallenge.tsx
@@ -2,6 +2,7 @@ import ChallengeItem from "@/components/Common/ChallengeItem/ChallengeItem";
import { EmptyDataView } from "@/components/Common/EmptyDataView/EmptyDataView";
import LoadingBox from "@/components/Common/Loading/LoadingBox/LoadingBox";
import { PATH } from "@/constants/path";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
import {
useDeleteLikesChallenge,
useGetInfiniteLikedChallenges,
@@ -51,7 +52,7 @@ function InfiniteInterestChallenge() {
)}
{!!data?.pages[0].posts.length && (
-
+
{data?.pages.map((page, pageIndex) =>
page.posts.map(
(post: InstanceThumbnailDataType, postIndex: number) => (
@@ -63,11 +64,9 @@ function InfiniteInterestChallenge() {
onClick={() => onClickChallengeItem(post.instanceId)}
>
onClickHeart(e, post.likesId)}
diff --git a/src/components/MyPage/MyPage/MyProfile/MyProfile.tsx b/src/components/MyPage/MyPage/MyProfile/MyProfile.tsx
index ed700992..3bb12a35 100644
--- a/src/components/MyPage/MyPage/MyProfile/MyProfile.tsx
+++ b/src/components/MyPage/MyPage/MyProfile/MyProfile.tsx
@@ -6,6 +6,7 @@ import { FRAMEID } from "@/constants/localStorageKey";
import { decrypt } from "@/hooks/useCrypto";
import { useGetMyProfile } from "@/hooks/queries/useProfileQuery";
import { profileImageFrame } from "@/data/frameData";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
function MyProfile() {
const { data } = useGetMyProfile();
@@ -29,7 +30,7 @@ function MyProfile() {
/>
)}
diff --git a/src/components/MyPage/UserInfoEdit/UserInformationEditForm/UserInformationEditForm.tsx b/src/components/MyPage/UserInfoEdit/UserInformationEditForm/UserInformationEditForm.tsx
index 102c9e10..eff74e7d 100644
--- a/src/components/MyPage/UserInfoEdit/UserInformationEditForm/UserInformationEditForm.tsx
+++ b/src/components/MyPage/UserInfoEdit/UserInformationEditForm/UserInformationEditForm.tsx
@@ -15,9 +15,9 @@ import { Input, TextArea } from "@/components/Common/Form";
import { useGetCheckNickName } from "@/hooks/queries/useUserQuery";
import Button from "@/components/Common/Button";
import ProfileImage from "../../MyPage/UserEdit/UserImg/UserImg";
-import { makeBase64URL } from "@/utils/makeBase64URL";
import userImage from "@/assets/icon/image-edit.svg";
import CommonModal from "@/components/Common/CommonModal/CommonModal";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
interface UserInformationFormType {
nickname: string;
@@ -136,15 +136,11 @@ function UserInformationEditForm() {
};
useEffect(() => {
+ if (!profileData) return;
const file = changedImage?.[0];
if (!file) {
- setImagePreview(
- makeBase64URL({
- uri: profileData?.fileResponse?.source,
- format: "jpg",
- })
- );
+ setImagePreview(makeAPIImage(profileData.fileResponse));
return;
}
@@ -154,7 +150,7 @@ function UserInformationEditForm() {
return () => {
if (objectUrl) URL.revokeObjectURL(objectUrl);
};
- }, [profileData?.fileResponse?.source, changedImage]);
+ }, [profileData, changedImage]);
const validateFileSize = (files: FileList | null) => {
if (!files?.length) return true;
diff --git a/src/helpers/makeAPIImage.ts b/src/helpers/makeAPIImage.ts
new file mode 100644
index 00000000..02fb9c60
--- /dev/null
+++ b/src/helpers/makeAPIImage.ts
@@ -0,0 +1,8 @@
+import { APIImage } from "@/types/apiImageType";
+import { makeBase64URL } from "@/utils/makeBase64URL";
+
+export const makeAPIImage = (file: APIImage) => {
+ const { source, environment } = file;
+ if (environment === "LOCAL") return makeBase64URL({ uri: source });
+ else return source;
+};
diff --git a/src/pages/Admin/AdminInstance/InstanceEdit/InstanceEdit.tsx b/src/pages/Admin/AdminInstance/InstanceEdit/InstanceEdit.tsx
index a29505f8..64dcb71b 100644
--- a/src/pages/Admin/AdminInstance/InstanceEdit/InstanceEdit.tsx
+++ b/src/pages/Admin/AdminInstance/InstanceEdit/InstanceEdit.tsx
@@ -18,7 +18,7 @@ import { interestsOption } from "@/data/InterestData";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import { ko } from "date-fns/locale";
-import { makeBase64URL } from "@/utils/makeBase64URL";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
type DateRange = [Date | null, Date | null];
@@ -108,12 +108,7 @@ const InstanceEdit = () => {
trigger("image");
const file = image?.[0];
if (!file) {
- setImagePreview(
- makeBase64URL({
- uri: instanceDetail?.fileResponse?.source,
- format: "jpg",
- })
- );
+ setImagePreview(makeAPIImage(instanceDetail.fileResponse));
return;
}
@@ -123,7 +118,7 @@ const InstanceEdit = () => {
return () => {
if (objectUrl) URL.revokeObjectURL(objectUrl);
};
- }, [image, instanceDetail?.fileResponse?.source, trigger]);
+ }, [image, instanceDetail, trigger]);
useEffect(() => {
if (instanceDetail) {
diff --git a/src/pages/Certification/OthersCurrentCertification/OthersCurrentCertification.tsx b/src/pages/Certification/OthersCurrentCertification/OthersCurrentCertification.tsx
index fea192df..cc2a11ca 100644
--- a/src/pages/Certification/OthersCurrentCertification/OthersCurrentCertification.tsx
+++ b/src/pages/Certification/OthersCurrentCertification/OthersCurrentCertification.tsx
@@ -9,6 +9,7 @@ import { useParams } from "react-router-dom";
import { AllWeekCertificationDataType } from "@/types/certificationType";
import LoadingBox from "@/components/Common/Loading/LoadingBox/LoadingBox";
import { useGetAllCertificationWeek } from "@/hooks/queries/useCertificationQuery";
+import { makeAPIImage } from "@/helpers/makeAPIImage";
function OthersCurrentCertification() {
const { id } = useParams();
@@ -39,7 +40,7 @@ function OthersCurrentCertification() {