Skip to content

Commit

Permalink
Merge pull request #98 from GDSC-PKNU-21-22/dev
Browse files Browse the repository at this point in the history
부리미 0.12v 배포
  • Loading branch information
pp449 authored Jul 18, 2023
2 parents 2a9b3f7 + 5039479 commit 3ce2ba8
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 143 deletions.
13 changes: 11 additions & 2 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from '@emotion/styled';
import { THEME } from '@styles/ThemeProvider/theme';
import { ReactNode } from 'react';

interface ButtonProps {
Expand All @@ -18,21 +19,29 @@ const Button = ({ children, disabled = false, ...props }: ButtonProps) => {
export default Button;

const StyledButton = styled.button`
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
width: 100%;
height: 50px;
margin: 4px 0;
border-radius: 8px;
padding: 10px;
background-color: #71bc5c;
background-color: ${THEME.BUTTON.GREEN};
color: #ffffff;
font-weight: bold;
&:disabled {
background-color: #e7e7e7;
background-color: ${THEME.BUTTON.GRAY};
color: #868686;
cursor: auto;
}
& > svg {
margin-right: 5px;
}
`;
4 changes: 2 additions & 2 deletions src/components/Card/InformCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import MajorModal from '@components/Modal/MajorModal';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import useMajor from '@hooks/useMajor';
import useRoter from '@hooks/useRouter';
import useRouter from '@hooks/useRouter';
import { THEME } from '@styles/ThemeProvider/theme';
import { IconKind } from '@type/styles/icon';
import { setSize } from '@utils/styles/size';
Expand All @@ -18,7 +18,7 @@ interface InformCardProps {
const InformCard = ({ icon, title, path }: InformCardProps) => {
const { major } = useMajor();
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
const { routerTo } = useRoter();
const { routerTo } = useRouter();

const onClick = () => {
if (!major) {
Expand Down
7 changes: 3 additions & 4 deletions src/components/FooterTab/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import Icon from '@components/Icon';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import useRouter from '@hooks/useRouter';
import { THEME } from '@styles/ThemeProvider/theme';
import { IconKind } from '@type/styles/icon';
import { useNavigate } from 'react-router-dom';

const footerIcons = [
{ kind: 'map', path: '/map' },
Expand All @@ -12,10 +11,10 @@ const footerIcons = [
] as const;

const FooterTab = () => {
const navigate = useNavigate();
const { routerTo } = useRouter();

const handleIconClick = (kind: IconKind, path: string) => {
navigate(path);
routerTo(path);
};

return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Icon from '@components/Icon';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import useRoter from '@hooks/useRouter';
import useRouter from '@hooks/useRouter';
import React from 'react';

const Header = () => {
const { routerTo, goBack } = useRoter();
const { routerTo, goBack } = useRouter();
return (
<header
css={css`
Expand Down
9 changes: 5 additions & 4 deletions src/components/List/DepartmentList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ import Button from '@components/Button';
import Icon from '@components/Icon';
import styled from '@emotion/styled';
import useMajor from '@hooks/useMajor';
import useRouter from '@hooks/useRouter';
import { THEME } from '@styles/ThemeProvider/theme';
import React, { useEffect, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import { useParams } from 'react-router-dom';

const DepartmentList = () => {
const [departmentList, setDepartmentList] = useState<string[]>();
const [selected, setSelected] = useState<string>('');
const [buttonDisable, setButtonDisable] = useState<boolean>(true);
const router = useNavigate();
const { routerTo, goBack } = useRouter();
const { setMajor } = useMajor();
const { college } = useParams();

const fetchData = async () => {
const result = await http.get(`/api/majorDecision/${college}`);
if (result.data === undefined) {
router(-1);
goBack();
}
setDepartmentList(result.data);
};
Expand All @@ -34,7 +35,7 @@ const DepartmentList = () => {
localStorage.setItem('major', selected);
setMajor(selected);
alert('전공 선택 완료 !');
router('/');
routerTo('/');
};

useEffect(() => {
Expand Down
28 changes: 3 additions & 25 deletions src/components/Modal/MajorModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Button from '@components/Button';
import Icon from '@components/Icon';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { THEME } from '@styles/ThemeProvider/theme';

import Modal from '..';
Expand All @@ -14,11 +13,12 @@ interface MajorModalProps {
const MajorModal = ({ onClose, routerTo }: MajorModalProps) => {
return (
<Modal onClose={onClose}>
<ModalContent>
<>
<span
css={css`
color: ${THEME.TEXT.GRAY};
font-weight: bold;
margin: 0 auto;
margin-bottom: 15px;
`}
>
Expand All @@ -28,31 +28,9 @@ const MajorModal = ({ onClose, routerTo }: MajorModalProps) => {
<Icon kind="plus" color={THEME.TEXT.WHITE} />
<span>학과 선택하기</span>
</Button>
</ModalContent>
</>
</Modal>
);
};

export default MajorModal;

const ModalContent = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: ${THEME.TEXT.WHITE};
padding: 30px;
border-radius: 15px;
Button {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 20px;
flex: 0 0 15%;
width: 15;
}
`;
87 changes: 87 additions & 0 deletions src/components/Modal/SuggestionModal/SuggestionInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import http from '@apis/http';
import Button from '@components/Button';
import { SERVER_URL } from '@config/index';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { THEME } from '@styles/ThemeProvider/theme';
import { areaResize } from '@utils/styles/textarea-resize';
import React, { Dispatch, SetStateAction, useRef, useState } from 'react';

interface SuggestionInputProps {
setIsSended: Dispatch<SetStateAction<boolean>>;
}

const SuggestionInput = ({ setIsSended }: SuggestionInputProps) => {
const areaRef = useRef<HTMLTextAreaElement>(null);
const [isInvalid, setIsInvalid] = useState<boolean>(true);

const onChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
if (!e.currentTarget.value || e.currentTarget.value.length < 5) {
setIsInvalid(true);
return;
}
setIsInvalid(false);
};
const onResize = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
areaResize(e.currentTarget);
};

const onSuggest = async () => {
setIsSended((prev) => !prev);
await http.post(
`${SERVER_URL}/api/suggestion`,
{
content: areaRef.current?.value,
},
{
headers: {
'Content-Type': 'application/json',
},
},
);
};

return (
<>
<span
css={css`
color: ${THEME.TEXT.BLACK};
font-weight: bold;
margin-bottom: 15px;
`}
>
건의사항
</span>
<TextArea
minLength={5}
placeholder="건의사항을 5글자 이상 남겨주세요."
rows={1}
ref={areaRef}
onKeyDown={onResize}
onKeyUp={onResize}
onChange={onChange}
></TextArea>
<Button onClick={onSuggest} disabled={isInvalid}>
보내기
</Button>
</>
);
};

export default SuggestionInput;

const TextArea = styled.textarea`
line-height: 1.5;
padding: 10px;
resize: none;
overflow-y: hidden;
font-size: 16px;
font-weight: bold;
border-radius: 8px;
&::placeholder {
color: ${THEME.TEXT.GRAY};
font-weight: lighter;
}
`;
20 changes: 20 additions & 0 deletions src/components/Modal/SuggestionModal/SuggestionThxMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { css } from '@emotion/react';

const SuggestionThxMessage = () => {
return (
<>
<span
css={css`
display: flex;
justify-content: center;
line-height: 30px;
`}
>
🙇‍♂️ 건의사항을 남겨 주셔서 정말 감사드립니다! 🙇‍♂️ <br />더 좋은 서비스를
제공할 수 있도록 노력하겠습니다.
</span>
</>
);
};

export default SuggestionThxMessage;
89 changes: 9 additions & 80 deletions src/components/Modal/SuggestionModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,95 +1,24 @@
import http from '@apis/http';
import Button from '@components/Button';
import { SERVER_URL } from '@config/index';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { THEME } from '@styles/ThemeProvider/theme';
import { areaResize } from '@utils/styles/textarea-resize';
import React, { useRef, useState } from 'react';
import React, { useState } from 'react';

import SuggestionInput from './SuggestionInput';
import SuggestionThxMessage from './SuggestionThxMessage';
import Modal from '..';

interface SuggestionModalProps {
onClose: () => void;
}

const SuggestionModal = ({ onClose }: SuggestionModalProps) => {
const areaRef = useRef<HTMLTextAreaElement>(null);
const [isEmtpy, setIsEmpty] = useState<boolean>(true);

const onChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
if (e.currentTarget.value) setIsEmpty(false);
else setIsEmpty(true);
};
const onResize = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
areaResize(e.currentTarget);
};

const onSuggest = async () => {
await http.post(
`${SERVER_URL}/api/suggestion`,
{
content: areaRef.current?.value,
},
{
headers: {
'Content-Type': 'application/json',
},
},
);
};

const [isSended, setIsSended] = useState<boolean>(false);
return (
<Modal onClose={onClose}>
<ModalContent>
<span
css={css`
color: ${THEME.TEXT.BLACK};
font-weight: bold;
margin-bottom: 15px;
`}
>
건의사항
</span>
<TextArea
placeholder="건의사항을 남겨주세요."
rows={1}
ref={areaRef}
onKeyDown={onResize}
onKeyUp={onResize}
onChange={onChange}
></TextArea>
<Button onClick={onSuggest} disabled={isEmtpy}>
보내기
</Button>
</ModalContent>
{isSended ? (
<SuggestionThxMessage />
) : (
<SuggestionInput setIsSended={setIsSended} />
)}
</Modal>
);
};

export default SuggestionModal;

const ModalContent = styled.div`
display: flex;
flex-direction: column;
background-color: ${THEME.TEXT.WHITE};
padding: 30px;
border-radius: 15px;
`;

const TextArea = styled.textarea`
line-height: 1.5;
padding: 10px;
resize: none;
overflow-y: hidden;
font-size: 16px;
font-weight: bold;
border-radius: 8px;
&::placeholder {
color: ${THEME.TEXT.GRAY};
font-weight: lighter;
}
`;
Loading

0 comments on commit 3ce2ba8

Please sign in to comment.