Skip to content

Commit a511a4e

Browse files
committed
feat: S3 URL 체크 함수 utils로 만들기
1 parent 2ebac6b commit a511a4e

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/app/(pages)/(albaform)/alba/[formId]/components/FormImage.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Image from "next/image";
22
import Indicator from "@/app/components/pagination/Indicator";
3+
import { isValidS3Url } from "@/utils/checkS3Url";
34

45
interface FormImageProps {
56
imageUrls: string[];
@@ -30,9 +31,11 @@ export default function FormImage({ imageUrls, currentPage, onPageChange }: Form
3031
))}
3132

3233
{/* 인디케이터 */}
33-
<div className="absolute bottom-4 left-1/2 -translate-x-1/2">
34-
<Indicator imageCount={imageUrls?.length ?? 0} currentPage={currentPage} onPageChange={onPageChange} />
35-
</div>
34+
{imageUrls.filter((url) => isValidS3Url(url)).length > 1 && (
35+
<div className="absolute bottom-4 left-1/2 -translate-x-1/2">
36+
<Indicator imageCount={imageUrls?.length ?? 0} currentPage={currentPage} onPageChange={onPageChange} />
37+
</div>
38+
)}
3639
</div>
3740
);
3841
}

src/app/components/card/cardList/AlbaListItem.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import Indicator from "../../pagination/Indicator";
1010
import { FormListType } from "@/types/response/form";
1111
import { useFormScrap } from "@/hooks/queries/form/useFormScap";
1212
import { MdOutlineImage } from "react-icons/md";
13-
import { S3_URL } from "@/constants/config";
1413
import DotLoadingSpinner from "../../loading-spinner/DotLodingSpinner";
14+
import { isValidS3Url } from "@/utils/checkS3Url";
1515

1616
/**
1717
* 알바폼 리스트 아이템 컴포넌트
@@ -125,11 +125,6 @@ const AlbaListItem = ({
125125
});
126126
};
127127

128-
// S3 URL 체크 함수
129-
const isValidS3Url = (url: string) => {
130-
return url.startsWith(S3_URL);
131-
};
132-
133128
return (
134129
<div className="relative h-auto w-[327px] overflow-hidden rounded-xl border border-grayscale-200 bg-white shadow-md transition-transform duration-300 hover:scale-[1.02] lg:w-[372px]">
135130
{/* 이미지 슬라이더 영역 */}

src/utils/checkS3Url.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { S3_URL } from "@/constants/config";
2+
3+
// S3 URL 체크 함수
4+
export const isValidS3Url = (url: string) => {
5+
return url.startsWith(S3_URL);
6+
};

0 commit comments

Comments
 (0)