Skip to content

Commit

Permalink
chore: 스티커팩 모달 위치 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
eunbeann committed Jan 18, 2024
1 parent e6c1749 commit 8e5d30d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
25 changes: 23 additions & 2 deletions src/Detail/components/LecueNoteListContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
BtnFloatingWrite,
BtnFloatingWriteOrange,
} from '../../../assets';
import CommonModal from '../../../components/common/Modal/CommonModal';
import usePostStickerState from '../../../StickerAttach/hooks/usePostStickerState';
import { NoteType, postedStickerType } from '../../type/lecueBookType';
import AlertBanner from '../AlretBanner';
Expand Down Expand Up @@ -52,6 +53,7 @@ function LecueNoteListContainer(props: LecueNoteListContainerProps) {
//state
const [fullHeight, setFullHeight] = useState<number | null>(null);
const [heightFromBottom, setHeightFromBottom] = useState<number | null>(null);
const [modalOn, setModalOn] = useState<boolean>(false);
const [isZigZagView, setIsZigZagView] = useState<boolean>(true);
const [stickerState, setStickerState] = useState<postedStickerType>({
postedStickerId: 0,
Expand All @@ -72,9 +74,20 @@ function LecueNoteListContainer(props: LecueNoteListContainerProps) {
};

const handleClickStickerButton = () => {
sessionStorage.setItem('scrollPosition', window.scrollY.toString());
if (
localStorage.getItem('token') &&
localStorage.getItem('token') !== null
) {
sessionStorage.setItem('scrollPosition', window.scrollY.toString());

navigate('/sticker-pack', { state: { bookId: bookId } });
navigate('/sticker-pack', { state: { bookId: bookId } });
} else {
setModalOn(true);
}
};

const handleClickModalBtn = () => {
navigate(`/login`);
};

const handleClickWriteButton = () => {
Expand Down Expand Up @@ -177,6 +190,14 @@ function LecueNoteListContainer(props: LecueNoteListContainerProps) {
)}

{isEditable && <AlertBanner onClick={handleClickDone} />}

{modalOn && (
<CommonModal
category="login"
setModalOn={setModalOn}
handleFn={handleClickModalBtn}
/>
)}
</S.LecueNoteListContainerWrapper>
);
}
Expand Down
21 changes: 1 addition & 20 deletions src/StickerPack/page/StickerPack/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useEffect, useState } from 'react';
import { useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';

// component
import Button from '../../../components/common/Button/index.tsx';
import Header from '../../../components/common/Header/index.tsx';
import LoadingPage from '../../../components/common/LoadingPage/index.tsx';
import CommonModal from '../../../components/common/Modal/CommonModal.tsx';
import StickerList from '../../components/StickerList/index.tsx';
import useGetBookUuid from '../../hooks/useGetBookUuid.ts';
import useGetStickerPack from '../../hooks/useGetStickerPack.ts';
Expand All @@ -17,16 +16,9 @@ import * as S from './StickerPack.style.ts';
function StickerPack() {
const navigate = useNavigate();
const location = useLocation();
const [modalOn, setModalOn] = useState(false);

const { bookId } = location.state;

useEffect(() => {
if (!localStorage.getItem('token')) {
setModalOn(true);
}
}, []);

const [selectedStickerData, setSelectedStickerData] = useState<stickerType>({
stickerId: 0,
stickerImage: '',
Expand All @@ -49,10 +41,6 @@ function StickerPack() {
});
};

const handleClickModalBtn = () => {
navigate(`/login`);
};

return isLoading ? (
<LoadingPage />
) : (
Expand All @@ -74,13 +62,6 @@ function StickerPack() {
선택 완료
</Button>
</S.ButtonWrapper>
{modalOn && (
<CommonModal
category="login"
setModalOn={setModalOn}
handleFn={handleClickModalBtn}
/>
)}
</S.Wrapper>
);
}
Expand Down

0 comments on commit 8e5d30d

Please sign in to comment.