React

[TIL/React] 2023/10/05

λ°˜μ‘ν˜• 🟒px(ν”½μ…€)κ³Ό 같은 κ³ μ • λ‹¨μœ„λ₯Ό μ“°λ©΄ μœ„μ™€ 같이 μ²˜μ°Έν•œ κ²°κ³Όλ₯Ό 얻을 수 μžˆλ‹€. μ½”λ“œλ₯Ό μˆ˜μ •ν–ˆλ‹€.μˆ˜μ • ν›„ λͺ¨μŠ΅ πŸŸ’μ½”λ“œμ— λŒ€ν•œ μ„€λͺ…이 ν•„μš”ν•œλ°, μ˜€λŠ˜μ€ λ„μ €νžˆ 힘이 λ‚˜μ§€ μ•ŠλŠ”λ‹€. handleDirectClick ν•¨μˆ˜λ₯Ό 톡해, 둜그인이 λ˜μ–΄ μžˆμ§€ μ•Šλ‹€λ©΄ logi

2023λ…„ 10μ›” 5일2min read

λ°˜μ‘ν˜• 🟒

px(ν”½μ…€)κ³Ό 같은 κ³ μ • λ‹¨μœ„λ₯Ό μ“°λ©΄ μœ„μ™€ 같이 μ²˜μ°Έν•œ κ²°κ³Όλ₯Ό 얻을 수 μžˆλ‹€. μ½”λ“œλ₯Ό μˆ˜μ •ν–ˆλ‹€.

code
import React from "react";
import { useParams, useLocation, useNavigate } from "react-router-dom";
import styled from "@emotion/styled";
import { shoppingData } from "../data/ShoppingCategory_Pork";
import ComponentWrapper from "../components/common/ComponentWrapper";
import { useSelector } from "react-redux";

const ProductDetailPageBackgroundStyle = styled.div`
  background-color: #181818;
  width: 100%;
  /* height: 100vh; */
`;

const AllContentWrapper = styled.div`
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  /* flex-grow: 1; */
  /* background-color: white; */
  @media (max-width: 900px) {
    flex-wrap: wrap;
    column-gap: 20px;
  }
`;

const ProductDetailPageImgWrapper = styled.div`
  /* height: 70%;
  width: 50%; */
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: white;
`;

const ProductImg = styled.img`
  width: 80%;
  height: 80%;
`;

const ProductDetailPageInfoWrapper = styled.div`
  /* width: 50%;
  height: 70%; */
  display: flex;
  flex-direction: column;
  background-color: blue;
`;

const ProductDetailPageInfoDataWrapper = styled.div`
  height: 30%;
`;

const InfoDataTitle = styled.p`
  font-size: 30px;
  color: white;
  font-weight: bolder;
`;

const InfoDataEtc = styled.p`
  font-size: 20px;
  color: white;
  font-weight: bolder;
`;

const OptionWrapper = styled.div`
  display: flex;
  align-items: center;
  column-gap: 20px;
  height: 20%;
  color: white;
`;

const AmountWrapper = styled.div`
  display: flex;
  align-items: center;
  column-gap: 20px;
  height: 20%;
  color: white;
`;

const ButtonWrapper = styled.div`
  width: 100%;
  background-color: orange;
  display: flex;
  height: 30%;
  justify-content: space-evenly;
  align-items: center;
`;

const ProductDetailPage = () => {
  const navigate = useNavigate();
  const { id } = useParams();
  const location = useLocation();
  const category = location?.state;
  const check = useSelector((state) => state.auth);
  console.log(check);

  const handleDirectClick = () => {
    if (check.isAuthenticated) {
      console.log("κ²°μ œν™”λ©΄μœΌλ‘œ");
    } else {
      navigate("/login");
    }
  };

  const MapData = shoppingData[category];
  const DetailData = MapData.find((elem) => elem?.id === id);
  const ImgSrc = DetailData.image;

  console.log(location);
  console.log(DetailData);
  console.log(ImgSrc);

  return (
    <>
      <ProductDetailPageBackgroundStyle>
        {/*  */}
        <ComponentWrapper style={{ height: "100%" }}>
          <AllContentWrapper>
            {/* image area */}
            <ProductDetailPageImgWrapper>
              <ProductImg src={ImgSrc} />
            </ProductDetailPageImgWrapper>
            {/* info area */}
            <ProductDetailPageInfoWrapper>
              <ProductDetailPageInfoDataWrapper>
                <InfoDataTitle>{DetailData?.subtitle}</InfoDataTitle>
                <InfoDataEtc>
                  {DetailData?.price} ({DetailData?.weight})
                </InfoDataEtc>
                <p></p>
              </ProductDetailPageInfoDataWrapper>

              <OptionWrapper>
                <span style={{ color: "white", fontWeight: "bolder" }}>
                  μ˜΅μ…˜
                </span>
                <div style={{ border: "2px solid orange" }}>
                  fdsagfagfdagfdgfda
                </div>
              </OptionWrapper>
              <AmountWrapper>
                <span style={{ color: "white", fontWeight: "bolder" }}>
                  μˆ˜λŸ‰
                </span>
                <div style={{ border: "2px solid orange" }}>
                  fdsagfagfdagfdgfda
                </div>
              </AmountWrapper>

              <ButtonWrapper>
                <button
                  style={{
                    backgroundColor: "#7f7776",
                    color: "white",
                    width: "200px",
                    height: "60px",
                    border: "none",
                  }}
                  onClick={handleDirectClick}
                >
                  λ°”λ‘œκ΅¬λ§€
                </button>
                <button
                  style={{
                    backgroundColor: "#c50f22",
                    color: "white",
                    width: "200px",
                    height: "60px",
                    border: "none",
                  }}
                >
                  μž₯λ°”κ΅¬λ‹ˆ
                </button>
              </ButtonWrapper>
            </ProductDetailPageInfoWrapper>
          </AllContentWrapper>
        </ComponentWrapper>
      </ProductDetailPageBackgroundStyle>
    </>
  );
};

