Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge: QA1차수정사항 반영 배포 #72

Merged
merged 23 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
54eee12
💄 Design: 프로필 아이콘 포인터 추가
jisooooooooooo Jul 24, 2024
e6e3edc
✨ Feat: 로고 경로 추가
jisooooooooooo Jul 24, 2024
d37f2ab
✨ Feat: 아티클 로딩 제거
jisooooooooooo Jul 24, 2024
bf5cb95
Merge pull request #66 from olmangjolmang/OMJM-72-f-아티클-상세-페이지
jisooooooooooo Jul 24, 2024
e8d787e
✨ Feat: 검색어 없을 때 alert추가, 엔터로 검색 되도록 수정
yeonnybus Jul 24, 2024
1ed0ccd
💄 Design: 퀴즈 디자인 수정
jisooooooooooo Jul 24, 2024
7a1bb68
Merge pull request #67 from olmangjolmang/OMJM-71-f-퀴즈
jisooooooooooo Jul 24, 2024
95b9c46
✨ Feat: 스타일 코드 분리
jisooooooooooo Jul 24, 2024
ff61d83
✨ Feat: 아티클 없을 때 별도 메시지 출력
yeonnybus Jul 24, 2024
7be86ac
💄 Design: 인풋 스타일 수정
jisooooooooooo Jul 24, 2024
b6da341
🐛 Fix: API 수정
yeonnybus Jul 24, 2024
ca30298
Merge pull request #68 from olmangjolmang/OMJM-72-f-아티클-상세-페이지
jisooooooooooo Jul 24, 2024
e6478c7
✨ Fix: 작성자와 작성 날짜 사이 바 추가
yeonnybus Jul 24, 2024
57f1c1a
Merge pull request #69 from olmangjolmang/OMJM-84-헤더
jisooooooooooo Jul 24, 2024
94a62a0
✨ Feat: 구독하기 API 추가
yeonnybus Jul 24, 2024
98ba32f
🐛 Fix: 버튼 색상 변경 조건 수정
yeonnybus Jul 24, 2024
61a9873
🐛 Fix: 헤더 갭 수정
yeonnybus Jul 24, 2024
c32aa42
🐛 Fix: 배너 배경 잘림 수정
yeonnybus Jul 24, 2024
a3e1234
🐛 Fix: 메인 페이지(홈) 관련 타입 수정(postId추가)
yeonnybus Jul 24, 2024
fec280f
✨ Feat: posdId추가에 따른 네비게이션 추가
yeonnybus Jul 24, 2024
f800dc0
🐛 Fix: length에러 임시 수정
jisooooooooooo Jul 24, 2024
97d24cc
Merge pull request #70 from olmangjolmang/OMJM-72-f-아티클-상세-페이지
jisooooooooooo Jul 24, 2024
71bf88d
Merge pull request #71 from olmangjolmang/OMJM-120-1stQA
yeonnybus Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/components/Boards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CategorySelector from "./CategorySelector";
import Pagination from "./Pagination";
import Select from "./Select";
import { Category, OrderBy, CATEGORY_LABELS } from "../types/ArticleBoards";
import { Container, GridContainer } from "../styles/ArticleBoards";
import { Container, GridContainer, NoContent } from "../styles/ArticleBoards";
import { Option } from "../types/ArticleBoards";

