diff --git a/com.twin.app.shoptime/src/views/CheckOutPanel/CheckOutPanel.jsx b/com.twin.app.shoptime/src/views/CheckOutPanel/CheckOutPanel.jsx
index b23b70af..1fd7c1a9 100644
--- a/com.twin.app.shoptime/src/views/CheckOutPanel/CheckOutPanel.jsx
+++ b/com.twin.app.shoptime/src/views/CheckOutPanel/CheckOutPanel.jsx
@@ -17,7 +17,6 @@ export default function CheckOutPanel() {
const { userInfo } = useSelector(
(state) => state.common.appStatus.loginUserData
);
- const panelInfo = useSelector((state) => state.panels.panels);
useEffect(() => {
dispatch(
@@ -50,7 +49,7 @@ export default function CheckOutPanel() {
/>
-
+
diff --git a/com.twin.app.shoptime/src/views/CheckOutPanel/container/SummaryContainer.module.less b/com.twin.app.shoptime/src/views/CheckOutPanel/container/SummaryContainer.module.less
index d9c5fbda..ad5144fb 100644
--- a/com.twin.app.shoptime/src/views/CheckOutPanel/container/SummaryContainer.module.less
+++ b/com.twin.app.shoptime/src/views/CheckOutPanel/container/SummaryContainer.module.less
@@ -54,24 +54,22 @@
}
.bottom {
- padding: 69px 60px 40px 60px;
+ padding: 0 60px;
.checkboxWrap {
display: flex;
- }
- .checkbox {
- .size(@w: 40px, @h: 40px);
- background-image: url("../../../../assets/images/btn/btn-check-nor.svg");
- background-position: center;
- background-size: cover;
- margin: 0 12px 20px 0;
- }
+ align-items: center;
- .contents {
- font-weight: normal;
- font-size: 24px;
- color: #009cff;
- text-decoration: underline;
+ .checkbox {
+ }
+
+ .contents {
+ font-weight: normal;
+ font-size: 24px;
+ color: #009cff;
+ text-decoration: underline;
+ transform: translateY(-3px);
+ }
}
.tButton {
diff --git a/com.twin.app.shoptime/src/views/CheckOutPanel/container/SummaryCotainer.jsx b/com.twin.app.shoptime/src/views/CheckOutPanel/container/SummaryCotainer.jsx
index ff08f0ec..f958fa61 100644
--- a/com.twin.app.shoptime/src/views/CheckOutPanel/container/SummaryCotainer.jsx
+++ b/com.twin.app.shoptime/src/views/CheckOutPanel/container/SummaryCotainer.jsx
@@ -1,10 +1,15 @@
-import React, { useCallback, useEffect, useState } from "react";
+import React, { useCallback, useEffect, useMemo, useState } from "react";
-import { useSelector } from "react-redux";
+import { useDispatch, useSelector } from "react-redux";
import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator";
+import { registerDevice } from "../../../actions/deviceActions";
+import { getHomeTerms } from "../../../actions/homeActions";
+import { setPurchaseTermsAgree } from "../../../actions/orderActions";
import TButton from "../../../components/TButton/TButton";
+import TCheckBox from "../../../components/TCheckBox/TCheckBox";
+import { $L } from "../../../utils/helperMethods";
import css from "./SummaryContainer.module.less";
const Container = SpotlightContainerDecorator(
@@ -12,13 +17,28 @@ const Container = SpotlightContainerDecorator(
"div"
);
-const terms = [
- { content: "Agree to the Terms of Purchase" },
- { content: "Agree to the Privacy Policy" },
-];
+export default function SummaryContainer({ userInfo }) {
+ const dispatch = useDispatch();
-export default function SummaryContainer() {
const { productList } = useSelector((state) => state.checkout.checkoutData);
+ const termsData = useSelector((state) => state.home.termsData);
+ const { checkoutTermsAgree } = useSelector((state) => state.common);
+
+ const checkoutTermsData = useMemo(
+ () =>
+ termsData?.data?.terms
+ .filter(
+ (item) => item.trmsTpCd === "MST00403" || item.trmsTpCd === "MST00404"
+ )
+ .map((term) => ({
+ id: term.trmsId,
+ content:
+ term.trmsTpCd === "MST00403"
+ ? `${$L("Agree to the Terms of Purchase")}`
+ : `${$L("Agree to the Privacy Policy")}`,
+ })),
+ [termsData]
+ );
const [summary, setSummary] = useState({
itemPrice: "0",
@@ -30,6 +50,15 @@ export default function SummaryContainer() {
currSign: "",
currSignLoc: "",
});
+ const [agreements, setAgreements] = useState(() => {
+ const initialAgreements = {};
+
+ checkoutTermsData.forEach(({ id }) => {
+ initialAgreements[id] = checkoutTermsAgree;
+ });
+
+ return initialAgreements;
+ });
const itemSetting = useCallback((productList) => {
if (!productList || productList.length === 0) return;
@@ -89,6 +118,41 @@ export default function SummaryContainer() {
{ name: "Your Coupon Savings", value: summary.couponPrice },
];
+ useEffect(() => {
+ const initialAgreements = Object.fromEntries(
+ checkoutTermsData.map(({ id }) => [id, checkoutTermsAgree])
+ );
+ setAgreements(initialAgreements);
+ }, [checkoutTermsData, checkoutTermsAgree]);
+
+ const handleAgreeCheck = useCallback((trmsId) => {
+ setAgreements((prev) => ({ ...prev, [trmsId]: !prev[trmsId] }));
+ }, []);
+
+ const handleClickOrder = useCallback(() => {
+ const allAgreed = Object.values(agreements).every((agreed) => agreed);
+
+ if (checkoutTermsAgree) {
+ if (allAgreed) {
+ console.log("success");
+ } else {
+ console.error("failed (please check checkbox)");
+ }
+ } else {
+ if (allAgreed) {
+ const agreeTerms = Object.keys(agreements).filter(
+ (trmsId) => agreements[trmsId]
+ );
+ dispatch(
+ setPurchaseTermsAgree({ mbrNo: userInfo, termsList: agreeTerms })
+ );
+ console.log("success");
+ } else {
+ console.error("failed (not agree terms)");
+ }
+ }
+ }, [dispatch, agreements, userInfo, checkoutTermsAgree]);
+
return (
@@ -120,13 +184,19 @@ export default function SummaryContainer() {
- {terms.map((item, index) => (
+ {checkoutTermsData.map((term, index) => (
-
-
{item.content}
+
handleAgreeCheck(term.id)}
+ />
+ {term.content}
))}
-
{"PLACE ORDER"}
+
+ {"PLACE ORDER"}
+
);