-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/#82 api magazine #94
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9ff14c9
๐ UI: ๋งค๊ฑฐ์ง ์บ๋ฆญํฐ ์ด๋ฏธ์ง ์ถ๊ฐ #82
minzee09 6815679
Merge branch 'develop' of https://github.com/UMC-Master/frontend intoโฆ
minzee09 403d783
โจ feat: ์ธ๊ธฐ ํด์ํ
๊ทธ ์ฐ๊ฒฐ #82
minzee09 0dc6c7d
โจ feat: ๋งค๊ฑฐ์ง ์์ธ ์ ๋ณด api ์ฐ๊ฒฐ #82
minzee09 08d299c
โจ feat: ์ ์ฒด ์ด๋ฏธ์ง๋ณด๊ธฐ ๋ชจ๋ฌ ์ถ๊ฐ #82
minzee09 9d4fff4
๐ bug: ์ ์ฑ
api ์ธํฐํ์ด์ค ์์ #82
minzee09 7844360
๐ bug: ํ์
์๋ฌ๋ฌ
minzee09 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import React from 'react'; | ||
| import styled from 'styled-components'; | ||
|
|
||
| interface ImageModalProps { | ||
| imageUrl: string; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| const ImageModal: React.FC<ImageModalProps> = ({ imageUrl, onClose }) => { | ||
| return ( | ||
| <Overlay onClick={onClose}> | ||
| <ModalContent> | ||
| <Image src={imageUrl} alt="ํ๋๋ ์ด๋ฏธ์ง" /> | ||
| </ModalContent> | ||
| </Overlay> | ||
| ); | ||
| }; | ||
|
|
||
| export default ImageModal; | ||
|
|
||
| const Overlay = styled.div` | ||
| position: fixed; | ||
| top: 30px; | ||
| left: 0; | ||
| width: 100%; | ||
| height: 100%; | ||
| background: rgba(0, 0, 0, 0.6); | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| z-index: 1000; | ||
| `; | ||
|
|
||
| const ModalContent = styled.div` | ||
| position: relative; | ||
| max-width: 70vh; | ||
| max-height: 70vh; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| `; | ||
|
|
||
| const Image = styled.img` | ||
| max-width: 100%; | ||
| max-height: 100%; | ||
| border-radius: 8px; | ||
| object-fit: contain; | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,87 +1,78 @@ | ||
| import { useEffect } from 'react'; | ||
| /* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
| // @ts-nocheck | ||
| import { useEffect, useState } from 'react'; | ||
| import { useParams } from 'react-router-dom'; | ||
| import styled from 'styled-components'; | ||
| import Typography from '@components/common/typography'; | ||
| import Tag from '@components/Tag/Tag'; | ||
|
|
||
| interface MagazineDetail { | ||
| id: string; | ||
| image: string; | ||
| title: string; | ||
| author: string; | ||
| date: string; | ||
| tags: string[]; | ||
| description: string; | ||
| externalLink: string; | ||
| } | ||
| const dummyDetails: MagazineDetail[] = [ | ||
| { | ||
| id: '1', | ||
| image: 'https://i.ibb.co/SXSyhmX6/image-11.png', | ||
| title: '์๋ฆฌํ ๋ณด๋๊ฐ๋ [์ฃผ๊ฑฐ์์ ] - ํ๋ฐฉ๋ฒ ์์คํ ', | ||
| author: '์์ด1์ธ๊ฐ๊ตฌ์ง์์ผํฐ', | ||
| date: '2024.12.30', | ||
| tags: ['๋ณด์', '๋์ด๊ฐ๋', 'ํ์ผ์ด'], | ||
| description: `ํ ๋ฐฉ๋ฒ ์์คํ | ||
|
|
||
| - ๋์ด๊ฐ๋๋ฒจ, ๋ชฐ์นด์์ฌ ์กด ๋ฑ 1์ธ์ธ ์ค์น | ||
| - ์ค์น๋น: ๋ฌด๋ฃ | ||
| - ์ฐ์ด์ฉ๋ฃ: 9,900์ | ||
| - ๋์: ์ธํฐ๋ท(์ ์ ) ์ค์น๊ฐ ๋์ด์๋ ์์ด๊ตฌ ๊ฑฐ์ฃผ 1์ธ๊ฐ๊ตฌ | ||
| - ๋ฌด์ธ๊ฒฝ๋น์๋น์ค ์ค์น ์ฃผํ ์ ์ฉ ๋ถ๊ฐ (์ ๊ท ์ํํธ, ์ ๊ท ์คํผ์คํ , ์ฒญ๋ ์ฃผํ ๋ฑ) | ||
|
|
||
| ๋ฌธ์: ์์ด1์ธ๊ฐ๊ตฌ์ง์์ผํฐ`, | ||
| externalLink: 'https://example.com', | ||
| }, | ||
| ]; | ||
| import { usePolicyGuide } from '@apis/queries/usePolicyQueries'; | ||
| import ImageModal from '@components/Modal/image'; | ||
|
|
||
| const MagazineDetailPage: React.FC = () => { | ||
| const { magazineId } = useParams<{ magazineId: string }>(); | ||
| const { data, isLoading } = usePolicyGuide({ policyId: Number(magazineId) }); | ||
| console.log('๋งค๊ฑฐ์ง', data); | ||
|
|
||
| const formattedDescription = data?.description | ||
| .replace(/ {5,}/g, '\n\n') // ๊ณต๋ฐฑ 5์นธ ์ด์ -> \n\n | ||
| .replace(/ {3,4}/g, '\n'); // ๊ณต๋ฐฑ 3~4์นธ -> \n | ||
|
|
||
| const [isModalOpen, setIsModalOpen] = useState(false); | ||
| const [selectedImage, setSelectedImage] = useState<string | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| window.scrollTo(0, 0); | ||
| }, []); | ||
|
|
||
| // TODO: ์ถํ API ์ฐ๋ ์, ์ค์ ๋ฐ์ดํฐ ๋ถ๋ฌ์ค๋๋ก ์์ | ||
| const detail = dummyDetails.find((item) => item.id === magazineId); | ||
| const handleImageClick = (imageUrl: string) => { | ||
| setSelectedImage(imageUrl); | ||
| setIsModalOpen(true); | ||
| }; | ||
|
|
||
| if (!detail) { | ||
| return <Container>ํด๋น ๋งค๊ฑฐ์ง์ ์ฐพ์ ์ ์์ต๋๋ค.</Container>; | ||
| if (isLoading) { | ||
| return; | ||
| } | ||
|
|
||
| return ( | ||
| <Container> | ||
| <Image src={detail.image || '/placeholder.svg'} alt={detail.title} /> | ||
| <Image | ||
| src={data?.image_url_list || '/placeholder.svg'} | ||
| alt={data?.title} | ||
| onClick={() => data?.image_url_list && handleImageClick(data?.image_url_list)} | ||
| /> | ||
| <Title> | ||
| <Typography variant="titleMedium">{detail.title}</Typography> | ||
| <Typography variant="titleMedium">{data?.title}</Typography> | ||
| </Title> | ||
| <AuthorContainer> | ||
| <div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 20 }}> | ||
| <ProfileImage /> | ||
| <ProfileImage | ||
| src={data?.organization.image || '/default-profile.png'} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ฌ์ง์ด ์์ ๋ ๊ธฐ๋ณธ ์ด๋ฏธ์ง๋ก ๋ฐ๋ก ์ ๋ฌ๋๋ ์์ ํ ๋ฐฉ๋ฒ์ด๋ค์! if๋ฌธ์ด๋ && ํํ๋ฅผ ์ฐ์ง ์๊ณ ๊ฐ๋จํ๊ฒ ๋ํ๋ผ ์ ์๋ ๋ฐฉ๋ฒ๋ ๋ฐฐ์๊ฐ๋๋ค! |
||
| alt={data?.organization.name} | ||
| hasImage={!!data?.organization.image} | ||
| /> | ||
| <Author> | ||
| <Typography variant="titleXxSmall">{detail.author}</Typography> | ||
| <Typography variant="titleXxSmall">{data?.organization.name}</Typography> | ||
| </Author> | ||
| </div> | ||
| <Date> | ||
| <Typography variant="bodySmall">{detail.date}</Typography> | ||
| <Typography variant="bodySmall">{data?.updated_at.slice(0, 10)}</Typography> | ||
| </Date> | ||
| </AuthorContainer> | ||
| <Tags> | ||
| {detail.tags.map((tag) => ( | ||
| <Tag key={tag} text={tag} selected /> | ||
| ))} | ||
| </Tags> | ||
| <Tags>{data?.hashtag?.map((tag) => <Tag key={tag.id} text={tag.name} selected />) ?? []}</Tags> | ||
| <Description> | ||
| <Typography variant="bodySmall">{detail.description}</Typography> | ||
| <Typography variant="bodySmall">{formattedDescription}</Typography> | ||
| </Description> | ||
| <Line /> | ||
| <Button href={detail.externalLink} target="_blank" rel="noopener noreferrer"> | ||
| <Button href={data?.policy_url} target="_blank" rel="noopener noreferrer"> | ||
| <Typography variant="titleXSmall">ํด๋น ํ์ด์ง๋ก ์ด๋ํ๊ธฐ</Typography> | ||
| </Button> | ||
| {isModalOpen && selectedImage && <ImageModal imageUrl={selectedImage} onClose={() => setIsModalOpen(false)} />} | ||
| </Container> | ||
| ); | ||
| }; | ||
|
|
||
| export default MagazineDetailPage; | ||
|
|
||
| const Container = styled.div` | ||
| max-width: 1280px; | ||
| margin: 0 auto; | ||
|
|
@@ -90,10 +81,11 @@ const Container = styled.div` | |
|
|
||
| const Image = styled.img` | ||
| width: 100%; | ||
| height: 200px; | ||
| height: 400px; | ||
| object-fit: cover; | ||
| border-radius: 20px; | ||
| margin-bottom: 32px; | ||
| cursor: pointer; | ||
| `; | ||
|
|
||
| const Title = styled.div` | ||
|
|
@@ -110,11 +102,13 @@ const AuthorContainer = styled.div` | |
| margin-bottom: 32px; | ||
| `; | ||
|
|
||
| const ProfileImage = styled.div` | ||
| const ProfileImage = styled.img<{ hasImage: boolean }>` | ||
| width: 60px; | ||
| height: 60px; | ||
| border-radius: 50%; | ||
| background-color: ${({ theme }) => theme.colors.text.lightGray}; | ||
| object-fit: cover; | ||
| background-color: ${({ hasImage, theme }) => (hasImage ? theme.colors.text.white : theme.colors.text.lightGray)}; | ||
| box-shadow: ${({ hasImage }) => (hasImage ? '0px 4px 10px rgba(0, 0, 0, 0.15)' : 'none')}; | ||
| `; | ||
|
|
||
| const Author = styled.div` | ||
|
|
@@ -162,5 +156,3 @@ const Button = styled.a` | |
| background-color: ${({ theme }) => theme.colors.primary[600]}; | ||
| } | ||
| `; | ||
|
|
||
| export default MagazineDetailPage; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ด๊ฑด ์๋ ์ค๋ฐ๊ฟ์ธ ์ ์ธ๊ฐ์?