From 17ff970598b72cc05329e69295fa1f3f7269c156 Mon Sep 17 00:00:00 2001 From: tyoung Date: Wed, 22 Feb 2023 10:24:01 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=94=A8Fix:=20=EC=BD=94=EB=A9=98?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=F0=9F=92=84=20Design:=20=EB=94=94=EC=9E=90=EC=9D=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=B4=20CSS?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20#23?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/post-list/Comment/Comment.tsx | 7 +- components/post-list/Comment/CommentList.tsx | 124 +++++++++++------- components/post-list/Comment/CommentWrite.tsx | 64 ++++++--- 3 files changed, 122 insertions(+), 73 deletions(-) diff --git a/components/post-list/Comment/Comment.tsx b/components/post-list/Comment/Comment.tsx index f4be08c..199675c 100644 --- a/components/post-list/Comment/Comment.tsx +++ b/components/post-list/Comment/Comment.tsx @@ -12,7 +12,7 @@ export default function Comment({ path }: any) { useEffect(() => { const collectionRef = collection(dbService, path); - const q = query(collectionRef, orderBy('timestamp', 'asc')); + const q = query(collectionRef, orderBy('createdAt', 'desc')); onSnapshot(q, (snapshot: any) => setComments( @@ -25,10 +25,10 @@ export default function Comment({ path }: any) {

댓글

{comments?.length}개의 댓글이 작성되었어요

