Skip to content

Commit

Permalink
fix: build error
Browse files Browse the repository at this point in the history
  • Loading branch information
kcwww committed Apr 19, 2024
1 parent bc70ece commit 0a12506
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 51 deletions.
27 changes: 16 additions & 11 deletions front/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { useEffect, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
import { useSetRecoilState } from 'recoil';
// import { useSetRecoilState } from 'recoil';
import styled from 'styled-components';
import { axios, theme } from '@utils';
import { useNav } from '@hooks';
import { MessageListRecoil, SnowBallRecoil } from '@states';
import { theme } from '@utils';

// add axios
// import { useNav } from '@hooks';
// import { MessageListRecoil, SnowBallRecoil } from '@states';

interface MsgResponse {
user_id: number;
Expand All @@ -20,6 +22,8 @@ interface MsgResponse {
is_deleted: boolean;
opened: string;
letter_id: number;
sentiment: 'positive' | 'neutral' | 'negative'; // temp
confidence: number; // temp
}

interface DeleteModalProps {
Expand Down Expand Up @@ -112,11 +116,12 @@ const MButton = styled.button`
`;

const DeleteModal = (props: DeleteModalProps) => {
const navigate = useNav();
// const navigate = useNav();
const [isModalOpened, setIsModalOpened] = useState(false);
const modalRef = useRef<HTMLDivElement>(null);
const setMessageList = useSetRecoilState(MessageListRecoil);
const setSnowBallBox = useSetRecoilState(SnowBallRecoil);
console.log(props); // temp
// const setMessageList = useSetRecoilState(MessageListRecoil);
// const setSnowBallBox = useSetRecoilState(SnowBallRecoil);

useEffect(() => {
const closeModal = (e: MouseEvent) => {
Expand All @@ -135,10 +140,10 @@ const DeleteModal = (props: DeleteModalProps) => {
};
}, [isModalOpened]);

const deleteArrayElement = (arr: Array<MsgResponse>, index: number) => {
const newArr = arr.filter((_, idx) => idx !== index);
props.set(newArr);
};
// const deleteArrayElement = (arr: Array<MsgResponse>, index: number) => {
// const newArr = arr.filter((_, idx) => idx !== index);
// props.set(newArr);
// };

const deleteMsg = async () => {
setIsModalOpened(false);
Expand Down
6 changes: 3 additions & 3 deletions front/src/pages/Main/ListMsgs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createPortal } from 'react-dom';
import { useRecoilValue } from 'recoil';
import styled from 'styled-components';
// import { axios } from '@utils';
import { useLogout } from '@hooks';
// import { useLogout } from '@hooks';
import { SnowBallRecoil } from '@states';
import { ListMsg, Prev } from '@components';
import { MSG_COLOR } from '@constants';
Expand Down Expand Up @@ -84,9 +84,9 @@ const ToastMsg = styled.div`
`;

const ListMsgs = (props: ListMsgProps) => {
const logout = useLogout();
// const logout = useLogout();
const [messages, setMessages] = useState<Array<MsgResponse>>([]);
const [toast, setToast] = useState(false);
const [toast] = useState(false);
const { userData } = useRecoilValue(SnowBallRecoil);

useEffect(() => {
Expand Down
11 changes: 6 additions & 5 deletions front/src/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useEffect, useRef, useState } from 'react';
import { useCookies } from 'react-cookie';
// import { useCookies } from 'react-cookie';
import { createPortal } from 'react-dom';
import { useRecoilState, useSetRecoilState } from 'recoil';
import styled from 'styled-components';
import { Loading } from '@utils';
import { useLogout, useNav } from '@hooks';
import { useLogout } from '@hooks';
import { MessageListRecoil, SnowBallRecoil } from '@states';
import { Message } from '@states';
import { SnowGlobeCanvas, UIContainer } from '@components';
import Introduce from '@pages/Intro/Introduce';
//temp
Expand Down Expand Up @@ -82,9 +83,9 @@ const Main = () => {
// document.cookie = `${cookieName2}=${cookieValue2}; expires=${expire2.toUTCString()}; secure=${secure2}; path=/`;
// };

const navigate = useNav();
// const navigate = useNav();
const logout = useLogout();
const [cookie] = useCookies(['loggedin']);
// const [cookie] = useCookies(['loggedin']);

const setMessageList = useSetRecoilState(MessageListRecoil);
const [{ snowBallData }, setSnowBallBox] = useRecoilState(SnowBallRecoil);
Expand Down Expand Up @@ -132,7 +133,7 @@ const Main = () => {
const messageList = mockData.snowball_data.message_list;

setSnowBallBox(prev => ({ ...prev, snowBallData: resSnowballData }));
setMessageList(messageList);
setMessageList(messageList as Message[]);
setIsLoading(true);
};

Expand Down
2 changes: 1 addition & 1 deletion front/src/pages/Main/MenuModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRef, useState } from 'react';
import { useRecoilValue } from 'recoil';
import styled from 'styled-components';
import { useLogout, useNav } from '@hooks';
import { useNav } from '@hooks';
import { SnowBallRecoil } from '@states';

interface ModalProps {
Expand Down
51 changes: 26 additions & 25 deletions front/src/pages/Make/Snowball/MainDeco/MakeButton.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useState } from 'react';
import { useRecoilValue } from 'recoil';
// import { useRecoilValue } from 'recoil';
import styled from 'styled-components';
import { LongButton, axios } from '@utils';
import { LongButton } from '@utils';
import { useNav } from '@hooks';
import { MakeDecoRecoil } from '@states';

// import { MakeDecoRecoil } from '@states';

interface MakeButtonProps {
color: string;
Expand Down Expand Up @@ -32,32 +33,32 @@ const StyledAlert = styled.div`

const MakeButton = (props: ButtonProps) => {
const navigate = useNav();
const { snowballName, mainDecoID, mainColor, bottomID, bottomColor } =
useRecoilValue(MakeDecoRecoil);
const [alert, setAlert] = useState(false);
// const { snowballName, mainDecoID, mainColor, bottomID, bottomColor } =
// useRecoilValue(MakeDecoRecoil);
const [alert] = useState(false);

const ClickedMake = () => {
if (snowballName === '') {
setAlert(true);
return;
}
// const ClickedMake = () => {
// if (snowballName === '') {
// setAlert(true);
// return;
// }

const snowballInfo = {
title: snowballName,
main_decoration_id: mainDecoID,
main_decoration_color: mainColor,
bottom_decoration_id: bottomID,
bottom_decoration_color: bottomColor,
is_message_private: false
};
// const snowballInfo = {
// title: snowballName,
// main_decoration_id: mainDecoID,
// main_decoration_color: mainColor,
// bottom_decoration_id: bottomID,
// bottom_decoration_color: bottomColor,
// is_message_private: false
// };

axios
.post('/api/snowball', snowballInfo, { withCredentials: true })
.catch(() => navigate('/'));
// axios
// .post('/api/snowball', snowballInfo, { withCredentials: true })
// .catch(() => navigate('/'));

props.view[1](!props.view[0]);
props.visible[1](-1);
};
// props.view[1](!props.view[0]);
// props.visible[1](-1);
// };

return (
<>
Expand Down
8 changes: 4 additions & 4 deletions front/src/pages/Make/Snowball/Snowball.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEffect, useState } from 'react';
import { useCookies } from 'react-cookie';
// import { useCookies } from 'react-cookie';
import { useRecoilState } from 'recoil';
import styled from 'styled-components';
import { theme } from '@utils';
import { useLogout, useNav } from '@hooks';
import { useNav } from '@hooks';
import { SnowBallRecoil } from '@states';
import { Button, SnowGlobeCanvas } from '@components';
import { MainDeco } from './MainDeco';
Expand Down Expand Up @@ -63,10 +63,10 @@ const Home = styled.img`

const Snowball = () => {
const navigate = useNav();
const logout = useLogout();
// const logout = useLogout();
const [make, setMake] = useState(false);

const [cookie] = useCookies(['loggedin']);
// const [cookie] = useCookies(['loggedin']);
const [{ snowBallData, userData }, setSnowball] =
useRecoilState(SnowBallRecoil);

Expand Down
4 changes: 2 additions & 2 deletions front/src/router/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { BrowserRouter, Outlet, Route, Routes } from 'react-router-dom';
import { RecoilRoot } from 'recoil';

const Intro = lazy(() => import('@pages/Intro/Intro'));
const Visit = lazy(() => import('@pages/Visit/Visit'));
const Deco = lazy(() => import('@pages/Visit/Deco/Deco'));
// const Visit = lazy(() => import('@pages/Visit/Visit'));
// const Deco = lazy(() => import('@pages/Visit/Deco/Deco'));
const Nickname = lazy(() => import('@pages/Make/Nickname/Nickname'));
const Snowball = lazy(() => import('@pages/Make/Snowball/Snowball'));
const Main = lazy(() => import('@pages/Main/Main'));
Expand Down

0 comments on commit 0a12506

Please sign in to comment.