Skip to content

Commit

Permalink
Merge pull request #201 from EasyAndBeauty/feature/#189
Browse files Browse the repository at this point in the history
Feature#189:핀버튼과 영수증 정보 연결로직 추가
  • Loading branch information
mdgarden authored Nov 23, 2022
2 parents c65a293 + 0b9813f commit c437209
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/components/atoms/ReceiptPageBtns/PinBtn.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { ReactComponent as PinIcon } from "assets/svg/pin_icon.svg";
import { useState } from "react";
import { useEffect, useState } from "react";
import styled from "styled-components";

export function PinBtn() {
export function PinBtn({ isPinned }) {
const [pinned, setPinned] = useState(false);

useEffect(() => {
if (isPinned) setPinned(true);
}, [isPinned]);

function handlePin() {
// todo: 서버로 pin 데이터 보내는 기능 추가
console.log("pinned", !pinned);
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/MySection/MySection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const MySection = () => {
<S.CreatedDate>{receipt.date && formatReceiptDate(receipt.date)}</S.CreatedDate>
<ReceiptPaper
onClick={() => {
navigate(`/receipt`, { state: { todos: receipt.todos } });
navigate(`/receipt`, { state: { todos: receipt.todos, pinned: receipt.pinned } });
}}
todos={Array.from(receipt.todos)}
key={receipt.id}
Expand Down
4 changes: 2 additions & 2 deletions src/components/pages/ReceiptPage/ReceiptPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as S from "./ReceiptPage.styles";

export function ReceiptPage() {
const {
state: { todos, date, receiptNumber },
state: { todos, pinned, date, receiptNumber },
} = useLocation();
const navigate = useNavigate();
const receiptRef = useRef(null);
Expand Down Expand Up @@ -34,7 +34,7 @@ export function ReceiptPage() {
<S.IconContainer>
<CopyBtn />
<SaveBtn date={date} />
<PinBtn />
<PinBtn isPinned={pinned} />
</S.IconContainer>
{modalOn && <AlertModal onClick={() => setModalOn(false)} />}
</S.Container>
Expand Down

0 comments on commit c437209

Please sign in to comment.