const orderByOptions: Option[] = [
Expand Down Expand Up @@ -56,6 +56,7 @@ const Boards = () => {

if (isLoading) return <div>아티클을 불러오는 중입니다.</div>;
if (isError) return <div>잘못된 접근입니다.</div>;

console.log(data);
return (
<Container>
Expand All @@ -73,16 +74,20 @@ const Boards = () => {
options={orderByOptions}
/>
</div>
<GridContainer>
{data &&
data.results.content.map((article: any) => (
<PostItemMain
key={article.postId}
{...article}
postCategory={CATEGORY_LABELS[article.postCategory as Category]}
/>
))}
</GridContainer>
{data && data.results.empty === true ? (
<NoContent>조건에 맞는 아티클이 없습니다.</NoContent>
) : (
<GridContainer>
{data &&
data.results.content.map((article: any) => (
<PostItemMain
key={article.postId}
{...article}
postCategory={CATEGORY_LABELS[article.postCategory as Category]}
/>
))}
</GridContainer>
)}
<Pagination
currentPage={page}
totalPages={data.results.totalPages}
Expand Down
88 changes: 9 additions & 79 deletions src/components/HighlightModal.tsx
Original file line number Diff line number Diff line change
@@ -1,85 +1,15 @@
import React, { useState } from "react";
import styled from "styled-components";
import ConfirmationModal from "./ConfirmationModal";
import StopConfirmationModal from "./StopConfirmationModal";

const ModalOverlay = styled.div`
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 999;
`;

const ModalContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
padding: 72px 112px;
width: 800px;
height: 600px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
position: relative;
`;

const ModalHeader = styled.div`
font-size: 24px;
font-weight: bold;
margin-bottom: 40px;
align-self: flex-start;
`;

const HighlightedTextContainer = styled.div`
width: 100%;
padding: 10px;
color: #272726;
margin-bottom: 40px;
font-size: 18px;
white-space: pre-wrap;
`;

const TextArea = styled.textarea`
width: 93%;
height: 570px;
padding: 30px;
background-color: #f4f4f7;
border-radius: 20px;
border: none;
resize: none;
font-size: 16px;
color: #afafb6;
font-weight: 500;
`;

const Button = styled.button`
margin-top: 32px;
width: 90.75px;
padding: 7.5px;
background-color: #463efb;
color: white;
border: none;
border-radius: 10px;
cursor: pointer;
align-self: flex-end;
`;

const CloseButton = styled.button`
position: absolute;
top: 60px;
right: 90px;
width: 15px;
height: 15px;
background: none;
border: none;
cursor: pointer;
`;
import {
ModalOverlay,
ModalContainer,
ModalHeader,
HighlightedTextContainer,
TextArea,
Button,
CloseButton,
} from "../styles/HighlightModal";

interface HighlightModalProps {
highlightedText: string;
Expand Down
2 changes: 2 additions & 0 deletions src/components/PostItemGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import styled from "styled-components";
import { Category, CATEGORY_LABELS } from "../types/ArticleBoards";

interface ResponseItem {
postId: number;
title: string;
imageUrl: string;
category: string;
Expand Down Expand Up @@ -85,6 +86,7 @@ const PostItemGroup = ({ topic, responseList }: Result) => {
<Slider {...settings}>
{responseList.map((post) => (
<PostItemHome
postId={post.postId}
imageUrl={post.imageUrl}
category={CATEGORY_LABELS[post.category as Category]}
title={post.title}
Expand Down
17 changes: 13 additions & 4 deletions src/components/PostItemHome.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState } from "react";
import { useNavigate, useLocation } from "react-router-dom";
import styled from "@emotion/styled";
import { css } from "@emotion/react";
import { ReactComponent as SaveIcon } from "../assets/saveIcon.svg";
import axiosInstance from "../api/AxiosInstance";

// 게시물 정보를 나타내는 타입 정의
interface ResponseItem {
postId: number;
title: string;
imageUrl: string;
category: string;
Expand All @@ -14,21 +14,30 @@ interface ResponseItem {
}

const PostItemHome = ({
postId,
title,
imageUrl,
category,
author,
createdDate,
}: ResponseItem) => {
const navigate = useNavigate();
const location = useLocation();

const handleNavigate = () => {
navigate(`/post/${postId}`, {
state: { from: location.pathname + location.search },
});
};
return (
<Container>
<Container onClick={handleNavigate}>
<Image src={imageUrl} alt="미리보기 이미지" />
<CategoryRow>
<Category>{category}</Category>
</CategoryRow>
<Title>{title}</Title>
<Author>
{author} {createdDate}
{author} | {createdDate}
</Author>
</Container>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/PostItemMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const PostItemMain: React.FC<PostItemProps> = ({
<Title>{title}</Title>
{content && <Summary>{content}</Summary>}
<Author hasSummary={!!content}>
{author} {createdDate}
{author} | {createdDate}
</Author>
</Container>
);
Expand Down
56 changes: 44 additions & 12 deletions src/components/SubscriptionModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from "react";
import { useState } from "react";
import React, { useState, useEffect } from "react";
import {
ModalOverlay,
ModalContent,
Expand All @@ -20,6 +19,8 @@ import {
Span,
} from "../styles/MainPage";
import styled from "styled-components";
import axiosInstance from "../api/AxiosInstance";

interface SubscribtionModalProps {
isOpen: boolean;
onClose: () => void;
Expand Down Expand Up @@ -87,6 +88,29 @@ const CloseIcon = () => (
const SubscribtionModal = ({ isOpen, onClose }: SubscribtionModalProps) => {
const [isRequiredChecked, setIsRequiredChecked] = useState<boolean>(false);
const [isOptionalChecked, setIsOptionalChecked] = useState<boolean>(false);
const [selectedDay, setSelectedDay] = useState<string>("");

const isSubmitEnabled = selectedDay !== "" && isRequiredChecked;

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!isSubmitEnabled) return;

const params = {
subsDay: selectedDay,
agreeInfo: isRequiredChecked,
agreeMarketing: isOptionalChecked,
};

try {
const response = await axiosInstance.post("/home/subscription", params);
console.log("Subscription successful:", response.data);

onClose();
} catch (error) {
console.error("Subscription failed:", error);
}
};

return (
<ModalOverlay isOpen={isOpen}>
Expand All @@ -109,17 +133,20 @@ const SubscribtionModal = ({ isOpen, onClose }: SubscribtionModalProps) => {
<Form>
<FormGroup>
<Label>요일</Label>
<Select defaultValue="">
<option value="" disabled hidden selected>
<Select
value={selectedDay}
onChange={(e) => setSelectedDay(e.target.value)}
>
<option value="" disabled hidden>
아티클을 받을 요일을 선택해주세요.
</option>
<option value="monday">월요일</option>
<option value="tuesday">화요일</option>
<option value="wednesday">수요일</option>
<option value="thursday">목요일</option>
<option value="friday">금요일</option>
<option value="saturday">토요일</option>
<option value="sunday">일요일</option>
<option value="MONDAY">월요일</option>
<option value="TUESDAY">화요일</option>
<option value="WEDNESDAY">수요일</option>
<option value="THURSDAY">목요일</option>
<option value="FRIDAY">금요일</option>
<option value="SATURDAY">토요일</option>
<option value="SUNDAY">일요일</option>
{/* 요일 옵션 추가 */}
</Select>
</FormGroup>
Expand Down Expand Up @@ -147,7 +174,12 @@ const SubscribtionModal = ({ isOpen, onClose }: SubscribtionModalProps) => {
<Link href="#">약관 상세보기</Link>
</CheckboxLabel>
</CheckboxGroup>
<SubmitButton type="submit">구독하기</SubmitButton>
<SubmitButton
isSubmitEnabled={isSubmitEnabled}
onClick={handleSubmit}
>
구독하기
</SubmitButton>
</Form>
</ModalContent>
</ModalOverlay>
Expand Down
4 changes: 2 additions & 2 deletions src/components/TicleNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const TicleNote = ({
setIsEditing(false);
// Replace with your question ID
try {
await axiosInstance.put(`/mypage/my-note/${postId}`, {
await axiosInstance.put(`/mypage/my-note/${noteId}`, {
content: answer,
});
// Optionally handle the response or refresh data
Expand All @@ -49,7 +49,7 @@ const TicleNote = ({
// Replace with your question ID

try {
await axiosInstance.delete(`/mypage/my-note/${postId}`);
await axiosInstance.delete(`/mypage/my-note/${noteId}`);
// Optionally handle the response or refresh data
alert("삭제되었습니다.");
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useHomeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useQuery } from "@tanstack/react-query";
import axiosInstance from "../api/AxiosInstance";

interface ResponseItem {
postId: number;
title: string;
imageUrl: string;
category: string;
Expand Down
Loading
Loading