export default ProductDetailPage;

μˆ˜μ • ν›„ λͺ¨μŠ΅ 🟒

μ½”λ“œμ— λŒ€ν•œ μ„€λͺ…이 ν•„μš”ν•œλ°, μ˜€λŠ˜μ€ λ„μ €νžˆ 힘이 λ‚˜μ§€ μ•ŠλŠ”λ‹€. handleDirectClick ν•¨μˆ˜λ₯Ό 톡해, 둜그인이 λ˜μ–΄ μžˆμ§€ μ•Šλ‹€λ©΄ login page둜 μ΄λ™ν•˜λ„λ‘ μ„€μ •ν–ˆλ‹€.

회고 🟒

1) μƒλŒ€μ μΈ λ‹¨μœ„λ₯Ό 써야 봉변을 λ©΄ν•  수 μžˆλ‹€λŠ” 점을 κΉ¨λ‹¬μ•˜λ‹€. 2) 1λ²ˆμ€ 사싀 이미 μ•Œκ³  μžˆμ—ˆλŠ”λ°, container λ‹¨μœ„λ‘œ μƒλŒ€ λ‹¨μœ„λ₯Ό 써야 함을 λ‹€μ‹œκΈˆ κΉ¨λ‹¬μ•˜λ‹€. 3) λ¬Έμ œλŠ” 2λ²ˆμ—μ„œ λŠλ‚€ 점이 λ§žλŠ” 것인지 μ˜λ¬Έμ΄λ‹€. 4) κ·Έλž˜λ„ λŒ€κ°• ꡬ쑰λ₯Ό μž‘μ•˜μœΌλ‹ˆ, μž₯λ°”κ΅¬λ‹ˆλ₯Ό 슬슬 λ§Œλ“€λ„λ‘ ν•˜μž.

More to read

Amazon VPC

Amazon VPC Architecture μ΄ν•΄ν•˜κΈ°

μƒˆλ‘œμš΄ ν”„λ‘œμ νŠΈλ₯Ό κΈ°νšν•˜λ©°, κ°œλ°œμ—μ„œ 무엇을 κ°€μž₯ λ¨Όμ € κ³ λ―Όν•΄μ•Ό ν•˜λŠ”μ§€ λ‹€μ‹œ λŒμ•„λ³΄κ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.ν•œλ•ŒλŠ” ν”„λ‘ νŠΈμ—”λ“œκ°€ λͺ¨λ“  μ„€κ³„μ˜ 좜발점이라고 λ―Ώμ—ˆμŠ΅λ‹ˆλ‹€. μœ μ €κ°€ 무엇을 보고, μ–΄λ–€ νλ¦„μ—μ„œ 머무λ₯΄κ³  μ΄νƒˆν•˜λŠ”μ§€μ— λŒ€ν•œ 이해 없이 μ„œλΉ„μŠ€λ₯Ό λ§Œλ“ λ‹€λŠ” 건 λΆˆκ°€λŠ₯ν•˜λ‹€κ³  μƒκ°ν–ˆκΈ°

'μ›μ‚¬μ΄νŠΈ'

ν”„λ‘ νŠΈμ—”λ“œ κ΄€μ μœΌλ‘œ μ•Œκ³ λ¦¬μ¦˜ μ΄ν•΄ν•˜κΈ°

μ˜€λžœλ§Œμ— 방법둠에 κ΄€ν•œ 글을 μ“°κ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€. 졜근 상황은 μ΄λ ‡μŠ΅λ‹ˆλ‹€. SSAFYμ—μ„œλŠ” ν•˜λ£¨μ— μ—„μ²­λ‚œ μ–‘μ˜ μ•Œκ³ λ¦¬μ¦˜ λ¬Έμ œλ“€μ„ 과제둜 μˆ˜ν–‰ν•˜κ²Œ λ©λ‹ˆλ‹€. κ·Έ κ³Όμ •μ—μ„œ, 'κ΅¬ν˜„λ ₯'이 맀우 λ–¨μ–΄μ§„λ‹€λŠ” 생각이 λ“€μ—ˆμŠ΅λ‹ˆλ‹€. μ™„μ „νžˆ μ–΄λ €μš΄ 문제라면 '아쉬움'μ΄λΌλŠ” 감정쑰차 λŠλΌμ§€

Subnet

VPC μ„€κ³„μ˜ μ‹œμž‘: IP와 Subnet

λ°˜λ³΅λ˜λŠ” 루틴 μ†μ—μ„œ 얻은 μ•ˆμ •κ°μ„ 발판 μ‚Όμ•„, μ΄μ œλŠ” 기술적 μŠ€νŽ™νŠΈλŸΌμ„ λ„“νžˆκΈ° μœ„ν•œ 개인 ν”„λ‘œμ νŠΈμ— μ°©μˆ˜ν•˜κ³ μž ν•©λ‹ˆλ‹€.이번 ν”„λ‘œμ νŠΈμ˜ λͺ©ν‘œλŠ” λ‹¨μˆœν•œ 포트폴리였 ꡬ좕을 λ„˜μ–΄, μ‹€μ œ μ„œλΉ„μŠ€ μˆ˜μ€€μ˜ λΈ”λ‘œκ·Έ μ‹œμŠ€ν…œ κ΅¬ν˜„κ³Ό λ‹€κ΅­μ–΄ 처리 적용 λ“± 싀무에 κ°€κΉŒμš΄ μ—­λŸ‰μ„ ν•œ 단계