+ {comments?.map((comment: any) => { return ; })} -
); } @@ -39,8 +39,11 @@ const CommentLayout = styled.div` .title { font-size: 1.25rem; + font-weight: 700; } .description { margin: 0.75rem 0 1.125rem; + font-size: 0.75rem; + color: #868e96; } `; diff --git a/components/post-list/Comment/CommentList.tsx b/components/post-list/Comment/CommentList.tsx index 76b59cd..ae1120e 100644 --- a/components/post-list/Comment/CommentList.tsx +++ b/components/post-list/Comment/CommentList.tsx @@ -7,7 +7,9 @@ import styled from 'styled-components'; type Props = {}; export default function CommentList({ comment, path }) { - const { userProfile, userNickName, createdAt, commentText, id } = comment; + console.log(comment); + const { userProfile, userNickName, createdAt, commentText, id, userId } = + comment; const [edit, setEdit] = useState({ active: false, editText: commentText, @@ -51,47 +53,54 @@ export default function CommentList({ comment, path }) { updateDoc(docRef, payload); }; + console.log(auth.currentUser?.uid); + return ( + + +

{userNickName}

{nowDate}

- - - {!active ? ( -

{commentText}

- ) : ( - //
- setEdit({ ...edit, editText: e.target.value })} - /> - )} - {/* {auth.currentUser && ( */} -
- editComment(id)} - > - 수정 - - deleteComment(id)} - > - 삭제 - +
+ {!active ? ( +

{commentText}

+ ) : ( + //
+ setEdit({ ...edit, editText: e.target.value })} + /> + )}
- {/* )} */} - + + + {auth.currentUser?.uid === userId ? ( + <> + editComment(id)} + > + 수정 + + deleteComment(id)} + > + 삭제 + + + ) : null} + ); } @@ -103,6 +112,7 @@ const CommentListLayout = styled.div` width: 100%; border-radius: 0.5rem; margin-bottom: 1.25rem; + padding: 0.125rem; &:hover { background: #f1f3f5; @@ -112,36 +122,41 @@ const CommentListLayout = styled.div` export const WriteInformationDiv = styled.div` display: flex; align-items: center; - - .userInformation { - .nickName { - margin-bottom: 0.125rem; - font-size: 0.875rem; - font-weight: 700; - } - - .date { - font-size: 0.75rem; - } - } + flex-direction: column; `; export const ProfileImg = styled.img` width: 40px; height: 40px; - margin-right: 0.625rem; + border-radius: 100%; object-fit: cover; `; -const CommentText = styled.div` +const CommentTextDiv = styled.div` display: flex; justify-content: space-between; - width: 100%; + flex-direction: column; + width: calc(100% - 10rem); + .userInformation { + display: flex; + align-items: center; + + .nickName { + margin-bottom: 0.125rem; + font-size: 0.875rem; + font-weight: 700; + } + + .date { + margin-left: 0.625rem; + font-size: 0.75rem; + color: #868e96; + } + } .commenText { overflow-wrap: anywhere; - } .editInput { @@ -154,8 +169,15 @@ const CommentText = styled.div` font-size: 0.875rem; } - .commentModify { + .comment-list { + width: 100%; display: flex; - font-size: 0.75rem; + margin-top: 0.375rem; + justify-content: space-between; } `; + +const CommentModify = styled.div` + display: flex; + gap: 10px; +`; diff --git a/components/post-list/Comment/CommentWrite.tsx b/components/post-list/Comment/CommentWrite.tsx index 9f7e8c8..8a04442 100644 --- a/components/post-list/Comment/CommentWrite.tsx +++ b/components/post-list/Comment/CommentWrite.tsx @@ -4,13 +4,17 @@ import { addDoc, collection, serverTimestamp } from 'firebase/firestore'; import React, { useState } from 'react'; import styled from 'styled-components'; import { ProfileImg, WriteInformationDiv } from './CommentList'; +import useCheckLogin from '../../Hooks/useCheckLogin'; +import { useRouter } from 'next/router'; +import Image from 'next/image'; export default function CommentWrite({ path }) { const [commentText, setCommnetText] = useState(''); - const userNickName = auth.currentUser?.displayName ?? 'notNicName'; + const userNickName = auth.currentUser?.displayName ?? ''; const userProfile = - auth.currentUser?.photoURL ?? - 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMQEhUQEBIVFRUVFxUVFRUVFRcVFRcWFRUXFxUVFRYYHSggGBolGxUVITEhJSkrLi4uFx8zODMsNygtLisBCgoKDg0OGhAQGCsdHR0tLSstKysrLS0tKy0tLSstLS0tLS0rLS0tLSstLS0tLS0tKzUtKy0tKzctLTcrKy0tK//AABEIALcBEwMBIgACEQEDEQH/xAAbAAACAwEBAQAAAAAAAAAAAAACAwABBAUGB//EADgQAAIBAgMECQQBAwMFAAAAAAABAgMRBCExBRJBUQYTYXGBkaGx8CLB0eHxFDJSFWKCByNCQ3L/xAAYAQADAQEAAAAAAAAAAAAAAAAAAQMCBP/EAB4RAQEAAwEBAQEBAQAAAAAAAAABAgMRIRIxQVEy/9oADAMBAAIRAxEAPwD10UMSAiMRpkSQSRSDQBaRaIi0AWQhYBC0UQAtlEIACPjoIsNQreNSI2UHYGTI3YpNYWDcjqAE7tUmsaI0BKdgt8X2fyrdIkTfKlLgOZFYlyOQtsByzNzYx8NFymIVYXKs3poUuyS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z6/XltoXteU3fNPPK/xXPJ7RxWfO3E93iuh85XvO9/sc+XQaXO5iy1qZYx57orNVMRBNtO/Ll4n26lTSj4HgNg9FJYesqjzST9j2+KxNqTa1yXn89ByMZ3tSN91y7zDjJWV9WMxOOhCKjfh5u1/nccXG7Ti8ln84hYUVVxbvbivbgDjcY2s8mjzsNvxjiHSlJbryvyf82E4zHS3nFO/JrNNEr3i2M7W6tiMxOIrZamSnGcuDH/6fUnwZOY2qWyMn9Rd6+BuwtTIOj0eqN3Orhuj0lqzeOus5Z48cyc08n6MT3HpYbAjxux8djwXAr8I/byii+8ZCnL/ABZ62Oz4rgH/AEkeRr4L7eWVGXIGpg5Pger/AKVAvCofyz9PH/6cyHrf6VEH8l120GhcQ0zTI0GhaYSAhospFgY0yMpFgFNCpRGlWEZW6Xuh2JYAXYiDaBABZVi2RDILiDuDWCxAEY5jatGMlZpPvBQ1MOBhrbLpSteCy7+JmjsLDr/1ROswJIOH1x49HcMndUKd/wD5Hx2VRWlKC8DfYpoXB1mjhILSK8g+qjyQ1oFgAbi5E3QmVcAqwDQbBYwWyhjQEkMAYLCYLAgkKsQA6EWGiEACQSIQCEgiEALRZZANCEIKhRCEA1MEhBhTKIQCQpkIIKQaZRAC7lMogBRRZAAWCQgGpoGxCCILI0QgwFgshBgDAkQgAu5CEAP/2Q=='; + auth.currentUser?.photoURL ?? '/images/defaultProfile.png'; + const { isLogin } = useCheckLogin(); + const router = useRouter(); const createdAt = Date.now(); @@ -19,29 +23,34 @@ export default function CommentWrite({ path }) { }; const addComment = async () => { - if (commentText.trim().length == 0) { - return; + if (isLogin) { + if (commentText.trim().length == 0) { + return; + } + + const collectionRef = collection(dbService, path); + const payload = { + commentText, + userNickName, + userProfile, + createdAt, + userId: auth.currentUser?.uid, + }; + await addDoc(collectionRef, payload); + setCommnetText(''); + } else { + router.push('/auth/sign-in'); } - const collectionRef = collection(dbService, path); - const payload = { - commentText, - userNickName, - userProfile, - createdAt, - timestamp: serverTimestamp(), - }; - await addDoc(collectionRef, payload); - setCommnetText(''); }; return ( - +

{userNickName}

-
+ Date: Wed, 22 Feb 2023 10:26:45 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=93=9D=20Docs:=20detail=20view=20url?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20#6=20#20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/PostListCard.tsx | 2 +- pages/{post-list => detail}/[id].tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename pages/{post-list => detail}/[id].tsx (89%) diff --git a/components/PostListCard.tsx b/components/PostListCard.tsx index 4246bd0..ed70f36 100644 --- a/components/PostListCard.tsx +++ b/components/PostListCard.tsx @@ -35,7 +35,7 @@ const PostListCard = ({ post, currentUserId }: PostListCardProps) => { }; return ( - +
Date: Wed, 22 Feb 2023 10:27:42 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=92=84=20Design:=20=EC=BB=A4=EC=8A=A4?= =?UTF-8?q?=ED=85=80=EB=B2=84=ED=8A=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ui/CustomButton.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/ui/CustomButton.tsx b/components/ui/CustomButton.tsx index 4587b4d..8021b44 100644 --- a/components/ui/CustomButton.tsx +++ b/components/ui/CustomButton.tsx @@ -10,7 +10,7 @@ interface CustomButtonProps { paddingColumns?: string; fontColor?: string; onClick?: any; - borderColor?:string + border?: string; } export default function CustomButton({ @@ -21,7 +21,7 @@ export default function CustomButton({ paddingColumns, fontColor, onClick, - borderColor + border, }: CustomButtonProps) { return ( ); @@ -45,5 +45,5 @@ const Button = styled.button` background: ${(props) => props.backgoundColor}; border-radius: 0.625rem; cursor: pointer; - border:1px solid ${props=>props.borderColor} + border: ${(props) => props.border}; `; From c9f9fc1e6c1f79885378a28170a85a8aadc89586 Mon Sep 17 00:00:00 2001 From: tyoung Date: Wed, 22 Feb 2023 13:11:02 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E2=9C=A8=20Feat:=C2=A0sns=20=EA=B3=B5?= =?UTF-8?q?=EC=9C=A0=ED=95=98=EA=B8=B0=20=EB=B2=84=ED=8A=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#22=20#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Hooks/useGetKakao.tsx | 71 ++++++++++++++++++++ components/detail/DetailViewText.tsx | 95 +++++++++++++++++++++++---- public/images/snsWrapper.png | Bin 0 -> 2468 bytes public/images/sprite_icon.png | Bin 5549 -> 5743 bytes 4 files changed, 153 insertions(+), 13 deletions(-) create mode 100644 components/Hooks/useGetKakao.tsx create mode 100644 public/images/snsWrapper.png diff --git a/components/Hooks/useGetKakao.tsx b/components/Hooks/useGetKakao.tsx new file mode 100644 index 0000000..1687197 --- /dev/null +++ b/components/Hooks/useGetKakao.tsx @@ -0,0 +1,71 @@ +// hooks.js +import { useState, useEffect } from 'react'; + +function useGetKakao(src) { + // Keep track of script status ("idle", "loading", "ready", "error") + const [status, setStatus] = useState(src ? 'loading' : 'idle'); + + useEffect( + () => { + // Allow falsy src value if waiting on other data needed for + // constructing the script URL passed to this hook. + if (!src) { + setStatus('idle'); + return; + } + + // Fetch existing script element by src + // It may have been added by another intance of this hook + let script = document.querySelector(`script[src="${src}"]`); + + if (!script) { + // Create script + script = document.createElement('script'); + script.src = src; + script.async = true; + script.setAttribute('data-status', 'loading'); + // Add script to document body + document.body.appendChild(script); + + // Store status in attribute on script + // This can be read by other instances of this hook + const setAttributeFromEvent = (event) => { + script.setAttribute( + 'data-status', + event.type === 'load' ? 'ready' : 'error', + ); + }; + + script.addEventListener('load', setAttributeFromEvent); + script.addEventListener('error', setAttributeFromEvent); + } else { + // Grab existing script status from attribute and set to state. + setStatus(script.getAttribute('data-status')); + } + + // Script event handler to update status in state + // Note: Even if the script already exists we still need to add + // event handlers to update the state for *this* hook instance. + const setStateFromEvent = (event) => { + setStatus(event.type === 'load' ? 'ready' : 'error'); + }; + + // Add event listeners + script.addEventListener('load', setStateFromEvent); + script.addEventListener('error', setStateFromEvent); + + // Remove event listeners on cleanup + return () => { + if (script) { + script.removeEventListener('load', setStateFromEvent); + script.removeEventListener('error', setStateFromEvent); + } + }; + }, + [src], // Only re-run effect if script src changes + ); + + return status; +} + +export { useGetKakao }; diff --git a/components/detail/DetailViewText.tsx b/components/detail/DetailViewText.tsx index 7de4d4d..e51c8a6 100644 --- a/components/detail/DetailViewText.tsx +++ b/components/detail/DetailViewText.tsx @@ -1,9 +1,34 @@ -import React from 'react'; +import React, { useEffect, useState } from 'react'; +import { FacebookShareButton } from 'react-share'; import styled from 'styled-components'; - +import { CopyToClipboard } from 'react-copy-to-clipboard'; +import { useGetKakao } from '../Hooks/useGetKakao'; type Props = {}; export default function DetailViewText({ detail }: Props) { + const [socialSharing, setSocialSharing] = useState(false); + + const clickToShare = () => { + setSocialSharing((prev) => !prev); + }; + const currentUrl = window.location.href; + + const status = useGetKakao('https://developers.kakao.com/sdk/js/kakao.js'); + useEffect(() => { + if (status === 'ready' && window.Kakao) { + if (!window.Kakao.isInitialized()) { + // 두번째 step 에서 가져온 javascript key 를 이용하여 initialize + window.Kakao.init('a81b3af974c17b5fc4088249f10e7f77'); + } + } + }, [status]); + + const handleKakaoButton = () => { + window.Kakao.Link.sendScrap({ + requestUrl: currentUrl, + }); + }; + return ( <> @@ -11,12 +36,22 @@ export default function DetailViewText({ detail }: Props) {
{detail.postText}
-
공유
-
    -
  • 1
  • -
  • 2
  • -
  • 3
  • -
+
+ 공유 +
+ {socialSharing && ( +
    +
  • + kakao +
  • + +
  • facebook
  • +
    + +
  • link
  • +
    +
+ )}
); @@ -43,16 +78,50 @@ const ShareLayout = styled.div` display: flex; justify-content: flex-end; position: relative; + padding: 1rem; .share { - padding: 20px; - cursor: point; + display: block; + width: 28px; + height: 28px; + background: url('/images/sprite_icon.png'); + background-position: -108px 0; + cursor: pointer; + text-indent: -999999%; } + .sns { position: absolute; - right: 0; - bottom: 0; - + right: -4%; + bottom: -3.125rem; display: flex; + justify-content: space-between; + align-items: center; + padding: 0.625rem; + width: 7.75rem; + height: 3.5rem; + background: url('/images/snsWrapper.png') no-repeat center; + border-radius: 0.625rem; + + .sns-icon { + display: flex; + align-items: center; + gap: 0.625rem; + width: 1.875rem; + height: 1.875rem; + text-indent: -999999%; + background: url('/images/sprite_icon.png') no-repeat center; + cursor: pointer; + + &.kakao { + background-position: -2.125rem 0.0625rem; + } + &.facebook { + background-position: 0 0.0625rem; + } + &.link { + background-position: -72px 0.0625rem; + } + } } `; diff --git a/public/images/snsWrapper.png b/public/images/snsWrapper.png new file mode 100644 index 0000000000000000000000000000000000000000..73ed663c93c0020ee45431947223d1e4cccd6b31 GIT binary patch literal 2468 zcmV;V30wAwP)Ym4ryX#|d-6$GF#V3049N0?`LJsk;MiTH~LP)Mc5R8Ns68`{AOu$1RB!{pF z=Af4-h|z-(g(xd3D$4p`Tz6fZeaz0Q^8L#CdTV-nW>&~Sr|Jhy*YoSDuCKrP>Z|H1 zAv_pTc!)r_3ow8j92^V=1_na$>Rklz3(p+RL4pbT`}P4+qdoVLI^BKax z6ci>r8~_>`4Zd^d&h)KYw>E(hlmWRXPMtcn5^>~}xP(Xh0?dF$h7?%6dUbAgcJ?C&ZbssZlZyY~UoP?o?;i8h95+%#QXq&xiG zh#?Ty*VosHv|gWRQ?PU(XGcDt|4OyM$jHbiYuB#rp!A`a5(!`>%Tl)V#qL&N?6>nb zqnUIydrqUYxXe&8Fx^0RwOW1HiXo8Z+S&Dc6^)` z?x2Hso2Era(p@2~Nhc{?lm{SY2o4@R*t>V{-fz0Py1o<(!1VO=Pgky7`EmdL{r5UM zJ8SlHQyHQSl2k^t4RCi9twBqkB{?4pAB6(DAE;HptI@R6Xt*EVZd5NLL(9lo~ z3?ij`{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Uw~}i<(|E*Ye!Xcd_0Iz+zfq(OlE(va0k)U={}2k7!~~ig||+K@5kt z)wB`ff9O6BV)z93i)4&`1Q!TL|KYu4371kO9HA2HWPgmdl^DM((#k1jWO>ljy66q_ z4-f)m7j%TN*Me<(s!EVTwdrt00000 MNkvXXt^-0~f*8q~?f?J) From 2dd0bbec7defea619eee4f4881d0032b18747ded Mon Sep 17 00:00:00 2001 From: tyoung Date: Wed, 22 Feb 2023 15:40:49 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E2=9C=A8Feat:=C2=A0=EA=B3=B5=EC=9C=A0?= =?UTF-8?q?=ED=95=98=EA=B8=B0,=20=ED=8C=94=EB=A1=9C=EC=9A=B0=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EB=94=94=ED=85=8C=EC=9D=BC=20=EB=B7=B0=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20/=20=EC=9C=A0=EC=A0=80=EB=B0=98=EC=9D=91?= =?UTF-8?q?=20#21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Hooks/useGetReaction.tsx | 13 ++++-- components/detail/DetailViewUserInfor.tsx | 53 +++++++++++------------ pages/auth/sign-in/index.tsx | 13 +++--- 3 files changed, 43 insertions(+), 36 deletions(-) diff --git a/components/Hooks/useGetReaction.tsx b/components/Hooks/useGetReaction.tsx index f8c4090..742230b 100644 --- a/components/Hooks/useGetReaction.tsx +++ b/components/Hooks/useGetReaction.tsx @@ -4,16 +4,23 @@ import React, { useEffect, useState } from 'react'; export default function useGetReaction() { const [userInfor, setUserInfor] = useState([]); + const [follow, setFollow] = useState(); + const [scrap, setScrap] = useState(); useEffect(() => { const collectionRef = collection(dbService, 'userInfo'); onSnapshot(collectionRef, (snapshot: any) => setUserInfor( - snapshot.docs.map((doc: any) => ({ ...doc.data(), id: doc.id })), + snapshot.docs?.map((doc: any) => ({ ...doc.data(), id: doc.id })), ), ); - }, [userInfor]); - return { userInfor }; + userInfor?.map( + (item) => auth.currentUser?.uid == item.id && setFollow(item.following)|| auth.currentUser?.uid == item.id && setScrap(item.scraps), + ); + }, [auth.currentUser?.uid, follow,scrap]); + // userInfor.map((item) => setGetUser(item)); + // console.log('getUser',getUser) + return { userInfor, follow ,scrap}; } diff --git a/components/detail/DetailViewUserInfor.tsx b/components/detail/DetailViewUserInfor.tsx index f47f85b..270c228 100644 --- a/components/detail/DetailViewUserInfor.tsx +++ b/components/detail/DetailViewUserInfor.tsx @@ -9,38 +9,36 @@ import { useRouter } from 'next/router'; export default function DetailViewUserInfor({ detail }) { const router = useRouter(); - const { userProfile, userId, jobCategory, likesCount, id, likes, scrap } = - detail; + const { userProfile, userId, jobCategory, likesCount, id, likes } = detail; const { isLogin, isUserObj, logOut } = useCheckLogin(); const like = likes.includes(isUserObj) ? true : false; const { userInfor } = useGetReaction(); - const [followings, setFollowings] = useState(); - const [scraps, setScraps] = useState(); - const follow = !!followings?.includes(userId) ? true : false; - const scraping = !!scraps?.includes(id) ? true : false; + const [following, setFollowing] = useState<[] | undefined>(); + const [scraps, setScraps] = useState<[] | undefined>(); + const scraper = scraps?.includes(id) ? true : false; + const follower = following?.includes(userId) ? true : false; useEffect(() => { userInfor?.map( (item) => - (auth.currentUser?.uid === item.id && setFollowings(item.followings)) || - (auth.currentUser?.uid === item.id && setScraps(item.scraps)), + (auth.currentUser?.uid === item.id && setFollowing(item.following)) || + (auth.currentUser?.uid == item.id && setScraps(item.scraps)), ); - }, [userInfor]); + }, [userInfor, following, scraps]); - const onclickScrap = async (num) => { + const onclickScrap = async (num: any) => { if (isLogin) { - if (!!scraps.includes(id)) { - scraps.pop(id); + if (scraps?.includes(id)) { + scraps?.pop(id); } else { - scraps.push(id); + scraps?.push(id); } - - const docRef = doc(dbService, 'userInfo', num); - const payload = { scraps }; - await updateDoc(docRef, payload); } else { router.push('/auth/sign-in'); } + const docRef = doc(dbService, 'userInfo', num); + const payload = { scraps }; + await updateDoc(docRef, payload); }; const onclickLove = async (num: any) => { @@ -63,18 +61,17 @@ export default function DetailViewUserInfor({ detail }) { const onclickFollow = async (num: any) => { if (isLogin) { - if (!!followings.includes(userId)) { - followings.pop(userId); + if (following?.includes(userId)) { + following?.pop(userId); } else { - followings.push(userId); + following?.push(userId); } - - const docRef = doc(dbService, 'userInfo', num); - const payload = { followings }; - await updateDoc(docRef, payload); } else { router.push('/auth/sign-in'); } + const docRef = doc(dbService, 'userInfo', num); + const payload = { following }; + await updateDoc(docRef, payload); }; return ( @@ -86,10 +83,9 @@ export default function DetailViewUserInfor({ detail }) {

{jobCategory}

-
{likesCount} +
- {!follow ? ( + {!follower ? ( ) : ( { console.log(e.target.checked); setStayLoginIsChecked(e.target.checked); @@ -153,8 +156,8 @@ export default function SignIn({}: Props) { const collectionRef = doc(dbService, `userInfo/${auth.currentUser?.uid}`); const payload = { userId: auth.currentUser?.uid, - scraps: [], - following: [], + scraps: [...scrap], + following: [...follow], introduction: '안녕하세요!', }; @@ -178,8 +181,8 @@ export default function SignIn({}: Props) { const collectionRef = doc(dbService, `userInfo/${auth.currentUser?.uid}`); const payload = { userId: auth.currentUser?.uid, - scraps: [], - following: [], + scraps: [...scrap], + following: [...follow], introduction: '안녕하세요!', }; From a73a1f1f4f32bb0f9485f219d864c2358a28c654 Mon Sep 17 00:00:00 2001 From: tyoung Date: Wed, 22 Feb 2023 15:45:27 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=92=84Design:=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=95=84=EC=9B=83=20=EB=B3=80=EA=B2=BD=20#20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/detail/DetailView.tsx | 34 ++++++++++++--- components/detail/DetailViewProducts.tsx | 54 +++++++++++++++++------- components/detail/DetailViewSlide.tsx | 2 +- package.json | 2 + 4 files changed, 69 insertions(+), 23 deletions(-) diff --git a/components/detail/DetailView.tsx b/components/detail/DetailView.tsx index a6e2a53..0e31327 100644 --- a/components/detail/DetailView.tsx +++ b/components/detail/DetailView.tsx @@ -21,15 +21,19 @@ export default function DetailView({}) { (detail) => id == detail.id && ( -
+
- - - -
-
-
+ +
+ + + +
+
+ +
+
), )} @@ -38,15 +42,31 @@ export default function DetailView({}) { } const DetailViewLayout = styled.div` + max-width: 75rem; + width: 100%; + margin: 9.25rem auto; + + .detail-header { + width: 100%; + max-width: 55.875rem; + } +`; + +const DetailViewDiv = styled.div` display: flex; justify-content: space-between; + align-items: flex-start; gap: 1.5rem; .detail-view { width: 100%; max-width: 55.875rem; } + .detail-product { width: calc(100% - 55.875rem); + background-color: #f1f3f5; + padding: 1.25rem; + border-radius: 0.625rem; } `; diff --git a/components/detail/DetailViewProducts.tsx b/components/detail/DetailViewProducts.tsx index 3626765..0adf13b 100644 --- a/components/detail/DetailViewProducts.tsx +++ b/components/detail/DetailViewProducts.tsx @@ -7,30 +7,54 @@ export default function DetailViewProducts({ detail }: Props) { const { products } = detail; return ( -

사용한 제품

-

{products?.length}개의 제품이 사용됐어요.

- - {products?.map((product) => ( -
- {product.title} -

{product.title}

-

{product.hashTag}

-
- ))} +

사용한 제품

+

{products?.length}개의 제품이 사용됐어요.

+ +
+ {products?.map((product) => ( +
+ {product.title} +

{product.title}

+

{product.hashTag}

+
+ ))} +
); } const DetailViewProductsLayout = styled.div` + .title { + font-size: 1.5rem; + font-weight: 700; + margin-bottom: 0.25rem; + } + + .description { + font-size: 0.75rem; + color: #868e96; + } + .product-wrap { + max-height: 66.875rem; + min-height: 66.875rem; + overflow-y: auto; + padding: 0 0.625rem 0 0; + } + .product-list { display: flex; flex-direction: column; align-items: center; justify-content: center; - padding: 10px; - margin: 10px 0 1rem; - border: 1px solid #868e96; - border-radius: 10px; + padding: 0.625rem; + margin: 0.625rem 0 1rem; + border: 0.0625rem solid #868e96; + border-radius: 0.625rem; + background: #fff; text-align: center; .product-img { @@ -39,7 +63,7 @@ const DetailViewProductsLayout = styled.div` } .product-title { - margin: 10px 0 2px; + margin: 0.625rem 0 0.125rem; font-weight: 700; } } diff --git a/components/detail/DetailViewSlide.tsx b/components/detail/DetailViewSlide.tsx index da8d9dc..60eef8d 100644 --- a/components/detail/DetailViewSlide.tsx +++ b/components/detail/DetailViewSlide.tsx @@ -29,7 +29,7 @@ export default function DetailViewSlide({ detail }) { } const DetailViewSlideLayout = styled.div` - border-radius: 10px; + border-radius: 0.625rem; overflow: hidden; .post-img { diff --git a/package.json b/package.json index 9161484..97744f3 100644 --- a/package.json +++ b/package.json @@ -20,11 +20,13 @@ "firebase": "^9.17.1", "next": "13.1.6", "react": "18.2.0", + "react-copy-to-clipboard": "^5.1.0", "react-dom": "18.2.0", "react-firebase-hooks": "^5.1.1", "react-icons": "^4.7.1", "react-query": "^3.39.3", "react-quill": "^2.0.0", + "react-share": "^4.4.1", "styled-components": "^5.3.6", "styled-reset": "^4.4.5", "swiper": "^9.0.5",