diff --git a/src/components/productComponents/cosmeticComponent.tsx b/src/components/productComponents/cosmeticComponent.tsx index 6423b04..c2f78ac 100644 --- a/src/components/productComponents/cosmeticComponent.tsx +++ b/src/components/productComponents/cosmeticComponent.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from "react"; import { sendCosmeticDataRequest } from "../../content/apiSetting/sendCosmeticDataRequest"; import Loading from "../Loading/component"; +import { useTheme } from "@src/contexts/ThemeContext"; const INGREDIENT_KO_MAP: Record = { avobenzone: "아보벤존", @@ -27,26 +28,13 @@ const INGREDIENT_KO_MAP: Record = { }; export const CosmeticComponent = () => { + const { fontClasses, theme } = useTheme(); + const isDarkMode = theme === "dark"; const [detectedIngredients, setDetectedIngredients] = useState( [], ); const [isLoading, setIsLoading] = useState(true); - const commonTextStyle: React.CSSProperties = { - fontFamily: "KoddiUD OnGothic", - fontSize: "28px", - fontWeight: 700, - lineHeight: "150%", - textAlign: "left", - }; - const commonTextStyle24: React.CSSProperties = { - fontFamily: "KoddiUD OnGothic", - fontSize: "24px", - fontWeight: 700, - lineHeight: "150%", - textAlign: "left", - }; - useEffect(() => { const fetchData = async () => { try { @@ -115,24 +103,13 @@ export const CosmeticComponent = () => { if (isLoading) { return (
-
+
제품 정보를 분석 중입니다.
@@ -142,50 +119,39 @@ export const CosmeticComponent = () => { return (
-

[화장품] 성분 안내

+

+ [화장품] 성분 안내 +

+
- {detectedIngredients.length > 0 && ( -
- {detectedIngredients.map((item, idx) => ( + 검출된 성분 + 총 {detectedIngredients.length}개 +
+ + {detectedIngredients.length > 0 && ( +
+ {detectedIngredients.map((item, idx) => ( +
{item}
- ))} -
- )} -
+ {idx !== detectedIngredients.length - 1 && ( +
+ )} +
+ ))} +
+ )}
); }; diff --git a/src/components/productComponents/couponComponent.tsx b/src/components/productComponents/couponComponent.tsx deleted file mode 100644 index 150ed4c..0000000 --- a/src/components/productComponents/couponComponent.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { downloadAllCoupons } from "../../content/coupang/downloadAllCoupons"; -import { checkCouponStatus } from "../../content/coupang/checkCouponStatus"; - -interface Props { - coupons: string[]; -} - -export const CouponComponent: React.FC = ({ coupons }) => { - const [downloaded, setDownloaded] = useState(false); - const [status, setStatus] = useState< - "none" | "downloadable" | "downloaded" - >("downloadable"); - - useEffect(() => { - const currentStatus = checkCouponStatus(); - setStatus(currentStatus); - }, []); - - useEffect(() => { - const listener = () => { - setDownloaded(true); - setStatus("downloaded"); - }; - window.addEventListener("voim-coupon-downloaded", listener); - return () => - window.removeEventListener("voim-coupon-downloaded", listener); - }, []); - - if (status === "none" || !coupons || coupons.length === 0) return null; - - const commonTextStyle: React.CSSProperties = { - fontFamily: "KoddiUD OnGothic", - fontSize: "28px", - fontStyle: "normal", - fontWeight: 700, - lineHeight: "150%", - textAlign: "center", - }; - - const handleDownload = async () => { - await downloadAllCoupons(); - setDownloaded(true); - setStatus("downloaded"); - }; - - return ( -
- {status === "downloadable" && !downloaded && ( - - )} -
- ); -}; diff --git a/src/components/productComponents/foodComponent.tsx b/src/components/productComponents/foodComponent.tsx index 52588ee..c3efe1e 100644 --- a/src/components/productComponents/foodComponent.tsx +++ b/src/components/productComponents/foodComponent.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from "react"; import { sendFoodDataRequest } from "../../content/apiSetting/sendFoodDataRequest"; import Loading from "../Loading/component"; +import { useTheme } from "@src/contexts/ThemeContext"; interface Nutrient { nutrientType: string; @@ -45,6 +46,8 @@ const allergyNameMap: Record = { }; export const FoodComponent = () => { + const { fontClasses, theme } = useTheme(); + const isDarkMode = theme === "dark"; const [nutrientAlerts, setNutrientAlerts] = useState( null, ); @@ -176,24 +179,17 @@ export const FoodComponent = () => { if (nutrientAlerts === null || allergyTypes === null) { return (
-
+
제품 정보를 분석 중입니다.
@@ -203,92 +199,91 @@ export const FoodComponent = () => { return (
-

식품 영양 및 알러지 성분

-
+

+ 식품 영양 및 알러지 성분 +

+
하루 기준 섭취량의 40% 넘는 영양성분 총 {nutrientAlerts.length}개
{nutrientOpen && nutrientAlerts.length > 0 && (
{nutrientAlerts.map((item, idx) => ( -
- - {nutrientNameMap[item.nutrientType] || - item.nutrientType} - - {item.percentage}% +
+
+ + {nutrientNameMap[item.nutrientType] || + item.nutrientType}{" "} + + {item.percentage}% +
+ + {idx !== nutrientAlerts.length - 1 && ( +
+ )}
))}
)}
알레르기 유발 성분 총 {allergyTypes.length}개
{allergyOpen && allergyTypes.length > 0 && (
{allergyTypes.map((item, idx) => ( -
- {allergyNameMap[item] || item} +
+
+ {allergyNameMap[item] || item} +
+ + {idx !== allergyTypes.length - 1 && ( +
+ )}
))}
diff --git a/src/components/productComponents/healthComponent.tsx b/src/components/productComponents/healthComponent.tsx index 5a00ec5..dc5f2a5 100644 --- a/src/components/productComponents/healthComponent.tsx +++ b/src/components/productComponents/healthComponent.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from "react"; import { sendHealthDataRequest } from "../../content/apiSetting/sendHealthDataRequest"; import Loading from "../Loading/component"; +import { useTheme } from "@src/contexts/ThemeContext"; const healthEffectMap: Record = { IMMUNE: "면역기능", @@ -38,6 +39,8 @@ const healthEffectMap: Record = { }; export const HealthComponent = () => { + const { fontClasses, theme } = useTheme(); + const isDarkMode = theme === "dark"; const [healthTypes, setHealthTypes] = useState(null); const commonTextStyle: React.CSSProperties = { @@ -140,24 +143,13 @@ export const HealthComponent = () => { if (healthTypes === null) { return (
-
+
제품 정보를 분석 중입니다.
@@ -167,41 +159,35 @@ export const HealthComponent = () => { return (
-

+

해당 제품의 기능성 효능 {healthTypes.length}가지

-
+ +
+ 검출된 기능성 효능 + 총 {healthTypes.length}개 +
+ {healthTypes.length > 0 && (
{healthTypes.map((item, idx) => ( -
- {healthEffectMap[item] || item} +
+
+ {healthEffectMap[item] || item} +
+ {idx !== healthTypes.length - 1 && ( +
+ )}
))}