code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -0,0 +1,18 @@
+export interface PageInfoData {
+ title: string;
+ description: string;
+ src: string;
+}
+
+export interface PageNavData {
+ id: string;
+ label: string;
+ icon?: string;
+ active: boolean;
+ subItems?: PageNavData[];
+}
+
+export interface FilteringData {
+ label: string;
+ value: string;
+} | TypeScript | [p5] type ํ์ผ์ ๋ฐ๋ก ๋ถ๋ฆฌํด์ ๊ฐ๋
์ฑ์ด ์ข์์ก๋ค์~๐ |
@@ -0,0 +1,16 @@
+export interface ReviewScore {
+ teamId: number;
+ gatheringId: number;
+ type: string;
+ averageScore: number;
+ oneStar: number;
+ twoStars: number;
+ threeStars: number;
+ fourStars: number;
+ fiveStars: number;
+}
+
+export interface GetReviewsParams {
+ gatheringId?: string;
+ type?: '' | 'DALLAEMFIT' | 'OFFICE_STRETCHING' | 'MINDFULNESS' | 'WORKATION';
+} | TypeScript | [p5] type ํ์ผ์ ๋ฐ๋ก ๋ถ๋ฆฌํด์ ๋ณด๊ธฐ ์ข์ต๋๋ค~!๐ฑ |
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
import styled from "@emotion/styled";
import { css, Theme } from "@emotion/react";
import CheckIcon from "components/inputs/TextInput/CheckIcon";
-import { TConditionCheck } from "./types/TConditionCheck";
+import { TConditionCheck } from "components/inputs/TextInput/types/TConditionCheck";
interface Props {
name?: string;
@@ -12,6 +12,7 @@ interface Props {
conditionList?: string[];
conditionCheckList?: TConditionCheck[];
multiline?: boolean;
+ height?: string;
onTextChange?: (value: string, isValid: boolean) => void;
}
@@ -23,6 +24,7 @@ const TextInput: React.FC<Props> = ({
conditionList,
conditionCheckList,
multiline = false,
+ height,
onTextChange,
}) => {
const [status, setStatus] = useState(value === "" ? "default" : "success"); // default / success / invalid / focus
@@ -76,7 +78,7 @@ const TextInput: React.FC<Props> = ({
}, [enteredValue, status, onTextChange]);
return (
- <EmotionWrapper>
+ <EmotionWrapper height={height}>
{label && <span className="label">{label}</span>}
{conditionList && (
<div className="spanList">
@@ -179,6 +181,7 @@ const EmotionWrapper = styled.div<Props>`
${({ theme }) => commonStyles(theme)};
position: relative;
resize: none;
+ height: ${({ height }) => height ?? "auto"};
}
`;
| Unknown | ์ฌ์ํ์ง๋ง `height ?? "auto"` ๋ ๊ด์ฐฎ์ ๊ฒ ๊ฐ์์! |
@@ -0,0 +1,170 @@
+import styled from "@emotion/styled";
+import IconStarFilled from "components/rating/icons/IconStarFilled";
+import IconStarHalf from "components/rating/icons/IconStarHalf";
+import IconStarOutlined from "components/rating/icons/IconStarOutlined";
+import { HTMLAttributes, useEffect, useState, useRef, useCallback } from "react";
+
+interface Props extends HTMLAttributes<HTMLDivElement> {
+ value: number; // 0 ~ 5 ์ฌ์ด์ ์ซ์, ๋ณ ๊ฐ์๋ ๊ฐ์ฅ ๊ฐ๊น์ด 0.5 ๋จ์๋ก ๋ฐ์ฌ๋ฆผ
+ isInput?: boolean; // input ๊ธฐ๋ฅ์ ํ๋๋ก ํ ์ง ์ค์
+ onSelectedValueChange?: (value: number) => void;
+}
+
+const Rating = ({ value, isInput = false, onSelectedValueChange, ...props }: Props) => {
+ const [selectedValue, setSelectedValue] = useState<number>(value);
+ const isMouseDown = useRef<boolean>(false);
+ const containerRef = useRef<HTMLDivElement>(null);
+
+ // round value to the nearest 0.5
+ const startCount = Math.round(selectedValue * 2) / 2;
+
+ const filledStarCount = Math.floor(startCount);
+ const hasHalfStar = startCount % 1 !== 0;
+ const emptyStarCount = 5 - filledStarCount - (hasHalfStar ? 1 : 0);
+
+ useEffect(() => {
+ if (onSelectedValueChange) {
+ onSelectedValueChange(selectedValue);
+ }
+ }, [selectedValue, onSelectedValueChange]);
+
+ const handleOnClick = (event: React.MouseEvent, index: number) => {
+ const clickX = event.nativeEvent.clientX; // ํด๋ฆญํ ์์น์ X ์ขํ
+
+ // IconStar... ์ปดํฌ๋ํธ ๋ด์์ ํด๋ฆญํ ์์น๋ฅผ ๊ธฐ์ค์ผ๋ก ์ผ์ชฝ ๋๋ ์ค๋ฅธ์ชฝ ํ๋ณ
+ const containerRect = event.currentTarget.getBoundingClientRect();
+ const containerCenterX = (containerRect.left + containerRect.right) / 2;
+
+ if (clickX < containerCenterX) {
+ setSelectedValue(index + 0.5);
+ } else {
+ setSelectedValue(index + 1);
+ }
+ };
+
+ const calculateScore = useCallback((currentX: number) => {
+ const container = containerRef.current;
+ if (container) {
+ const unitSize = container.getBoundingClientRect().width / 10;
+ const relativeX = currentX - container.getBoundingClientRect().x;
+ if (relativeX <= 0) setSelectedValue(0.5);
+ else {
+ const score = (Math.floor(relativeX / unitSize) + 1) * 0.5;
+ score > 5 ? setSelectedValue(5) : setSelectedValue(score);
+ }
+ }
+ }, []);
+
+ const handleOnMouseDown = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
+ isMouseDown.current = true;
+ }, []);
+
+ const handleOnMouseLeave = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
+ isMouseDown.current = false;
+ }, []);
+
+ const handleOnMouseMove = useCallback(
+ (event: React.MouseEvent) => {
+ if (isMouseDown.current) calculateScore(event.clientX);
+ },
+ [calculateScore]
+ );
+
+ const handleOnMouseUp = useCallback((event: React.MouseEvent) => {
+ isMouseDown.current = false;
+ }, []);
+
+ // For mobile view
+ const handleOnTouchMove = useCallback(
+ (event: React.TouchEvent) => {
+ calculateScore(event.changedTouches[0].clientX);
+ },
+ [calculateScore]
+ );
+
+ return (
+ <EmotionWrapper isInput={isInput} {...props}>
+ <div
+ className="star-container"
+ onMouseDown={handleOnMouseDown}
+ onMouseUp={handleOnMouseUp}
+ onMouseMove={handleOnMouseMove}
+ onMouseLeave={handleOnMouseLeave}
+ onTouchMove={handleOnTouchMove}
+ ref={containerRef}
+ >
+ {Array.from({ length: filledStarCount }, (_, index) =>
+ isInput ? (
+ <IconStarFilled
+ key={index}
+ size={40}
+ onClick={(event: React.MouseEvent) => handleOnClick(event, index)}
+ />
+ ) : (
+ <IconStarFilled key={index} />
+ )
+ )}
+ {hasHalfStar &&
+ (isInput ? (
+ <IconStarHalf
+ size={40}
+ onClick={(event: React.MouseEvent) => handleOnClick(event, filledStarCount)}
+ />
+ ) : (
+ <IconStarHalf />
+ ))}
+ {Array.from({ length: emptyStarCount }, (_, index) =>
+ isInput ? (
+ <IconStarOutlined
+ key={index}
+ size={40}
+ onClick={(event: React.MouseEvent) =>
+ handleOnClick(event, filledStarCount + index + (hasHalfStar ? 1 : 0))
+ }
+ />
+ ) : (
+ <IconStarOutlined key={index} />
+ )
+ )}
+ </div>
+ {isInput ? (
+ <div>
+ <span className="rating-value-selected">{selectedValue}</span>
+ <span className="rating-full-marks"> / 5</span>
+ </div>
+ ) : (
+ <p className="rating-value">{value}</p>
+ )}
+ </EmotionWrapper>
+ );
+};
+
+export default Rating;
+
+const EmotionWrapper = styled.div<{ isInput: boolean }>`
+ display: flex;
+ align-items: center;
+ ${({ isInput }) => (isInput ? "flex-direction: column; gap: 20px;" : "column-gap: 4px;")}
+
+ .star-container {
+ display: flex;
+ column-gap: 2px;
+ }
+
+ color: ${({ theme }) => theme.color.gray400};
+
+ .rating-full-marks {
+ font-size: 16px;
+ font-weight: 300;
+ }
+
+ .rating-value-selected {
+ font-size: 32px;
+ font-weight: 500;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .rating-value {
+ font-size: 12px;
+ }
+`; | Unknown | ์ค ์ด ์ปดํฌ๋ํธ๋ ์์ง Rating์ชฝ์ด ๋จธ์ง ๋์ง ์์์ ์ผ๋ถ ๋ด์ฉ์ ๊ทธ๋๋ก ๊ฐ์ง๊ณ ์ค์ ๋ถ๋ถ์ธ๊ฐ์ฉ~? (+ `isInput` ๋ชจ๋ ์ถ๊ฐ๋ก์?) |
@@ -0,0 +1,170 @@
+import styled from "@emotion/styled";
+import IconStarFilled from "components/rating/icons/IconStarFilled";
+import IconStarHalf from "components/rating/icons/IconStarHalf";
+import IconStarOutlined from "components/rating/icons/IconStarOutlined";
+import { HTMLAttributes, useEffect, useState, useRef, useCallback } from "react";
+
+interface Props extends HTMLAttributes<HTMLDivElement> {
+ value: number; // 0 ~ 5 ์ฌ์ด์ ์ซ์, ๋ณ ๊ฐ์๋ ๊ฐ์ฅ ๊ฐ๊น์ด 0.5 ๋จ์๋ก ๋ฐ์ฌ๋ฆผ
+ isInput?: boolean; // input ๊ธฐ๋ฅ์ ํ๋๋ก ํ ์ง ์ค์
+ onSelectedValueChange?: (value: number) => void;
+}
+
+const Rating = ({ value, isInput = false, onSelectedValueChange, ...props }: Props) => {
+ const [selectedValue, setSelectedValue] = useState<number>(value);
+ const isMouseDown = useRef<boolean>(false);
+ const containerRef = useRef<HTMLDivElement>(null);
+
+ // round value to the nearest 0.5
+ const startCount = Math.round(selectedValue * 2) / 2;
+
+ const filledStarCount = Math.floor(startCount);
+ const hasHalfStar = startCount % 1 !== 0;
+ const emptyStarCount = 5 - filledStarCount - (hasHalfStar ? 1 : 0);
+
+ useEffect(() => {
+ if (onSelectedValueChange) {
+ onSelectedValueChange(selectedValue);
+ }
+ }, [selectedValue, onSelectedValueChange]);
+
+ const handleOnClick = (event: React.MouseEvent, index: number) => {
+ const clickX = event.nativeEvent.clientX; // ํด๋ฆญํ ์์น์ X ์ขํ
+
+ // IconStar... ์ปดํฌ๋ํธ ๋ด์์ ํด๋ฆญํ ์์น๋ฅผ ๊ธฐ์ค์ผ๋ก ์ผ์ชฝ ๋๋ ์ค๋ฅธ์ชฝ ํ๋ณ
+ const containerRect = event.currentTarget.getBoundingClientRect();
+ const containerCenterX = (containerRect.left + containerRect.right) / 2;
+
+ if (clickX < containerCenterX) {
+ setSelectedValue(index + 0.5);
+ } else {
+ setSelectedValue(index + 1);
+ }
+ };
+
+ const calculateScore = useCallback((currentX: number) => {
+ const container = containerRef.current;
+ if (container) {
+ const unitSize = container.getBoundingClientRect().width / 10;
+ const relativeX = currentX - container.getBoundingClientRect().x;
+ if (relativeX <= 0) setSelectedValue(0.5);
+ else {
+ const score = (Math.floor(relativeX / unitSize) + 1) * 0.5;
+ score > 5 ? setSelectedValue(5) : setSelectedValue(score);
+ }
+ }
+ }, []);
+
+ const handleOnMouseDown = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
+ isMouseDown.current = true;
+ }, []);
+
+ const handleOnMouseLeave = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
+ isMouseDown.current = false;
+ }, []);
+
+ const handleOnMouseMove = useCallback(
+ (event: React.MouseEvent) => {
+ if (isMouseDown.current) calculateScore(event.clientX);
+ },
+ [calculateScore]
+ );
+
+ const handleOnMouseUp = useCallback((event: React.MouseEvent) => {
+ isMouseDown.current = false;
+ }, []);
+
+ // For mobile view
+ const handleOnTouchMove = useCallback(
+ (event: React.TouchEvent) => {
+ calculateScore(event.changedTouches[0].clientX);
+ },
+ [calculateScore]
+ );
+
+ return (
+ <EmotionWrapper isInput={isInput} {...props}>
+ <div
+ className="star-container"
+ onMouseDown={handleOnMouseDown}
+ onMouseUp={handleOnMouseUp}
+ onMouseMove={handleOnMouseMove}
+ onMouseLeave={handleOnMouseLeave}
+ onTouchMove={handleOnTouchMove}
+ ref={containerRef}
+ >
+ {Array.from({ length: filledStarCount }, (_, index) =>
+ isInput ? (
+ <IconStarFilled
+ key={index}
+ size={40}
+ onClick={(event: React.MouseEvent) => handleOnClick(event, index)}
+ />
+ ) : (
+ <IconStarFilled key={index} />
+ )
+ )}
+ {hasHalfStar &&
+ (isInput ? (
+ <IconStarHalf
+ size={40}
+ onClick={(event: React.MouseEvent) => handleOnClick(event, filledStarCount)}
+ />
+ ) : (
+ <IconStarHalf />
+ ))}
+ {Array.from({ length: emptyStarCount }, (_, index) =>
+ isInput ? (
+ <IconStarOutlined
+ key={index}
+ size={40}
+ onClick={(event: React.MouseEvent) =>
+ handleOnClick(event, filledStarCount + index + (hasHalfStar ? 1 : 0))
+ }
+ />
+ ) : (
+ <IconStarOutlined key={index} />
+ )
+ )}
+ </div>
+ {isInput ? (
+ <div>
+ <span className="rating-value-selected">{selectedValue}</span>
+ <span className="rating-full-marks"> / 5</span>
+ </div>
+ ) : (
+ <p className="rating-value">{value}</p>
+ )}
+ </EmotionWrapper>
+ );
+};
+
+export default Rating;
+
+const EmotionWrapper = styled.div<{ isInput: boolean }>`
+ display: flex;
+ align-items: center;
+ ${({ isInput }) => (isInput ? "flex-direction: column; gap: 20px;" : "column-gap: 4px;")}
+
+ .star-container {
+ display: flex;
+ column-gap: 2px;
+ }
+
+ color: ${({ theme }) => theme.color.gray400};
+
+ .rating-full-marks {
+ font-size: 16px;
+ font-weight: 300;
+ }
+
+ .rating-value-selected {
+ font-size: 32px;
+ font-weight: 500;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .rating-value {
+ font-size: 12px;
+ }
+`; | Unknown | ์ค... ๋ฐ์ด๋ ์ฌ์ฉ์ฑ์ผ ๊ฒ ๊ฐ์ต๋๋ค ๐ ์๊ณ ํ์
จ์ต๋๋ค! |
@@ -0,0 +1,120 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Rating from "components/rating/Rating";
+import IconEditFilledWhite from "components/icons/IconEditFilledWhite";
+import Link from "next/link";
+import dayjs from "dayjs";
+
+interface Props {
+ restaurantId: string;
+ reviewId: number;
+ userId: number;
+ score: number;
+ content: string;
+ createdAt: Date;
+}
+
+const ReviewItem: React.FC<Props> = ({
+ restaurantId,
+ reviewId,
+ userId,
+ score,
+ content,
+ createdAt,
+}) => {
+ const [isExpanded, setIsExpanded] = useState(false);
+
+ const toggleExpansion = () => {
+ setIsExpanded((isExpanded) => !isExpanded);
+ };
+
+ const editLink = `/restaurants/${restaurantId}/review/${reviewId}/edit`;
+ const displayContent =
+ content.length > 100 && !isExpanded ? content.slice(0, 100) + "..." : content;
+
+ /**
+ * TODO 1: userId๋ก userInfo ๋ถ๋ฌ์ค๊ธฐ
+ */
+ const userName = "ํ๊ธธ๋";
+ const ImgSrc = "/images/profile-image-default-1.png";
+
+ /**
+ * TODO 2: ํ์ฌ ๋ก๊ทธ์ธ๋ ์ ์ ์์ด๋ ๊ฐ์ ธ์ค๊ธฐ (๋ฆฌ๋ทฐ ์์ ๊ถํ ํ์ธ์ฉ)
+ */
+ const currentUserId = 1;
+
+ return (
+ <EmotionWrapper>
+ <div className="user-info-score-div">
+ <div className="user-info-div">
+ <Image src={ImgSrc} alt={"์ ์ ํ๋กํ ์ด๋ฏธ์ง"} width={30} height={30} />
+ <span className="user-name">{userName}</span>
+ <span className="date">{dayjs(createdAt).format("YY/MM/DD")}</span>
+ {currentUserId === userId && (
+ <Link href={editLink}>
+ <IconEditFilledWhite />
+ </Link>
+ )}
+ </div>
+ <Rating value={score} />
+ </div>
+ <div className="content-div">
+ <span>{displayContent}</span>
+ {content.length > 100 && (
+ <button onClick={toggleExpansion}>{isExpanded ? "์ ๊ธฐ" : "๋ ๋ณด๊ธฐ"}</button>
+ )}
+ </div>
+ </EmotionWrapper>
+ );
+};
+
+export default ReviewItem;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ min-height: 90px;
+ width: 100%;
+ background-color: ${({ theme }) => theme.color.white};
+ border-radius: 6px;
+
+ padding: 10px;
+
+ .user-info-score-div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .user-info-div {
+ display: flex;
+ gap: 8px;
+ justify-content: center;
+ align-items: center;
+
+ span.user-name {
+ font-size: 16px;
+ font-weight: 600;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+ span.date {
+ font-size: 12px;
+ font-weight: 300;
+ color: ${({ theme }) => theme.color.gray300};
+ }
+ }
+ }
+
+ .content-div {
+ span {
+ line-height: 1.5;
+ color: ${({ theme }) => theme.color.gray400};
+ flex-grow: 1;
+ margin-right: 8px;
+ }
+
+ button {
+ color: ${({ theme }) => theme.color.gray300};
+ }
+ }
+`; | Unknown | ์ค..! ์ ํฌ๊ฐ `dayjs` ๋ ์ฐ๊ณ ์์ด์ ํ์ฉํด๋ณด์๋ ๊ฒ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค!
์ด๋ฐ ๊ฒฝ์ฐ
```tsx
import dayjs from 'dayjs';
const formattedDate= dayjs(date).format("YY/MM/DD")
```
์ด๋ ๊ฒ ํ์ฉํด๋ณผ ์๋ ์์ ๊ฒ ๊ฐ์ต๋๋ค~ |
@@ -0,0 +1,120 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Rating from "components/rating/Rating";
+import IconEditFilledWhite from "components/icons/IconEditFilledWhite";
+import Link from "next/link";
+import dayjs from "dayjs";
+
+interface Props {
+ restaurantId: string;
+ reviewId: number;
+ userId: number;
+ score: number;
+ content: string;
+ createdAt: Date;
+}
+
+const ReviewItem: React.FC<Props> = ({
+ restaurantId,
+ reviewId,
+ userId,
+ score,
+ content,
+ createdAt,
+}) => {
+ const [isExpanded, setIsExpanded] = useState(false);
+
+ const toggleExpansion = () => {
+ setIsExpanded((isExpanded) => !isExpanded);
+ };
+
+ const editLink = `/restaurants/${restaurantId}/review/${reviewId}/edit`;
+ const displayContent =
+ content.length > 100 && !isExpanded ? content.slice(0, 100) + "..." : content;
+
+ /**
+ * TODO 1: userId๋ก userInfo ๋ถ๋ฌ์ค๊ธฐ
+ */
+ const userName = "ํ๊ธธ๋";
+ const ImgSrc = "/images/profile-image-default-1.png";
+
+ /**
+ * TODO 2: ํ์ฌ ๋ก๊ทธ์ธ๋ ์ ์ ์์ด๋ ๊ฐ์ ธ์ค๊ธฐ (๋ฆฌ๋ทฐ ์์ ๊ถํ ํ์ธ์ฉ)
+ */
+ const currentUserId = 1;
+
+ return (
+ <EmotionWrapper>
+ <div className="user-info-score-div">
+ <div className="user-info-div">
+ <Image src={ImgSrc} alt={"์ ์ ํ๋กํ ์ด๋ฏธ์ง"} width={30} height={30} />
+ <span className="user-name">{userName}</span>
+ <span className="date">{dayjs(createdAt).format("YY/MM/DD")}</span>
+ {currentUserId === userId && (
+ <Link href={editLink}>
+ <IconEditFilledWhite />
+ </Link>
+ )}
+ </div>
+ <Rating value={score} />
+ </div>
+ <div className="content-div">
+ <span>{displayContent}</span>
+ {content.length > 100 && (
+ <button onClick={toggleExpansion}>{isExpanded ? "์ ๊ธฐ" : "๋ ๋ณด๊ธฐ"}</button>
+ )}
+ </div>
+ </EmotionWrapper>
+ );
+};
+
+export default ReviewItem;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ min-height: 90px;
+ width: 100%;
+ background-color: ${({ theme }) => theme.color.white};
+ border-radius: 6px;
+
+ padding: 10px;
+
+ .user-info-score-div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .user-info-div {
+ display: flex;
+ gap: 8px;
+ justify-content: center;
+ align-items: center;
+
+ span.user-name {
+ font-size: 16px;
+ font-weight: 600;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+ span.date {
+ font-size: 12px;
+ font-weight: 300;
+ color: ${({ theme }) => theme.color.gray300};
+ }
+ }
+ }
+
+ .content-div {
+ span {
+ line-height: 1.5;
+ color: ${({ theme }) => theme.color.gray400};
+ flex-grow: 1;
+ margin-right: 8px;
+ }
+
+ button {
+ color: ${({ theme }) => theme.color.gray300};
+ }
+ }
+`; | Unknown | `className` ์ ๋ฐ๋ก ์ปจ๋ฒค์
์ด ์๋ ๊ฒ์ ์๋์ง๋ง ๋๋ถ๋ถ kebab case ๋ฅผ ์ ์ฉํ๊ณ ์์ด `user-info-score-div` ์ด๋ฐ ์์ ์ด๋จ๊น์~? |
@@ -0,0 +1,105 @@
+import styled from "@emotion/styled";
+import RestaurantExternalLinkIcon from "feature/restaurants/restaurantsDetail/components/icons/RestaurantExternalLinkIcon";
+import Link from "next/link";
+
+interface Props {
+ restaurantId: string;
+ userAuth?: number;
+ restaurantName: string;
+ restaurantAddress: string;
+ organizationName: string;
+ link?: string;
+ isMain?: boolean;
+}
+
+const RestaurantDetailHeaderSection: React.FC<Props> = ({
+ restaurantId,
+ userAuth,
+ restaurantName,
+ restaurantAddress,
+ organizationName,
+ link,
+ isMain = true,
+}) => {
+ return (
+ <EmotionWrapper>
+ <div className="over-title-div">
+ <span className="subtitle">{organizationName}</span>
+ {isMain &&
+ (userAuth === 0 || userAuth === 1 ? (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/edit"}>
+ ๋ง์ง ์์
+ </Link>
+ ) : (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/copy"}>
+ ๋ง์ง ์์
+ </Link>
+ ))}
+ </div>
+ <h1 className="title">{restaurantName}</h1>
+ <div className="under-title-div">
+ <span className="subtitle">{restaurantAddress}</span>
+ {link && (
+ <Link className="link-div" href={link}>
+ <RestaurantExternalLinkIcon />
+ <span className="link-span">๋ง์ง ์์ธ ์ ๋ณด ></span>
+ </Link>
+ )}
+ </div>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantDetailHeaderSection;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ justify-content: center;
+ align-items: left;
+ gap: 8px;
+
+ span {
+ font-weight: 300;
+ margin-left: 2px;
+ font-size: 16px;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+
+ span.subtitle {
+ font-size: 12px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray300};
+ }
+
+ .title {
+ font-size: 30px;
+ font-weight: 600;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .under-title-div,
+ .over-title-div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+
+ .link-div {
+ display: flex;
+ justify-content: right;
+ align-items: center;
+ text-decoration-line: none;
+
+ font-size: 14px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .link-span {
+ font-size: 12px;
+ font-weight: 300;
+ color: ${({ theme }) => theme.color.gray500};
+ }
+`; | Unknown | ์ด `restaurantId` ๊ฐ `string[]` ๋ ๋ฐ๊ฒ ํ์ ์ด์ ๊ฐ ์์๊น์~? |
@@ -0,0 +1,105 @@
+import styled from "@emotion/styled";
+import RestaurantExternalLinkIcon from "feature/restaurants/restaurantsDetail/components/icons/RestaurantExternalLinkIcon";
+import Link from "next/link";
+
+interface Props {
+ restaurantId: string;
+ userAuth?: number;
+ restaurantName: string;
+ restaurantAddress: string;
+ organizationName: string;
+ link?: string;
+ isMain?: boolean;
+}
+
+const RestaurantDetailHeaderSection: React.FC<Props> = ({
+ restaurantId,
+ userAuth,
+ restaurantName,
+ restaurantAddress,
+ organizationName,
+ link,
+ isMain = true,
+}) => {
+ return (
+ <EmotionWrapper>
+ <div className="over-title-div">
+ <span className="subtitle">{organizationName}</span>
+ {isMain &&
+ (userAuth === 0 || userAuth === 1 ? (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/edit"}>
+ ๋ง์ง ์์
+ </Link>
+ ) : (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/copy"}>
+ ๋ง์ง ์์
+ </Link>
+ ))}
+ </div>
+ <h1 className="title">{restaurantName}</h1>
+ <div className="under-title-div">
+ <span className="subtitle">{restaurantAddress}</span>
+ {link && (
+ <Link className="link-div" href={link}>
+ <RestaurantExternalLinkIcon />
+ <span className="link-span">๋ง์ง ์์ธ ์ ๋ณด ></span>
+ </Link>
+ )}
+ </div>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantDetailHeaderSection;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ justify-content: center;
+ align-items: left;
+ gap: 8px;
+
+ span {
+ font-weight: 300;
+ margin-left: 2px;
+ font-size: 16px;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+
+ span.subtitle {
+ font-size: 12px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray300};
+ }
+
+ .title {
+ font-size: 30px;
+ font-weight: 600;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .under-title-div,
+ .over-title-div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+
+ .link-div {
+ display: flex;
+ justify-content: right;
+ align-items: center;
+ text-decoration-line: none;
+
+ font-size: 14px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .link-span {
+ font-size: 12px;
+ font-weight: 300;
+ color: ${({ theme }) => theme.color.gray500};
+ }
+`; | Unknown | ์ ์ฌ๊ธฐ๋ `over-title-div` ์ด๋ ๊ฒ ๊ฐ ์ด๋จ๊น์ ! |
@@ -0,0 +1,105 @@
+import styled from "@emotion/styled";
+import RestaurantExternalLinkIcon from "feature/restaurants/restaurantsDetail/components/icons/RestaurantExternalLinkIcon";
+import Link from "next/link";
+
+interface Props {
+ restaurantId: string;
+ userAuth?: number;
+ restaurantName: string;
+ restaurantAddress: string;
+ organizationName: string;
+ link?: string;
+ isMain?: boolean;
+}
+
+const RestaurantDetailHeaderSection: React.FC<Props> = ({
+ restaurantId,
+ userAuth,
+ restaurantName,
+ restaurantAddress,
+ organizationName,
+ link,
+ isMain = true,
+}) => {
+ return (
+ <EmotionWrapper>
+ <div className="over-title-div">
+ <span className="subtitle">{organizationName}</span>
+ {isMain &&
+ (userAuth === 0 || userAuth === 1 ? (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/edit"}>
+ ๋ง์ง ์์
+ </Link>
+ ) : (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/copy"}>
+ ๋ง์ง ์์
+ </Link>
+ ))}
+ </div>
+ <h1 className="title">{restaurantName}</h1>
+ <div className="under-title-div">
+ <span className="subtitle">{restaurantAddress}</span>
+ {link && (
+ <Link className="link-div" href={link}>
+ <RestaurantExternalLinkIcon />
+ <span className="link-span">๋ง์ง ์์ธ ์ ๋ณด ></span>
+ </Link>
+ )}
+ </div>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantDetailHeaderSection;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ justify-content: center;
+ align-items: left;
+ gap: 8px;
+
+ span {
+ font-weight: 300;
+ margin-left: 2px;
+ font-size: 16px;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+
+ span.subtitle {
+ font-size: 12px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray300};
+ }
+
+ .title {
+ font-size: 30px;
+ font-weight: 600;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .under-title-div,
+ .over-title-div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+
+ .link-div {
+ display: flex;
+ justify-content: right;
+ align-items: center;
+ text-decoration-line: none;
+
+ font-size: 14px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .link-span {
+ font-size: 12px;
+ font-weight: 300;
+ color: ${({ theme }) => theme.color.gray500};
+ }
+`; | Unknown | ์ฌ๊ธฐ๋ ์ด ํ์ด์ง์์ ๊ฑฐ์ ๋ฉ์ธ ๊ธ ์ ๋ชฉ์ธ ๊ฒ ๊ฐ์๋ฐ `<h1 />` ํ๊ทธ ์ ๋๋ก ์ฌ์ฉํ๋ฉด ์ด๋จ๊น์~?
์๋๋ ๋ ํผ๋ฐ์ค์ฉ [ํ์ด์ค๋ถ] ์ ๋ฉค๋ฒ ์์ธ ํ์ด์ง์ธ๋ฐ ์๋น์ค ์ ๋ชฉ (์ ํฌ๋ก ์น๋ฉด '์ฉ์ฉ๋ํ') ์ `<h2/>` ํ๊ทธ, ์ ์ ์ด๋ฆ์ `<h1/>` ์ผ๋ก ์ฌ์ฉํ ๊ฒ ๊ฐ์ต๋๋ค.
์ ํฌ๋ ์คํ๋ ค ์๋จ navbar ์์ [์ฉ์ฉ๋ํ] ์ `<h2 />` ๋ก ๋ฐ๊พธ๊ณ ๋ง์ง์ด๋ ๋จ์ฒด ์์ธ ํ์ด์ง์์ ๋ง์ง์ด๋ฆ, ๋จ์ฒด์ด๋ฆ์ `<h1/>` ์ ๋ฃ์ผ๋ฉด semantic tagging ๋ฟ๋ง ์๋๋ผ SEO ์๋ ๋์์ด ๋ ๊ฒ ๊ฐ์ต๋๋ค!
cc. @hoon5083

 |
@@ -0,0 +1,85 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Button from "components/button/Button";
+
+interface Props {
+ imgSrcList: string[];
+}
+
+const RestaurantDetailImgSection: React.FC<Props> = ({ imgSrcList }) => {
+ const [currentImgIndex, setCurrentImgIndex] = useState(0);
+
+ const handleOnClickRight = () => {
+ setCurrentImgIndex((currentImgIndex) =>
+ currentImgIndex == imgSrcList.length - 1 ? 0 : currentImgIndex + 1
+ );
+ };
+
+ const handleOnClickLeft = () => {
+ setCurrentImgIndex((currentImgIndex) =>
+ currentImgIndex == 0 ? imgSrcList.length - 1 : currentImgIndex - 1
+ );
+ };
+
+ return (
+ <EmotionWrapper>
+ {imgSrcList.length === 0 ? (
+ <Image
+ className="restaurant-img"
+ alt="๋ง์ง ๊ธฐ๋ณธ ์ด๋ฏธ์ง"
+ src={"/images/defaults/default-restaurant-image.png"}
+ fill
+ />
+ ) : (
+ <Image
+ className="restaurant-img"
+ alt="๋ง์ง ์ด๋ฏธ์ง"
+ src={imgSrcList[currentImgIndex]}
+ fill
+ />
+ )}
+ <Button
+ onClick={handleOnClickLeft}
+ variant="text"
+ style={{
+ backgroundColor: "transparent",
+ zIndex: "10",
+ position: "absolute",
+ left: "0px",
+ }}
+ >
+ <
+ </Button>
+ <Button
+ onClick={handleOnClickRight}
+ variant="text"
+ className="right-button"
+ style={{
+ backgroundColor: "transparent",
+ zIndex: "10",
+ position: "absolute",
+ right: "0px",
+ }}
+ >
+ >
+ </Button>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantDetailImgSection;
+
+const EmotionWrapper = styled.div`
+ position: relative;
+ width: 100%;
+ height: 120px;
+ overflow: hidden;
+ margin-bottom: 10px;
+
+ .restaurant-img {
+ z-index: 1;
+ object-fit: cover;
+ position: absolute;
+ }
+`; | Unknown | ํน์ ์ด ๋ฒํผ์ ํ๋ฉด์์ ์ด๋ ๋ถ๋ถ์ธ๊ฐ์ฉ~?
๋ก์ปฌ์์ ๋๋ ธ์ ๋ ๋
ธ์ถ๋์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค!
 |
@@ -0,0 +1,70 @@
+import styled from "@emotion/styled";
+import RestaurantDetailImgSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailImgSection";
+import RestaurantDetailHeaderSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailHeaderSection";
+import RestaurantDetailInfoSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailInfoSection";
+import RestaurantDetailReviewSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailReviewSection";
+import Divider from "components/divider/Divider";
+import { restaurant } from "feature/restaurants/restaurantsDetail/mockups/restaurant";
+import { reviewPage1 } from "feature/restaurants/restaurantsDetail/mockups/reviews";
+
+interface Props {
+ restaurantId: string;
+}
+
+const ViewRestaurantDetail: React.FC<Props> = ({ restaurantId }) => {
+ /**
+ * TODO 1: ์ฌ์ฉ์ ๊ถํ ๋ถ๋ฌ์ค๊ธฐ
+ */
+ const userAuth = 0;
+
+ /**
+ * TODO 2: ๋ง์ง ์์ธ ์ ๋ณด ๋ถ๋ฌ์ค๊ธฐ
+ */
+
+ /**
+ * TODO3: ๋ง์ง์ ๋ชจ๋ ๋ฆฌ๋ทฐ ์กฐํํ๊ธฐ
+ * - totalScore, totalPages ํ์ธํ๊ธฐ ์ํ Read Reviews API ํธ์ถ
+ * - ๋ฆฌ๋ทฐ๊ฐ ์๋ ๊ฒฝ์ฐ 404 ์๋ฌ ๋ฐํ?
+ */
+ const { totalScore, totalCount, totalPages, scoreStatistics } = reviewPage1;
+
+ return (
+ <EmotionWrapper>
+ <RestaurantDetailImgSection imgSrcList={restaurant.imgSrcList} />
+ <RestaurantDetailHeaderSection
+ restaurantId={restaurantId}
+ userAuth={userAuth}
+ restaurantName={restaurant.name}
+ restaurantAddress={restaurant.address}
+ organizationName={restaurant.organizationName}
+ link={restaurant.link}
+ />
+ <RestaurantDetailInfoSection
+ restaurantId={restaurantId}
+ comment={restaurant.comment}
+ orderTip={restaurant.orderTip}
+ capacity={restaurant.capacity}
+ recommendedMenus={restaurant.recommnededMenus}
+ category={restaurant.category}
+ delivery={restaurant.delivery}
+ openingHour={restaurant.openingHour}
+ tags={restaurant.tags}
+ totalScore={totalScore}
+ totalCount={totalCount}
+ />
+ <Divider />
+ <RestaurantDetailReviewSection
+ restaurantId={restaurantId}
+ userAuth={userAuth}
+ totalScore={totalScore}
+ totalCount={totalCount}
+ totalPages={totalPages}
+ scoreStatistics={scoreStatistics}
+ />
+ </EmotionWrapper>
+ );
+};
+
+export default ViewRestaurantDetail;
+
+const EmotionWrapper = styled.div``; | Unknown | ์์ ์ฝ๋์ธ๊ฐ์!?
๊ฐ์ฒด๊ตฌ์กฐ ๋ถํด๋ก ๋ฐ์์ค๋ ๊ฒ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค!
```tsx
const { totalScore, totalCount, totalPages, scoreStatistics } = reviewPage1
``` |
@@ -0,0 +1,137 @@
+import styled from "@emotion/styled";
+import Rating from "components/rating/Rating";
+import RestaurantDetailHeaderSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailHeaderSection";
+import Button from "components/button/Button";
+import TextInput from "components/inputs/TextInput/TextInput";
+import { useState, useCallback } from "react";
+import Checkbox from "components/checkbox/Checkbox";
+import { REVIEW_CONTENT_MAX_VALUE, REVIEW_CONTENT_MIN_VALUE } from "constant/limit";
+
+interface Props {
+ restaurantId: string;
+ isEditMode: boolean;
+ reviewId?: string | number | string[];
+ score?: number;
+ content?: string;
+}
+
+const RestaurantsReviewForm: React.FC<Props> = ({ restaurantId, score = 0, content = "" }) => {
+ const [selectedScroe, setSelectedScore] = useState<number>(score);
+ const [enteredContent, setEnteredContent] = useState<string>(content);
+ const [isPublic, setIsPublic] = useState<boolean>(true);
+
+ /**
+ * TODO: restaurantId๋ก ๋ง์ง ์์ธ์ ๋ณด ๋ถ๋ฌ์ค๊ธฐ
+ */
+
+ const contentMaxLengthCheck = {
+ condition: (content: string) => {
+ return content.length <= REVIEW_CONTENT_MAX_VALUE;
+ },
+ messageOnError: "500์ ์ด๋ด๋ก ์์ฑํด์ฃผ์ธ์.",
+ };
+
+ const contentMinLengthCheck = {
+ condition: (content: string) => {
+ return content.length >= REVIEW_CONTENT_MIN_VALUE;
+ },
+ messageOnError: "20์ ์ด์ ์์ฑํด์ฃผ์ธ์.",
+ };
+
+ const handleScoreChange = useCallback((value: number) => {
+ setSelectedScore(value);
+ }, []);
+
+ const handleContentChange = useCallback((value: string) => {
+ setEnteredContent(value);
+ }, []);
+
+ const handleSetIsPublic = useCallback((value: string) => {
+ if (value === "true") setIsPublic(true);
+ else setIsPublic(false);
+ }, []);
+
+ const handleOnSubmit = () => {
+ console.log("์ ์ : ", selectedScroe);
+ console.log("๋ฆฌ๋ทฐ ๋ด์ฉ : ", enteredContent);
+ console.log("๊ณต๊ฐ ์ฌ๋ถ : ", isPublic);
+ };
+
+ return (
+ <EmotionWrapper>
+ <RestaurantDetailHeaderSection
+ restaurantId={restaurantId}
+ restaurantName="๋ด์์ก"
+ restaurantAddress="๊ฒฝ๊ธฐ๋ ์์์ ์ฒ์ฒ๋"
+ organizationName="์์คํ
์ปจ์คํดํธ ๊ทธ๋ฃน"
+ isMain={false}
+ />
+ <Rating value={score} isInput onSelectedValueChange={handleScoreChange} />
+ <TextInput
+ label="๋ฆฌ๋ทฐ ๋ด์ฉ"
+ placeholder="๋ง์ง์ ๋ํ ์์งํ ํ์ ์์ฑํด์ฃผ์ธ์!"
+ multiline
+ value={content}
+ onTextChange={handleContentChange}
+ conditionCheckList={[contentMaxLengthCheck, contentMinLengthCheck]}
+ height="150px"
+ />
+ <div className="right-alignment">
+ <p className="label">๋ฆฌ๋ทฐ ๊ณต๊ฐ ์ฌ๋ถ๋ฅผ ์ค์ ํด์ฃผ์ธ์.</p>
+ <Checkbox.Group
+ checkedList={[String(isPublic)]}
+ setCheckedItem={(value) => handleSetIsPublic(value)}
+ >
+ <Checkbox.Item value="true">๊ณต๊ฐ</Checkbox.Item>
+ <Checkbox.Item value="false">๋น๊ณต๊ฐ</Checkbox.Item>
+ </Checkbox.Group>
+ {!isPublic && (
+ <p className="description">๋น๊ณต๊ฐ๋ก ์ค์ ์, ๋จ์ฒด ์ธ๋ถ์ธ์๊ฒ๋ ๋ฆฌ๋ทฐ๊ฐ ๋ณด์ด์ง ์์ต๋๋ค.</p>
+ )}
+ </div>
+ <Button onClick={handleOnSubmit} fullWidth>
+ ์์ฑ ์๋ฃ
+ </Button>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantsReviewForm;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ gap: 30px;
+
+ textarea {
+ font-size: 16px;
+ }
+
+ button {
+ font-size: 16px;
+ }
+
+ .right-alignment {
+ margin-top: -15px;
+ width: 100%;
+ }
+
+ .label {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ margin-left: 2px;
+ font-weight: 500;
+ font-size: 16px;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+
+ .description {
+ margin-top: 5px;
+ margin-left: 2px;
+ font-size: 14px;
+ font-weight: 200;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+`; | Unknown | ์คํ๊ฐ ์๋ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,137 @@
+import styled from "@emotion/styled";
+import Rating from "components/rating/Rating";
+import RestaurantDetailHeaderSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailHeaderSection";
+import Button from "components/button/Button";
+import TextInput from "components/inputs/TextInput/TextInput";
+import { useState, useCallback } from "react";
+import Checkbox from "components/checkbox/Checkbox";
+import { REVIEW_CONTENT_MAX_VALUE, REVIEW_CONTENT_MIN_VALUE } from "constant/limit";
+
+interface Props {
+ restaurantId: string;
+ isEditMode: boolean;
+ reviewId?: string | number | string[];
+ score?: number;
+ content?: string;
+}
+
+const RestaurantsReviewForm: React.FC<Props> = ({ restaurantId, score = 0, content = "" }) => {
+ const [selectedScroe, setSelectedScore] = useState<number>(score);
+ const [enteredContent, setEnteredContent] = useState<string>(content);
+ const [isPublic, setIsPublic] = useState<boolean>(true);
+
+ /**
+ * TODO: restaurantId๋ก ๋ง์ง ์์ธ์ ๋ณด ๋ถ๋ฌ์ค๊ธฐ
+ */
+
+ const contentMaxLengthCheck = {
+ condition: (content: string) => {
+ return content.length <= REVIEW_CONTENT_MAX_VALUE;
+ },
+ messageOnError: "500์ ์ด๋ด๋ก ์์ฑํด์ฃผ์ธ์.",
+ };
+
+ const contentMinLengthCheck = {
+ condition: (content: string) => {
+ return content.length >= REVIEW_CONTENT_MIN_VALUE;
+ },
+ messageOnError: "20์ ์ด์ ์์ฑํด์ฃผ์ธ์.",
+ };
+
+ const handleScoreChange = useCallback((value: number) => {
+ setSelectedScore(value);
+ }, []);
+
+ const handleContentChange = useCallback((value: string) => {
+ setEnteredContent(value);
+ }, []);
+
+ const handleSetIsPublic = useCallback((value: string) => {
+ if (value === "true") setIsPublic(true);
+ else setIsPublic(false);
+ }, []);
+
+ const handleOnSubmit = () => {
+ console.log("์ ์ : ", selectedScroe);
+ console.log("๋ฆฌ๋ทฐ ๋ด์ฉ : ", enteredContent);
+ console.log("๊ณต๊ฐ ์ฌ๋ถ : ", isPublic);
+ };
+
+ return (
+ <EmotionWrapper>
+ <RestaurantDetailHeaderSection
+ restaurantId={restaurantId}
+ restaurantName="๋ด์์ก"
+ restaurantAddress="๊ฒฝ๊ธฐ๋ ์์์ ์ฒ์ฒ๋"
+ organizationName="์์คํ
์ปจ์คํดํธ ๊ทธ๋ฃน"
+ isMain={false}
+ />
+ <Rating value={score} isInput onSelectedValueChange={handleScoreChange} />
+ <TextInput
+ label="๋ฆฌ๋ทฐ ๋ด์ฉ"
+ placeholder="๋ง์ง์ ๋ํ ์์งํ ํ์ ์์ฑํด์ฃผ์ธ์!"
+ multiline
+ value={content}
+ onTextChange={handleContentChange}
+ conditionCheckList={[contentMaxLengthCheck, contentMinLengthCheck]}
+ height="150px"
+ />
+ <div className="right-alignment">
+ <p className="label">๋ฆฌ๋ทฐ ๊ณต๊ฐ ์ฌ๋ถ๋ฅผ ์ค์ ํด์ฃผ์ธ์.</p>
+ <Checkbox.Group
+ checkedList={[String(isPublic)]}
+ setCheckedItem={(value) => handleSetIsPublic(value)}
+ >
+ <Checkbox.Item value="true">๊ณต๊ฐ</Checkbox.Item>
+ <Checkbox.Item value="false">๋น๊ณต๊ฐ</Checkbox.Item>
+ </Checkbox.Group>
+ {!isPublic && (
+ <p className="description">๋น๊ณต๊ฐ๋ก ์ค์ ์, ๋จ์ฒด ์ธ๋ถ์ธ์๊ฒ๋ ๋ฆฌ๋ทฐ๊ฐ ๋ณด์ด์ง ์์ต๋๋ค.</p>
+ )}
+ </div>
+ <Button onClick={handleOnSubmit} fullWidth>
+ ์์ฑ ์๋ฃ
+ </Button>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantsReviewForm;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ gap: 30px;
+
+ textarea {
+ font-size: 16px;
+ }
+
+ button {
+ font-size: 16px;
+ }
+
+ .right-alignment {
+ margin-top: -15px;
+ width: 100%;
+ }
+
+ .label {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ margin-left: 2px;
+ font-weight: 500;
+ font-size: 16px;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+
+ .description {
+ margin-top: 5px;
+ margin-left: 2px;
+ font-size: 14px;
+ font-weight: 200;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+`; | Unknown | ์ ๊ฐ์ `src/constant/limit.ts` ์์ ๊ด๋ฆฌํด์ฃผ๋ ๊ฒ์ ์ด๋จ๊น์~?
ํ๋์ ํ์ผ์์ ๊ฐ ์ต๋๊ธธ์ด๋ ์ต์๊ธธ์ด ์กฐ๊ฑด ๋ฑ์ ๊ด๋ฆฌํด์ฃผ๋ฉด ๋์ค์ ์ด๋ฅผ ์ฆ๊ฐ ๋๋ ๊ฐ์์ํฌ ์ผ์ด ์์ ๋ ๋์ํ๊ธฐ ์ฉ์ดํ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,18 @@
+import styled from "@emotion/styled";
+import RestaurantsReviewForm from "feature/restaurants/restaurantsReview/components/form/RestaurantsReviewForm";
+
+interface Props {
+ restaurantId: string;
+}
+
+const ViewRestaurantReviewCreate: React.FC<Props> = ({ restaurantId }) => {
+ return (
+ <EmotionWrapper>
+ <RestaurantsReviewForm restaurantId={restaurantId} isEditMode={false} />
+ </EmotionWrapper>
+ );
+};
+
+export default ViewRestaurantReviewCreate;
+
+const EmotionWrapper = styled.div``; | Unknown | ์ฌ๊ธฐ์๋ `string []` ์ ํน๋ณํ ์ถ๊ฐํด์ฃผ์ ์ด์ ๊ฐ ์์๊น์~? |
@@ -0,0 +1,170 @@
+import styled from "@emotion/styled";
+import IconStarFilled from "components/rating/icons/IconStarFilled";
+import IconStarHalf from "components/rating/icons/IconStarHalf";
+import IconStarOutlined from "components/rating/icons/IconStarOutlined";
+import { HTMLAttributes, useEffect, useState, useRef, useCallback } from "react";
+
+interface Props extends HTMLAttributes<HTMLDivElement> {
+ value: number; // 0 ~ 5 ์ฌ์ด์ ์ซ์, ๋ณ ๊ฐ์๋ ๊ฐ์ฅ ๊ฐ๊น์ด 0.5 ๋จ์๋ก ๋ฐ์ฌ๋ฆผ
+ isInput?: boolean; // input ๊ธฐ๋ฅ์ ํ๋๋ก ํ ์ง ์ค์
+ onSelectedValueChange?: (value: number) => void;
+}
+
+const Rating = ({ value, isInput = false, onSelectedValueChange, ...props }: Props) => {
+ const [selectedValue, setSelectedValue] = useState<number>(value);
+ const isMouseDown = useRef<boolean>(false);
+ const containerRef = useRef<HTMLDivElement>(null);
+
+ // round value to the nearest 0.5
+ const startCount = Math.round(selectedValue * 2) / 2;
+
+ const filledStarCount = Math.floor(startCount);
+ const hasHalfStar = startCount % 1 !== 0;
+ const emptyStarCount = 5 - filledStarCount - (hasHalfStar ? 1 : 0);
+
+ useEffect(() => {
+ if (onSelectedValueChange) {
+ onSelectedValueChange(selectedValue);
+ }
+ }, [selectedValue, onSelectedValueChange]);
+
+ const handleOnClick = (event: React.MouseEvent, index: number) => {
+ const clickX = event.nativeEvent.clientX; // ํด๋ฆญํ ์์น์ X ์ขํ
+
+ // IconStar... ์ปดํฌ๋ํธ ๋ด์์ ํด๋ฆญํ ์์น๋ฅผ ๊ธฐ์ค์ผ๋ก ์ผ์ชฝ ๋๋ ์ค๋ฅธ์ชฝ ํ๋ณ
+ const containerRect = event.currentTarget.getBoundingClientRect();
+ const containerCenterX = (containerRect.left + containerRect.right) / 2;
+
+ if (clickX < containerCenterX) {
+ setSelectedValue(index + 0.5);
+ } else {
+ setSelectedValue(index + 1);
+ }
+ };
+
+ const calculateScore = useCallback((currentX: number) => {
+ const container = containerRef.current;
+ if (container) {
+ const unitSize = container.getBoundingClientRect().width / 10;
+ const relativeX = currentX - container.getBoundingClientRect().x;
+ if (relativeX <= 0) setSelectedValue(0.5);
+ else {
+ const score = (Math.floor(relativeX / unitSize) + 1) * 0.5;
+ score > 5 ? setSelectedValue(5) : setSelectedValue(score);
+ }
+ }
+ }, []);
+
+ const handleOnMouseDown = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
+ isMouseDown.current = true;
+ }, []);
+
+ const handleOnMouseLeave = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
+ isMouseDown.current = false;
+ }, []);
+
+ const handleOnMouseMove = useCallback(
+ (event: React.MouseEvent) => {
+ if (isMouseDown.current) calculateScore(event.clientX);
+ },
+ [calculateScore]
+ );
+
+ const handleOnMouseUp = useCallback((event: React.MouseEvent) => {
+ isMouseDown.current = false;
+ }, []);
+
+ // For mobile view
+ const handleOnTouchMove = useCallback(
+ (event: React.TouchEvent) => {
+ calculateScore(event.changedTouches[0].clientX);
+ },
+ [calculateScore]
+ );
+
+ return (
+ <EmotionWrapper isInput={isInput} {...props}>
+ <div
+ className="star-container"
+ onMouseDown={handleOnMouseDown}
+ onMouseUp={handleOnMouseUp}
+ onMouseMove={handleOnMouseMove}
+ onMouseLeave={handleOnMouseLeave}
+ onTouchMove={handleOnTouchMove}
+ ref={containerRef}
+ >
+ {Array.from({ length: filledStarCount }, (_, index) =>
+ isInput ? (
+ <IconStarFilled
+ key={index}
+ size={40}
+ onClick={(event: React.MouseEvent) => handleOnClick(event, index)}
+ />
+ ) : (
+ <IconStarFilled key={index} />
+ )
+ )}
+ {hasHalfStar &&
+ (isInput ? (
+ <IconStarHalf
+ size={40}
+ onClick={(event: React.MouseEvent) => handleOnClick(event, filledStarCount)}
+ />
+ ) : (
+ <IconStarHalf />
+ ))}
+ {Array.from({ length: emptyStarCount }, (_, index) =>
+ isInput ? (
+ <IconStarOutlined
+ key={index}
+ size={40}
+ onClick={(event: React.MouseEvent) =>
+ handleOnClick(event, filledStarCount + index + (hasHalfStar ? 1 : 0))
+ }
+ />
+ ) : (
+ <IconStarOutlined key={index} />
+ )
+ )}
+ </div>
+ {isInput ? (
+ <div>
+ <span className="rating-value-selected">{selectedValue}</span>
+ <span className="rating-full-marks"> / 5</span>
+ </div>
+ ) : (
+ <p className="rating-value">{value}</p>
+ )}
+ </EmotionWrapper>
+ );
+};
+
+export default Rating;
+
+const EmotionWrapper = styled.div<{ isInput: boolean }>`
+ display: flex;
+ align-items: center;
+ ${({ isInput }) => (isInput ? "flex-direction: column; gap: 20px;" : "column-gap: 4px;")}
+
+ .star-container {
+ display: flex;
+ column-gap: 2px;
+ }
+
+ color: ${({ theme }) => theme.color.gray400};
+
+ .rating-full-marks {
+ font-size: 16px;
+ font-weight: 300;
+ }
+
+ .rating-value-selected {
+ font-size: 32px;
+ font-weight: 500;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .rating-value {
+ font-size: 12px;
+ }
+`; | Unknown | ๋ต ๋ง์ต๋๋ค..! |
@@ -0,0 +1,85 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Button from "components/button/Button";
+
+interface Props {
+ imgSrcList: string[];
+}
+
+const RestaurantDetailImgSection: React.FC<Props> = ({ imgSrcList }) => {
+ const [currentImgIndex, setCurrentImgIndex] = useState(0);
+
+ const handleOnClickRight = () => {
+ setCurrentImgIndex((currentImgIndex) =>
+ currentImgIndex == imgSrcList.length - 1 ? 0 : currentImgIndex + 1
+ );
+ };
+
+ const handleOnClickLeft = () => {
+ setCurrentImgIndex((currentImgIndex) =>
+ currentImgIndex == 0 ? imgSrcList.length - 1 : currentImgIndex - 1
+ );
+ };
+
+ return (
+ <EmotionWrapper>
+ {imgSrcList.length === 0 ? (
+ <Image
+ className="restaurant-img"
+ alt="๋ง์ง ๊ธฐ๋ณธ ์ด๋ฏธ์ง"
+ src={"/images/defaults/default-restaurant-image.png"}
+ fill
+ />
+ ) : (
+ <Image
+ className="restaurant-img"
+ alt="๋ง์ง ์ด๋ฏธ์ง"
+ src={imgSrcList[currentImgIndex]}
+ fill
+ />
+ )}
+ <Button
+ onClick={handleOnClickLeft}
+ variant="text"
+ style={{
+ backgroundColor: "transparent",
+ zIndex: "10",
+ position: "absolute",
+ left: "0px",
+ }}
+ >
+ <
+ </Button>
+ <Button
+ onClick={handleOnClickRight}
+ variant="text"
+ className="right-button"
+ style={{
+ backgroundColor: "transparent",
+ zIndex: "10",
+ position: "absolute",
+ right: "0px",
+ }}
+ >
+ >
+ </Button>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantDetailImgSection;
+
+const EmotionWrapper = styled.div`
+ position: relative;
+ width: 100%;
+ height: 120px;
+ overflow: hidden;
+ margin-bottom: 10px;
+
+ .restaurant-img {
+ z-index: 1;
+ object-fit: cover;
+ position: absolute;
+ }
+`; | Unknown | ์ ์ด๋ฏธ์ง ์ฌ๋ผ์ด๋๋ฅผ ๊ตฌํํ๋ ค๋ค๊ฐ ์ผ๋จ PR๋ถํฐ ์ฌ๋ ธ๋๋ฐ, ํด๋น ๋ฒํผ์ ๊ทธ ๊ณผ์ ์์ ์๊ธด ๋ณ ์๋ฏธ ์๋ ๋ฒํผ์
๋๋ค.. ์ญ์ ํ๋๋ก ํ๊ฒ ์ต๋๋ค! |
@@ -0,0 +1,70 @@
+import styled from "@emotion/styled";
+import RestaurantDetailImgSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailImgSection";
+import RestaurantDetailHeaderSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailHeaderSection";
+import RestaurantDetailInfoSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailInfoSection";
+import RestaurantDetailReviewSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailReviewSection";
+import Divider from "components/divider/Divider";
+import { restaurant } from "feature/restaurants/restaurantsDetail/mockups/restaurant";
+import { reviewPage1 } from "feature/restaurants/restaurantsDetail/mockups/reviews";
+
+interface Props {
+ restaurantId: string;
+}
+
+const ViewRestaurantDetail: React.FC<Props> = ({ restaurantId }) => {
+ /**
+ * TODO 1: ์ฌ์ฉ์ ๊ถํ ๋ถ๋ฌ์ค๊ธฐ
+ */
+ const userAuth = 0;
+
+ /**
+ * TODO 2: ๋ง์ง ์์ธ ์ ๋ณด ๋ถ๋ฌ์ค๊ธฐ
+ */
+
+ /**
+ * TODO3: ๋ง์ง์ ๋ชจ๋ ๋ฆฌ๋ทฐ ์กฐํํ๊ธฐ
+ * - totalScore, totalPages ํ์ธํ๊ธฐ ์ํ Read Reviews API ํธ์ถ
+ * - ๋ฆฌ๋ทฐ๊ฐ ์๋ ๊ฒฝ์ฐ 404 ์๋ฌ ๋ฐํ?
+ */
+ const { totalScore, totalCount, totalPages, scoreStatistics } = reviewPage1;
+
+ return (
+ <EmotionWrapper>
+ <RestaurantDetailImgSection imgSrcList={restaurant.imgSrcList} />
+ <RestaurantDetailHeaderSection
+ restaurantId={restaurantId}
+ userAuth={userAuth}
+ restaurantName={restaurant.name}
+ restaurantAddress={restaurant.address}
+ organizationName={restaurant.organizationName}
+ link={restaurant.link}
+ />
+ <RestaurantDetailInfoSection
+ restaurantId={restaurantId}
+ comment={restaurant.comment}
+ orderTip={restaurant.orderTip}
+ capacity={restaurant.capacity}
+ recommendedMenus={restaurant.recommnededMenus}
+ category={restaurant.category}
+ delivery={restaurant.delivery}
+ openingHour={restaurant.openingHour}
+ tags={restaurant.tags}
+ totalScore={totalScore}
+ totalCount={totalCount}
+ />
+ <Divider />
+ <RestaurantDetailReviewSection
+ restaurantId={restaurantId}
+ userAuth={userAuth}
+ totalScore={totalScore}
+ totalCount={totalCount}
+ totalPages={totalPages}
+ scoreStatistics={scoreStatistics}
+ />
+ </EmotionWrapper>
+ );
+};
+
+export default ViewRestaurantDetail;
+
+const EmotionWrapper = styled.div``; | Unknown | ํ์ธ ๊ฐ์ฌํฉ๋๋ค. ์์ ํ์ต๋๋ค! |
@@ -0,0 +1,137 @@
+import styled from "@emotion/styled";
+import Rating from "components/rating/Rating";
+import RestaurantDetailHeaderSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailHeaderSection";
+import Button from "components/button/Button";
+import TextInput from "components/inputs/TextInput/TextInput";
+import { useState, useCallback } from "react";
+import Checkbox from "components/checkbox/Checkbox";
+import { REVIEW_CONTENT_MAX_VALUE, REVIEW_CONTENT_MIN_VALUE } from "constant/limit";
+
+interface Props {
+ restaurantId: string;
+ isEditMode: boolean;
+ reviewId?: string | number | string[];
+ score?: number;
+ content?: string;
+}
+
+const RestaurantsReviewForm: React.FC<Props> = ({ restaurantId, score = 0, content = "" }) => {
+ const [selectedScroe, setSelectedScore] = useState<number>(score);
+ const [enteredContent, setEnteredContent] = useState<string>(content);
+ const [isPublic, setIsPublic] = useState<boolean>(true);
+
+ /**
+ * TODO: restaurantId๋ก ๋ง์ง ์์ธ์ ๋ณด ๋ถ๋ฌ์ค๊ธฐ
+ */
+
+ const contentMaxLengthCheck = {
+ condition: (content: string) => {
+ return content.length <= REVIEW_CONTENT_MAX_VALUE;
+ },
+ messageOnError: "500์ ์ด๋ด๋ก ์์ฑํด์ฃผ์ธ์.",
+ };
+
+ const contentMinLengthCheck = {
+ condition: (content: string) => {
+ return content.length >= REVIEW_CONTENT_MIN_VALUE;
+ },
+ messageOnError: "20์ ์ด์ ์์ฑํด์ฃผ์ธ์.",
+ };
+
+ const handleScoreChange = useCallback((value: number) => {
+ setSelectedScore(value);
+ }, []);
+
+ const handleContentChange = useCallback((value: string) => {
+ setEnteredContent(value);
+ }, []);
+
+ const handleSetIsPublic = useCallback((value: string) => {
+ if (value === "true") setIsPublic(true);
+ else setIsPublic(false);
+ }, []);
+
+ const handleOnSubmit = () => {
+ console.log("์ ์ : ", selectedScroe);
+ console.log("๋ฆฌ๋ทฐ ๋ด์ฉ : ", enteredContent);
+ console.log("๊ณต๊ฐ ์ฌ๋ถ : ", isPublic);
+ };
+
+ return (
+ <EmotionWrapper>
+ <RestaurantDetailHeaderSection
+ restaurantId={restaurantId}
+ restaurantName="๋ด์์ก"
+ restaurantAddress="๊ฒฝ๊ธฐ๋ ์์์ ์ฒ์ฒ๋"
+ organizationName="์์คํ
์ปจ์คํดํธ ๊ทธ๋ฃน"
+ isMain={false}
+ />
+ <Rating value={score} isInput onSelectedValueChange={handleScoreChange} />
+ <TextInput
+ label="๋ฆฌ๋ทฐ ๋ด์ฉ"
+ placeholder="๋ง์ง์ ๋ํ ์์งํ ํ์ ์์ฑํด์ฃผ์ธ์!"
+ multiline
+ value={content}
+ onTextChange={handleContentChange}
+ conditionCheckList={[contentMaxLengthCheck, contentMinLengthCheck]}
+ height="150px"
+ />
+ <div className="right-alignment">
+ <p className="label">๋ฆฌ๋ทฐ ๊ณต๊ฐ ์ฌ๋ถ๋ฅผ ์ค์ ํด์ฃผ์ธ์.</p>
+ <Checkbox.Group
+ checkedList={[String(isPublic)]}
+ setCheckedItem={(value) => handleSetIsPublic(value)}
+ >
+ <Checkbox.Item value="true">๊ณต๊ฐ</Checkbox.Item>
+ <Checkbox.Item value="false">๋น๊ณต๊ฐ</Checkbox.Item>
+ </Checkbox.Group>
+ {!isPublic && (
+ <p className="description">๋น๊ณต๊ฐ๋ก ์ค์ ์, ๋จ์ฒด ์ธ๋ถ์ธ์๊ฒ๋ ๋ฆฌ๋ทฐ๊ฐ ๋ณด์ด์ง ์์ต๋๋ค.</p>
+ )}
+ </div>
+ <Button onClick={handleOnSubmit} fullWidth>
+ ์์ฑ ์๋ฃ
+ </Button>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantsReviewForm;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ gap: 30px;
+
+ textarea {
+ font-size: 16px;
+ }
+
+ button {
+ font-size: 16px;
+ }
+
+ .right-alignment {
+ margin-top: -15px;
+ width: 100%;
+ }
+
+ .label {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ margin-left: 2px;
+ font-weight: 500;
+ font-size: 16px;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+
+ .description {
+ margin-top: 5px;
+ margin-left: 2px;
+ font-size: 14px;
+ font-weight: 200;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+`; | Unknown | ๋ฐ๊ฒฌ ๊ฐ์ฌํฉ๋๋ค! ์์ ํ์ต๋๋ค. |
@@ -0,0 +1,137 @@
+import styled from "@emotion/styled";
+import Rating from "components/rating/Rating";
+import RestaurantDetailHeaderSection from "feature/restaurants/restaurantsDetail/components/section/RestaurantDetailHeaderSection";
+import Button from "components/button/Button";
+import TextInput from "components/inputs/TextInput/TextInput";
+import { useState, useCallback } from "react";
+import Checkbox from "components/checkbox/Checkbox";
+import { REVIEW_CONTENT_MAX_VALUE, REVIEW_CONTENT_MIN_VALUE } from "constant/limit";
+
+interface Props {
+ restaurantId: string;
+ isEditMode: boolean;
+ reviewId?: string | number | string[];
+ score?: number;
+ content?: string;
+}
+
+const RestaurantsReviewForm: React.FC<Props> = ({ restaurantId, score = 0, content = "" }) => {
+ const [selectedScroe, setSelectedScore] = useState<number>(score);
+ const [enteredContent, setEnteredContent] = useState<string>(content);
+ const [isPublic, setIsPublic] = useState<boolean>(true);
+
+ /**
+ * TODO: restaurantId๋ก ๋ง์ง ์์ธ์ ๋ณด ๋ถ๋ฌ์ค๊ธฐ
+ */
+
+ const contentMaxLengthCheck = {
+ condition: (content: string) => {
+ return content.length <= REVIEW_CONTENT_MAX_VALUE;
+ },
+ messageOnError: "500์ ์ด๋ด๋ก ์์ฑํด์ฃผ์ธ์.",
+ };
+
+ const contentMinLengthCheck = {
+ condition: (content: string) => {
+ return content.length >= REVIEW_CONTENT_MIN_VALUE;
+ },
+ messageOnError: "20์ ์ด์ ์์ฑํด์ฃผ์ธ์.",
+ };
+
+ const handleScoreChange = useCallback((value: number) => {
+ setSelectedScore(value);
+ }, []);
+
+ const handleContentChange = useCallback((value: string) => {
+ setEnteredContent(value);
+ }, []);
+
+ const handleSetIsPublic = useCallback((value: string) => {
+ if (value === "true") setIsPublic(true);
+ else setIsPublic(false);
+ }, []);
+
+ const handleOnSubmit = () => {
+ console.log("์ ์ : ", selectedScroe);
+ console.log("๋ฆฌ๋ทฐ ๋ด์ฉ : ", enteredContent);
+ console.log("๊ณต๊ฐ ์ฌ๋ถ : ", isPublic);
+ };
+
+ return (
+ <EmotionWrapper>
+ <RestaurantDetailHeaderSection
+ restaurantId={restaurantId}
+ restaurantName="๋ด์์ก"
+ restaurantAddress="๊ฒฝ๊ธฐ๋ ์์์ ์ฒ์ฒ๋"
+ organizationName="์์คํ
์ปจ์คํดํธ ๊ทธ๋ฃน"
+ isMain={false}
+ />
+ <Rating value={score} isInput onSelectedValueChange={handleScoreChange} />
+ <TextInput
+ label="๋ฆฌ๋ทฐ ๋ด์ฉ"
+ placeholder="๋ง์ง์ ๋ํ ์์งํ ํ์ ์์ฑํด์ฃผ์ธ์!"
+ multiline
+ value={content}
+ onTextChange={handleContentChange}
+ conditionCheckList={[contentMaxLengthCheck, contentMinLengthCheck]}
+ height="150px"
+ />
+ <div className="right-alignment">
+ <p className="label">๋ฆฌ๋ทฐ ๊ณต๊ฐ ์ฌ๋ถ๋ฅผ ์ค์ ํด์ฃผ์ธ์.</p>
+ <Checkbox.Group
+ checkedList={[String(isPublic)]}
+ setCheckedItem={(value) => handleSetIsPublic(value)}
+ >
+ <Checkbox.Item value="true">๊ณต๊ฐ</Checkbox.Item>
+ <Checkbox.Item value="false">๋น๊ณต๊ฐ</Checkbox.Item>
+ </Checkbox.Group>
+ {!isPublic && (
+ <p className="description">๋น๊ณต๊ฐ๋ก ์ค์ ์, ๋จ์ฒด ์ธ๋ถ์ธ์๊ฒ๋ ๋ฆฌ๋ทฐ๊ฐ ๋ณด์ด์ง ์์ต๋๋ค.</p>
+ )}
+ </div>
+ <Button onClick={handleOnSubmit} fullWidth>
+ ์์ฑ ์๋ฃ
+ </Button>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantsReviewForm;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ gap: 30px;
+
+ textarea {
+ font-size: 16px;
+ }
+
+ button {
+ font-size: 16px;
+ }
+
+ .right-alignment {
+ margin-top: -15px;
+ width: 100%;
+ }
+
+ .label {
+ margin-top: 20px;
+ margin-bottom: 10px;
+ margin-left: 2px;
+ font-weight: 500;
+ font-size: 16px;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+
+ .description {
+ margin-top: 5px;
+ margin-left: 2px;
+ font-size: 14px;
+ font-weight: 200;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+`; | Unknown | ๋ต ์ข์ต๋๋ค! ์์ ํ์ต๋๋ค. |
@@ -0,0 +1,85 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Button from "components/button/Button";
+
+interface Props {
+ imgSrcList: string[];
+}
+
+const RestaurantDetailImgSection: React.FC<Props> = ({ imgSrcList }) => {
+ const [currentImgIndex, setCurrentImgIndex] = useState(0);
+
+ const handleOnClickRight = () => {
+ setCurrentImgIndex((currentImgIndex) =>
+ currentImgIndex == imgSrcList.length - 1 ? 0 : currentImgIndex + 1
+ );
+ };
+
+ const handleOnClickLeft = () => {
+ setCurrentImgIndex((currentImgIndex) =>
+ currentImgIndex == 0 ? imgSrcList.length - 1 : currentImgIndex - 1
+ );
+ };
+
+ return (
+ <EmotionWrapper>
+ {imgSrcList.length === 0 ? (
+ <Image
+ className="restaurant-img"
+ alt="๋ง์ง ๊ธฐ๋ณธ ์ด๋ฏธ์ง"
+ src={"/images/defaults/default-restaurant-image.png"}
+ fill
+ />
+ ) : (
+ <Image
+ className="restaurant-img"
+ alt="๋ง์ง ์ด๋ฏธ์ง"
+ src={imgSrcList[currentImgIndex]}
+ fill
+ />
+ )}
+ <Button
+ onClick={handleOnClickLeft}
+ variant="text"
+ style={{
+ backgroundColor: "transparent",
+ zIndex: "10",
+ position: "absolute",
+ left: "0px",
+ }}
+ >
+ <
+ </Button>
+ <Button
+ onClick={handleOnClickRight}
+ variant="text"
+ className="right-button"
+ style={{
+ backgroundColor: "transparent",
+ zIndex: "10",
+ position: "absolute",
+ right: "0px",
+ }}
+ >
+ >
+ </Button>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantDetailImgSection;
+
+const EmotionWrapper = styled.div`
+ position: relative;
+ width: 100%;
+ height: 120px;
+ overflow: hidden;
+ margin-bottom: 10px;
+
+ .restaurant-img {
+ z-index: 1;
+ object-fit: cover;
+ position: absolute;
+ }
+`; | Unknown | ์ด๋ฏธ์ง ์ฌ๋ผ์ด๋๋ ์์ง ๊ตฌํํ์ง ์์์ง๋ง, ์ผ๋จ ์ด๋ฏธ์ง ์ ํ์ด ๊ฐ๋ฅํ๋๋ก ๋ฒํผ์ ๋ง๋ค์ด๋์์ต๋๋ค! ์ง๊ธ์ ๋ฒํผ ๋ณด์ผ ๊ฒ๋๋ค. |
@@ -0,0 +1,105 @@
+import styled from "@emotion/styled";
+import RestaurantExternalLinkIcon from "feature/restaurants/restaurantsDetail/components/icons/RestaurantExternalLinkIcon";
+import Link from "next/link";
+
+interface Props {
+ restaurantId: string;
+ userAuth?: number;
+ restaurantName: string;
+ restaurantAddress: string;
+ organizationName: string;
+ link?: string;
+ isMain?: boolean;
+}
+
+const RestaurantDetailHeaderSection: React.FC<Props> = ({
+ restaurantId,
+ userAuth,
+ restaurantName,
+ restaurantAddress,
+ organizationName,
+ link,
+ isMain = true,
+}) => {
+ return (
+ <EmotionWrapper>
+ <div className="over-title-div">
+ <span className="subtitle">{organizationName}</span>
+ {isMain &&
+ (userAuth === 0 || userAuth === 1 ? (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/edit"}>
+ ๋ง์ง ์์
+ </Link>
+ ) : (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/copy"}>
+ ๋ง์ง ์์
+ </Link>
+ ))}
+ </div>
+ <h1 className="title">{restaurantName}</h1>
+ <div className="under-title-div">
+ <span className="subtitle">{restaurantAddress}</span>
+ {link && (
+ <Link className="link-div" href={link}>
+ <RestaurantExternalLinkIcon />
+ <span className="link-span">๋ง์ง ์์ธ ์ ๋ณด ></span>
+ </Link>
+ )}
+ </div>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantDetailHeaderSection;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ justify-content: center;
+ align-items: left;
+ gap: 8px;
+
+ span {
+ font-weight: 300;
+ margin-left: 2px;
+ font-size: 16px;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+
+ span.subtitle {
+ font-size: 12px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray300};
+ }
+
+ .title {
+ font-size: 30px;
+ font-weight: 600;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .under-title-div,
+ .over-title-div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+
+ .link-div {
+ display: flex;
+ justify-content: right;
+ align-items: center;
+ text-decoration-line: none;
+
+ font-size: 14px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .link-span {
+ font-size: 12px;
+ font-weight: 300;
+ color: ${({ theme }) => theme.color.gray500};
+ }
+`; | Unknown | ์ค.. ๋ต ๋ค๋ฅธ ํ์ด์ง๋ ๋ฉ์ธ์ด ๋๋ ํ
์คํธ(๋ง์ง ์ด๋ฆ, ๋จ์ฒด ์ด๋ฆ)์ `<h1 />`์ ์ฌ์ฉํ๋๋ก ์์ ํ๊ฒ ์ต๋๋ค.
์ผ๋จ ๋ง์ง ์์ธ ํ์ด์ง์์๋ ๋ง์ง ์ด๋ฆ์ `<h1 />` ํ๊ทธ๋ก ์์ ์๋ฃํ์์ต๋๋ค. |
@@ -0,0 +1,105 @@
+import styled from "@emotion/styled";
+import RestaurantExternalLinkIcon from "feature/restaurants/restaurantsDetail/components/icons/RestaurantExternalLinkIcon";
+import Link from "next/link";
+
+interface Props {
+ restaurantId: string;
+ userAuth?: number;
+ restaurantName: string;
+ restaurantAddress: string;
+ organizationName: string;
+ link?: string;
+ isMain?: boolean;
+}
+
+const RestaurantDetailHeaderSection: React.FC<Props> = ({
+ restaurantId,
+ userAuth,
+ restaurantName,
+ restaurantAddress,
+ organizationName,
+ link,
+ isMain = true,
+}) => {
+ return (
+ <EmotionWrapper>
+ <div className="over-title-div">
+ <span className="subtitle">{organizationName}</span>
+ {isMain &&
+ (userAuth === 0 || userAuth === 1 ? (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/edit"}>
+ ๋ง์ง ์์
+ </Link>
+ ) : (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/copy"}>
+ ๋ง์ง ์์
+ </Link>
+ ))}
+ </div>
+ <h1 className="title">{restaurantName}</h1>
+ <div className="under-title-div">
+ <span className="subtitle">{restaurantAddress}</span>
+ {link && (
+ <Link className="link-div" href={link}>
+ <RestaurantExternalLinkIcon />
+ <span className="link-span">๋ง์ง ์์ธ ์ ๋ณด ></span>
+ </Link>
+ )}
+ </div>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantDetailHeaderSection;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ justify-content: center;
+ align-items: left;
+ gap: 8px;
+
+ span {
+ font-weight: 300;
+ margin-left: 2px;
+ font-size: 16px;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+
+ span.subtitle {
+ font-size: 12px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray300};
+ }
+
+ .title {
+ font-size: 30px;
+ font-weight: 600;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .under-title-div,
+ .over-title-div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+
+ .link-div {
+ display: flex;
+ justify-content: right;
+ align-items: center;
+ text-decoration-line: none;
+
+ font-size: 14px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .link-span {
+ font-size: 12px;
+ font-weight: 300;
+ color: ${({ theme }) => theme.color.gray500};
+ }
+`; | Unknown | className์ ๋ชจ๋ kebab case๋ก ์์ ์๋ฃํ์์ต๋๋ค! |
@@ -0,0 +1,120 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Rating from "components/rating/Rating";
+import IconEditFilledWhite from "components/icons/IconEditFilledWhite";
+import Link from "next/link";
+import dayjs from "dayjs";
+
+interface Props {
+ restaurantId: string;
+ reviewId: number;
+ userId: number;
+ score: number;
+ content: string;
+ createdAt: Date;
+}
+
+const ReviewItem: React.FC<Props> = ({
+ restaurantId,
+ reviewId,
+ userId,
+ score,
+ content,
+ createdAt,
+}) => {
+ const [isExpanded, setIsExpanded] = useState(false);
+
+ const toggleExpansion = () => {
+ setIsExpanded((isExpanded) => !isExpanded);
+ };
+
+ const editLink = `/restaurants/${restaurantId}/review/${reviewId}/edit`;
+ const displayContent =
+ content.length > 100 && !isExpanded ? content.slice(0, 100) + "..." : content;
+
+ /**
+ * TODO 1: userId๋ก userInfo ๋ถ๋ฌ์ค๊ธฐ
+ */
+ const userName = "ํ๊ธธ๋";
+ const ImgSrc = "/images/profile-image-default-1.png";
+
+ /**
+ * TODO 2: ํ์ฌ ๋ก๊ทธ์ธ๋ ์ ์ ์์ด๋ ๊ฐ์ ธ์ค๊ธฐ (๋ฆฌ๋ทฐ ์์ ๊ถํ ํ์ธ์ฉ)
+ */
+ const currentUserId = 1;
+
+ return (
+ <EmotionWrapper>
+ <div className="user-info-score-div">
+ <div className="user-info-div">
+ <Image src={ImgSrc} alt={"์ ์ ํ๋กํ ์ด๋ฏธ์ง"} width={30} height={30} />
+ <span className="user-name">{userName}</span>
+ <span className="date">{dayjs(createdAt).format("YY/MM/DD")}</span>
+ {currentUserId === userId && (
+ <Link href={editLink}>
+ <IconEditFilledWhite />
+ </Link>
+ )}
+ </div>
+ <Rating value={score} />
+ </div>
+ <div className="content-div">
+ <span>{displayContent}</span>
+ {content.length > 100 && (
+ <button onClick={toggleExpansion}>{isExpanded ? "์ ๊ธฐ" : "๋ ๋ณด๊ธฐ"}</button>
+ )}
+ </div>
+ </EmotionWrapper>
+ );
+};
+
+export default ReviewItem;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ min-height: 90px;
+ width: 100%;
+ background-color: ${({ theme }) => theme.color.white};
+ border-radius: 6px;
+
+ padding: 10px;
+
+ .user-info-score-div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .user-info-div {
+ display: flex;
+ gap: 8px;
+ justify-content: center;
+ align-items: center;
+
+ span.user-name {
+ font-size: 16px;
+ font-weight: 600;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+ span.date {
+ font-size: 12px;
+ font-weight: 300;
+ color: ${({ theme }) => theme.color.gray300};
+ }
+ }
+ }
+
+ .content-div {
+ span {
+ line-height: 1.5;
+ color: ${({ theme }) => theme.color.gray400};
+ flex-grow: 1;
+ margin-right: 8px;
+ }
+
+ button {
+ color: ${({ theme }) => theme.color.gray300};
+ }
+ }
+`; | Unknown | className์ ๋ชจ๋ kebab case๋ก ์์ ์๋ฃํ์์ต๋๋ค! |
@@ -0,0 +1,120 @@
+import styled from "@emotion/styled";
+import Image from "next/image";
+import { useState } from "react";
+import Rating from "components/rating/Rating";
+import IconEditFilledWhite from "components/icons/IconEditFilledWhite";
+import Link from "next/link";
+import dayjs from "dayjs";
+
+interface Props {
+ restaurantId: string;
+ reviewId: number;
+ userId: number;
+ score: number;
+ content: string;
+ createdAt: Date;
+}
+
+const ReviewItem: React.FC<Props> = ({
+ restaurantId,
+ reviewId,
+ userId,
+ score,
+ content,
+ createdAt,
+}) => {
+ const [isExpanded, setIsExpanded] = useState(false);
+
+ const toggleExpansion = () => {
+ setIsExpanded((isExpanded) => !isExpanded);
+ };
+
+ const editLink = `/restaurants/${restaurantId}/review/${reviewId}/edit`;
+ const displayContent =
+ content.length > 100 && !isExpanded ? content.slice(0, 100) + "..." : content;
+
+ /**
+ * TODO 1: userId๋ก userInfo ๋ถ๋ฌ์ค๊ธฐ
+ */
+ const userName = "ํ๊ธธ๋";
+ const ImgSrc = "/images/profile-image-default-1.png";
+
+ /**
+ * TODO 2: ํ์ฌ ๋ก๊ทธ์ธ๋ ์ ์ ์์ด๋ ๊ฐ์ ธ์ค๊ธฐ (๋ฆฌ๋ทฐ ์์ ๊ถํ ํ์ธ์ฉ)
+ */
+ const currentUserId = 1;
+
+ return (
+ <EmotionWrapper>
+ <div className="user-info-score-div">
+ <div className="user-info-div">
+ <Image src={ImgSrc} alt={"์ ์ ํ๋กํ ์ด๋ฏธ์ง"} width={30} height={30} />
+ <span className="user-name">{userName}</span>
+ <span className="date">{dayjs(createdAt).format("YY/MM/DD")}</span>
+ {currentUserId === userId && (
+ <Link href={editLink}>
+ <IconEditFilledWhite />
+ </Link>
+ )}
+ </div>
+ <Rating value={score} />
+ </div>
+ <div className="content-div">
+ <span>{displayContent}</span>
+ {content.length > 100 && (
+ <button onClick={toggleExpansion}>{isExpanded ? "์ ๊ธฐ" : "๋ ๋ณด๊ธฐ"}</button>
+ )}
+ </div>
+ </EmotionWrapper>
+ );
+};
+
+export default ReviewItem;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ min-height: 90px;
+ width: 100%;
+ background-color: ${({ theme }) => theme.color.white};
+ border-radius: 6px;
+
+ padding: 10px;
+
+ .user-info-score-div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .user-info-div {
+ display: flex;
+ gap: 8px;
+ justify-content: center;
+ align-items: center;
+
+ span.user-name {
+ font-size: 16px;
+ font-weight: 600;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+ span.date {
+ font-size: 12px;
+ font-weight: 300;
+ color: ${({ theme }) => theme.color.gray300};
+ }
+ }
+ }
+
+ .content-div {
+ span {
+ line-height: 1.5;
+ color: ${({ theme }) => theme.color.gray400};
+ flex-grow: 1;
+ margin-right: 8px;
+ }
+
+ button {
+ color: ${({ theme }) => theme.color.gray300};
+ }
+ }
+`; | Unknown | ์ค ๋ต ๊ฐ์ฌํฉ๋๋ค. ํด๋น ๋ฐฉ์์ผ๋ก ์์ ์๋ฃํ์์ต๋๋ค! |
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
import styled from "@emotion/styled";
import { css, Theme } from "@emotion/react";
import CheckIcon from "components/inputs/TextInput/CheckIcon";
-import { TConditionCheck } from "./types/TConditionCheck";
+import { TConditionCheck } from "components/inputs/TextInput/types/TConditionCheck";
interface Props {
name?: string;
@@ -12,6 +12,7 @@ interface Props {
conditionList?: string[];
conditionCheckList?: TConditionCheck[];
multiline?: boolean;
+ height?: string;
onTextChange?: (value: string, isValid: boolean) => void;
}
@@ -23,6 +24,7 @@ const TextInput: React.FC<Props> = ({
conditionList,
conditionCheckList,
multiline = false,
+ height,
onTextChange,
}) => {
const [status, setStatus] = useState(value === "" ? "default" : "success"); // default / success / invalid / focus
@@ -76,7 +78,7 @@ const TextInput: React.FC<Props> = ({
}, [enteredValue, status, onTextChange]);
return (
- <EmotionWrapper>
+ <EmotionWrapper height={height}>
{label && <span className="label">{label}</span>}
{conditionList && (
<div className="spanList">
@@ -179,6 +181,7 @@ const EmotionWrapper = styled.div<Props>`
${({ theme }) => commonStyles(theme)};
position: relative;
resize: none;
+ height: ${({ height }) => height ?? "auto"};
}
`;
| Unknown | ๋ต ์์ ํ์ต๋๋ค! |
@@ -0,0 +1,105 @@
+import styled from "@emotion/styled";
+import RestaurantExternalLinkIcon from "feature/restaurants/restaurantsDetail/components/icons/RestaurantExternalLinkIcon";
+import Link from "next/link";
+
+interface Props {
+ restaurantId: string;
+ userAuth?: number;
+ restaurantName: string;
+ restaurantAddress: string;
+ organizationName: string;
+ link?: string;
+ isMain?: boolean;
+}
+
+const RestaurantDetailHeaderSection: React.FC<Props> = ({
+ restaurantId,
+ userAuth,
+ restaurantName,
+ restaurantAddress,
+ organizationName,
+ link,
+ isMain = true,
+}) => {
+ return (
+ <EmotionWrapper>
+ <div className="over-title-div">
+ <span className="subtitle">{organizationName}</span>
+ {isMain &&
+ (userAuth === 0 || userAuth === 1 ? (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/edit"}>
+ ๋ง์ง ์์
+ </Link>
+ ) : (
+ <Link className="link-div" href={"/restaurants/" + restaurantId + "/copy"}>
+ ๋ง์ง ์์
+ </Link>
+ ))}
+ </div>
+ <h1 className="title">{restaurantName}</h1>
+ <div className="under-title-div">
+ <span className="subtitle">{restaurantAddress}</span>
+ {link && (
+ <Link className="link-div" href={link}>
+ <RestaurantExternalLinkIcon />
+ <span className="link-span">๋ง์ง ์์ธ ์ ๋ณด ></span>
+ </Link>
+ )}
+ </div>
+ </EmotionWrapper>
+ );
+};
+
+export default RestaurantDetailHeaderSection;
+
+const EmotionWrapper = styled.div`
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ justify-content: center;
+ align-items: left;
+ gap: 8px;
+
+ span {
+ font-weight: 300;
+ margin-left: 2px;
+ font-size: 16px;
+ color: ${({ theme }) => theme.color.gray600};
+ }
+
+ span.subtitle {
+ font-size: 12px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray300};
+ }
+
+ .title {
+ font-size: 30px;
+ font-weight: 600;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .under-title-div,
+ .over-title-div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ }
+
+ .link-div {
+ display: flex;
+ justify-content: right;
+ align-items: center;
+ text-decoration-line: none;
+
+ font-size: 14px;
+ font-weight: 400;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .link-span {
+ font-size: 12px;
+ font-weight: 300;
+ color: ${({ theme }) => theme.color.gray500};
+ }
+`; | Unknown | restaurantId๋ฅผ ๋ฐ์์ฌ ๋ `const restaurantId = query.restaurantId ?? 0;` ์ด๋ ๊ฒ๋ง ํ๋๋ props๋ก ๋๊ฒจ์ค ๋ ํ์
์๋ฌ๊ฐ ๋ ์ ์ ๋ ๊ฒ ์ค์ ํ๊ฑด๋ฐ, ํ์ฌ๋ `const restaurantId = (query.restaurantId ?? 0) as string;` ์์ ์ด๋ฐ ์์ผ๋ก ํ์
์ ๋ช
์ํด์ฃผ์ด์ props๋ก ๋ฐ์์ฌ ๋์๋ string์ผ๋ก๋ง ๋ฐ์์ค๋๋ก ์์ ํ์ต๋๋ค! |
@@ -0,0 +1,18 @@
+import styled from "@emotion/styled";
+import RestaurantsReviewForm from "feature/restaurants/restaurantsReview/components/form/RestaurantsReviewForm";
+
+interface Props {
+ restaurantId: string;
+}
+
+const ViewRestaurantReviewCreate: React.FC<Props> = ({ restaurantId }) => {
+ return (
+ <EmotionWrapper>
+ <RestaurantsReviewForm restaurantId={restaurantId} isEditMode={false} />
+ </EmotionWrapper>
+ );
+};
+
+export default ViewRestaurantReviewCreate;
+
+const EmotionWrapper = styled.div``; | Unknown | [์ฌ๊ธฐ](https://github.com/SystemConsultantGroup/foodhub-frontend/pull/27#discussion_r1373127345)์์ ์ด์ ๋ฅผ ์ค๋ช
ํ์๊ณ , ํด๋น ๋ถ๋ถ string์ผ๋ก๋ง ๋ฐ์์ค๋๋ก ์์ ํ์ต๋๋ค! |
@@ -0,0 +1,170 @@
+import styled from "@emotion/styled";
+import IconStarFilled from "components/rating/icons/IconStarFilled";
+import IconStarHalf from "components/rating/icons/IconStarHalf";
+import IconStarOutlined from "components/rating/icons/IconStarOutlined";
+import { HTMLAttributes, useEffect, useState, useRef, useCallback } from "react";
+
+interface Props extends HTMLAttributes<HTMLDivElement> {
+ value: number; // 0 ~ 5 ์ฌ์ด์ ์ซ์, ๋ณ ๊ฐ์๋ ๊ฐ์ฅ ๊ฐ๊น์ด 0.5 ๋จ์๋ก ๋ฐ์ฌ๋ฆผ
+ isInput?: boolean; // input ๊ธฐ๋ฅ์ ํ๋๋ก ํ ์ง ์ค์
+ onSelectedValueChange?: (value: number) => void;
+}
+
+const Rating = ({ value, isInput = false, onSelectedValueChange, ...props }: Props) => {
+ const [selectedValue, setSelectedValue] = useState<number>(value);
+ const isMouseDown = useRef<boolean>(false);
+ const containerRef = useRef<HTMLDivElement>(null);
+
+ // round value to the nearest 0.5
+ const startCount = Math.round(selectedValue * 2) / 2;
+
+ const filledStarCount = Math.floor(startCount);
+ const hasHalfStar = startCount % 1 !== 0;
+ const emptyStarCount = 5 - filledStarCount - (hasHalfStar ? 1 : 0);
+
+ useEffect(() => {
+ if (onSelectedValueChange) {
+ onSelectedValueChange(selectedValue);
+ }
+ }, [selectedValue, onSelectedValueChange]);
+
+ const handleOnClick = (event: React.MouseEvent, index: number) => {
+ const clickX = event.nativeEvent.clientX; // ํด๋ฆญํ ์์น์ X ์ขํ
+
+ // IconStar... ์ปดํฌ๋ํธ ๋ด์์ ํด๋ฆญํ ์์น๋ฅผ ๊ธฐ์ค์ผ๋ก ์ผ์ชฝ ๋๋ ์ค๋ฅธ์ชฝ ํ๋ณ
+ const containerRect = event.currentTarget.getBoundingClientRect();
+ const containerCenterX = (containerRect.left + containerRect.right) / 2;
+
+ if (clickX < containerCenterX) {
+ setSelectedValue(index + 0.5);
+ } else {
+ setSelectedValue(index + 1);
+ }
+ };
+
+ const calculateScore = useCallback((currentX: number) => {
+ const container = containerRef.current;
+ if (container) {
+ const unitSize = container.getBoundingClientRect().width / 10;
+ const relativeX = currentX - container.getBoundingClientRect().x;
+ if (relativeX <= 0) setSelectedValue(0.5);
+ else {
+ const score = (Math.floor(relativeX / unitSize) + 1) * 0.5;
+ score > 5 ? setSelectedValue(5) : setSelectedValue(score);
+ }
+ }
+ }, []);
+
+ const handleOnMouseDown = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
+ isMouseDown.current = true;
+ }, []);
+
+ const handleOnMouseLeave = useCallback((event: React.MouseEvent<HTMLDivElement>) => {
+ isMouseDown.current = false;
+ }, []);
+
+ const handleOnMouseMove = useCallback(
+ (event: React.MouseEvent) => {
+ if (isMouseDown.current) calculateScore(event.clientX);
+ },
+ [calculateScore]
+ );
+
+ const handleOnMouseUp = useCallback((event: React.MouseEvent) => {
+ isMouseDown.current = false;
+ }, []);
+
+ // For mobile view
+ const handleOnTouchMove = useCallback(
+ (event: React.TouchEvent) => {
+ calculateScore(event.changedTouches[0].clientX);
+ },
+ [calculateScore]
+ );
+
+ return (
+ <EmotionWrapper isInput={isInput} {...props}>
+ <div
+ className="star-container"
+ onMouseDown={handleOnMouseDown}
+ onMouseUp={handleOnMouseUp}
+ onMouseMove={handleOnMouseMove}
+ onMouseLeave={handleOnMouseLeave}
+ onTouchMove={handleOnTouchMove}
+ ref={containerRef}
+ >
+ {Array.from({ length: filledStarCount }, (_, index) =>
+ isInput ? (
+ <IconStarFilled
+ key={index}
+ size={40}
+ onClick={(event: React.MouseEvent) => handleOnClick(event, index)}
+ />
+ ) : (
+ <IconStarFilled key={index} />
+ )
+ )}
+ {hasHalfStar &&
+ (isInput ? (
+ <IconStarHalf
+ size={40}
+ onClick={(event: React.MouseEvent) => handleOnClick(event, filledStarCount)}
+ />
+ ) : (
+ <IconStarHalf />
+ ))}
+ {Array.from({ length: emptyStarCount }, (_, index) =>
+ isInput ? (
+ <IconStarOutlined
+ key={index}
+ size={40}
+ onClick={(event: React.MouseEvent) =>
+ handleOnClick(event, filledStarCount + index + (hasHalfStar ? 1 : 0))
+ }
+ />
+ ) : (
+ <IconStarOutlined key={index} />
+ )
+ )}
+ </div>
+ {isInput ? (
+ <div>
+ <span className="rating-value-selected">{selectedValue}</span>
+ <span className="rating-full-marks"> / 5</span>
+ </div>
+ ) : (
+ <p className="rating-value">{value}</p>
+ )}
+ </EmotionWrapper>
+ );
+};
+
+export default Rating;
+
+const EmotionWrapper = styled.div<{ isInput: boolean }>`
+ display: flex;
+ align-items: center;
+ ${({ isInput }) => (isInput ? "flex-direction: column; gap: 20px;" : "column-gap: 4px;")}
+
+ .star-container {
+ display: flex;
+ column-gap: 2px;
+ }
+
+ color: ${({ theme }) => theme.color.gray400};
+
+ .rating-full-marks {
+ font-size: 16px;
+ font-weight: 300;
+ }
+
+ .rating-value-selected {
+ font-size: 32px;
+ font-weight: 500;
+ color: ${({ theme }) => theme.color.gray700};
+ }
+
+ .rating-value {
+ font-size: 12px;
+ }
+`; | Unknown | ๋ณ์ ์ dragํ์ฌ ์
๋ ฅํ ์ ์๋๋ก ์ถ๊ฐ์ ์ผ๋ก ๊ตฌํํ์๋๋ฐ, ๋ฐ์คํฌํฑ์์๋ ์ ๋๋๋ฐ ๋ชจ๋ฐ์ผ์์๋ touchMove ์ด๋ฒคํธ๊ฐ ์ค๊ฐ์ ๋๊ธฐ๋ ํ์์ด ๋ฐ์ํ์์ต๋๋ค. ์ ํํ๋ touchMove ๋์ค์ state๋ฅผ ์ธํ
ํ๋ฉด, ํฐ์น๋ ์ด์ด์ง๊ณ ์๋ ์ํฉ์ธ๋ฐ๋ touchMove๊ฐ ์ธ์๋์ง ์์ต๋๋ค. selectedValue๊ฐ ๋ฐ๋๋ฉด์ star๋ค์ด ๋ค์ ๋ ๋๋ง๋๋ ๊ฒ ๋๋ฌธ์ธ ๊ฒ ๊ฐ์ง๋ง ์ ํํ ๋ญ ๋๋ฌธ์ธ์ง๋ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ํ์ฌ ํด๊ฒฐ ๋ฐฉ์์ ์ฐพ๋ ์ค์ด๊ธด ํ๋ฐ, ํ๋ค๊ฐ ์๋๋ฉด ์ด์๋ก ์ฌ๋ฆฌ๋๋ก ํ๊ฒ ์ต๋๋ค.. @jaychang99 @hoon5083 |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ goToMain = e => {
+ fetch('http://10.58.0.100:8000/users/signin', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.id,
+ password: this.state.pw,
+ nick_name: '์ด์์ฐ',
+ phonenumber: '01012345678',
+ }),
+ })
+ .then(response => response.json())
+ .then(result => {
+ if (result.message === 'SUCCESS') {
+ this.props.history.push('/MainEuiyeon');
+ } else {
+ alert('์์ด๋ ๋ฐ ๋น๋ฐ๋ฒํธ๋ฅผ ํ์ธํ์ธ์!');
+ }
+ });
+ };
-class LoginEuiyeon extends React.Component {
render() {
- return <div>11</div>;
+ return (
+ <div class="Login">
+ <section className="loginBox">
+ <div className="logo">
+ <div className="logoFont">Westagram</div>
+ </div>
+
+ <form className="loginForm">
+ <div className="inputWrap">
+ <div className="inputId">
+ <input
+ className="input"
+ id="idInput"
+ type="text"
+ name="id"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ <div className="inputPassword">
+ <input
+ className="input"
+ id="pwInput"
+ type="password"
+ name="pw"
+ placeholder="๋น๋ฐ๋ฒํธ (6์๋ฆฌ ์ด์)"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ </div>
+
+ <div className="buttonWrap">
+ <button
+ className={
+ this.state.id.includes('@') && this.state.pw.length >= 6
+ ? 'loginBtn'
+ : 'loginBtn_disabled'
+ }
+ type="button"
+ onClick={this.goToMain}
+ >
+ {' '}
+ ๋ก๊ทธ์ธ{' '}
+ </button>
+ </div>
+ </form>
+
+ <div className="forgotText">
+ <a className="forgotPassword">๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?</a>
+ </div>
+ </section>
+ </div>
+ );
}
}
-export default LoginEuiyeon;
+
+export default withRouter(Login); | JavaScript | ๋ฆฌ์กํธ ๊ด๋ จ ๋ผ์ด๋ธ๋ฌ๋ฆฌ import๊ฐ ๋ ์ฐ์ ์์์ ์์นํด์ผ ํ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ goToMain = e => {
+ fetch('http://10.58.0.100:8000/users/signin', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.id,
+ password: this.state.pw,
+ nick_name: '์ด์์ฐ',
+ phonenumber: '01012345678',
+ }),
+ })
+ .then(response => response.json())
+ .then(result => {
+ if (result.message === 'SUCCESS') {
+ this.props.history.push('/MainEuiyeon');
+ } else {
+ alert('์์ด๋ ๋ฐ ๋น๋ฐ๋ฒํธ๋ฅผ ํ์ธํ์ธ์!');
+ }
+ });
+ };
-class LoginEuiyeon extends React.Component {
render() {
- return <div>11</div>;
+ return (
+ <div class="Login">
+ <section className="loginBox">
+ <div className="logo">
+ <div className="logoFont">Westagram</div>
+ </div>
+
+ <form className="loginForm">
+ <div className="inputWrap">
+ <div className="inputId">
+ <input
+ className="input"
+ id="idInput"
+ type="text"
+ name="id"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ <div className="inputPassword">
+ <input
+ className="input"
+ id="pwInput"
+ type="password"
+ name="pw"
+ placeholder="๋น๋ฐ๋ฒํธ (6์๋ฆฌ ์ด์)"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ </div>
+
+ <div className="buttonWrap">
+ <button
+ className={
+ this.state.id.includes('@') && this.state.pw.length >= 6
+ ? 'loginBtn'
+ : 'loginBtn_disabled'
+ }
+ type="button"
+ onClick={this.goToMain}
+ >
+ {' '}
+ ๋ก๊ทธ์ธ{' '}
+ </button>
+ </div>
+ </form>
+
+ <div className="forgotText">
+ <a className="forgotPassword">๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?</a>
+ </div>
+ </section>
+ </div>
+ );
}
}
-export default LoginEuiyeon;
+
+export default withRouter(Login); | JavaScript | import './Login.scss'; ์๋ก ๊ฐ์ผ๋ ๊ฒ ๊ฐ์ต๋๋ค!! ๐ |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ goToMain = e => {
+ fetch('http://10.58.0.100:8000/users/signin', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.id,
+ password: this.state.pw,
+ nick_name: '์ด์์ฐ',
+ phonenumber: '01012345678',
+ }),
+ })
+ .then(response => response.json())
+ .then(result => {
+ if (result.message === 'SUCCESS') {
+ this.props.history.push('/MainEuiyeon');
+ } else {
+ alert('์์ด๋ ๋ฐ ๋น๋ฐ๋ฒํธ๋ฅผ ํ์ธํ์ธ์!');
+ }
+ });
+ };
-class LoginEuiyeon extends React.Component {
render() {
- return <div>11</div>;
+ return (
+ <div class="Login">
+ <section className="loginBox">
+ <div className="logo">
+ <div className="logoFont">Westagram</div>
+ </div>
+
+ <form className="loginForm">
+ <div className="inputWrap">
+ <div className="inputId">
+ <input
+ className="input"
+ id="idInput"
+ type="text"
+ name="id"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ <div className="inputPassword">
+ <input
+ className="input"
+ id="pwInput"
+ type="password"
+ name="pw"
+ placeholder="๋น๋ฐ๋ฒํธ (6์๋ฆฌ ์ด์)"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ </div>
+
+ <div className="buttonWrap">
+ <button
+ className={
+ this.state.id.includes('@') && this.state.pw.length >= 6
+ ? 'loginBtn'
+ : 'loginBtn_disabled'
+ }
+ type="button"
+ onClick={this.goToMain}
+ >
+ {' '}
+ ๋ก๊ทธ์ธ{' '}
+ </button>
+ </div>
+ </form>
+
+ <div className="forgotText">
+ <a className="forgotPassword">๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?</a>
+ </div>
+ </section>
+ </div>
+ );
}
}
-export default LoginEuiyeon;
+
+export default withRouter(Login); | JavaScript | ์์ ์๋ฃ ๐ |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ goToMain = e => {
+ fetch('http://10.58.0.100:8000/users/signin', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.id,
+ password: this.state.pw,
+ nick_name: '์ด์์ฐ',
+ phonenumber: '01012345678',
+ }),
+ })
+ .then(response => response.json())
+ .then(result => {
+ if (result.message === 'SUCCESS') {
+ this.props.history.push('/MainEuiyeon');
+ } else {
+ alert('์์ด๋ ๋ฐ ๋น๋ฐ๋ฒํธ๋ฅผ ํ์ธํ์ธ์!');
+ }
+ });
+ };
-class LoginEuiyeon extends React.Component {
render() {
- return <div>11</div>;
+ return (
+ <div class="Login">
+ <section className="loginBox">
+ <div className="logo">
+ <div className="logoFont">Westagram</div>
+ </div>
+
+ <form className="loginForm">
+ <div className="inputWrap">
+ <div className="inputId">
+ <input
+ className="input"
+ id="idInput"
+ type="text"
+ name="id"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ <div className="inputPassword">
+ <input
+ className="input"
+ id="pwInput"
+ type="password"
+ name="pw"
+ placeholder="๋น๋ฐ๋ฒํธ (6์๋ฆฌ ์ด์)"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ </div>
+
+ <div className="buttonWrap">
+ <button
+ className={
+ this.state.id.includes('@') && this.state.pw.length >= 6
+ ? 'loginBtn'
+ : 'loginBtn_disabled'
+ }
+ type="button"
+ onClick={this.goToMain}
+ >
+ {' '}
+ ๋ก๊ทธ์ธ{' '}
+ </button>
+ </div>
+ </form>
+
+ <div className="forgotText">
+ <a className="forgotPassword">๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?</a>
+ </div>
+ </section>
+ </div>
+ );
}
}
-export default LoginEuiyeon;
+
+export default withRouter(Login); | JavaScript | - variable.scss ๋ scss ํ์ผ์์ ์ฌ์ฉํ๋ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ js ์์ import ๋ฅผ ํ๋ ๊ฒ์ด ์๋ฏธ๊ฐ ์์ต๋๋ค.
- scss ํ์ผ์์ ๋ณ์๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ์ import ํด์ฃผ์ธ์! |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ goToMain = e => {
+ fetch('http://10.58.0.100:8000/users/signin', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.id,
+ password: this.state.pw,
+ nick_name: '์ด์์ฐ',
+ phonenumber: '01012345678',
+ }),
+ })
+ .then(response => response.json())
+ .then(result => {
+ if (result.message === 'SUCCESS') {
+ this.props.history.push('/MainEuiyeon');
+ } else {
+ alert('์์ด๋ ๋ฐ ๋น๋ฐ๋ฒํธ๋ฅผ ํ์ธํ์ธ์!');
+ }
+ });
+ };
-class LoginEuiyeon extends React.Component {
render() {
- return <div>11</div>;
+ return (
+ <div class="Login">
+ <section className="loginBox">
+ <div className="logo">
+ <div className="logoFont">Westagram</div>
+ </div>
+
+ <form className="loginForm">
+ <div className="inputWrap">
+ <div className="inputId">
+ <input
+ className="input"
+ id="idInput"
+ type="text"
+ name="id"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ <div className="inputPassword">
+ <input
+ className="input"
+ id="pwInput"
+ type="password"
+ name="pw"
+ placeholder="๋น๋ฐ๋ฒํธ (6์๋ฆฌ ์ด์)"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ </div>
+
+ <div className="buttonWrap">
+ <button
+ className={
+ this.state.id.includes('@') && this.state.pw.length >= 6
+ ? 'loginBtn'
+ : 'loginBtn_disabled'
+ }
+ type="button"
+ onClick={this.goToMain}
+ >
+ {' '}
+ ๋ก๊ทธ์ธ{' '}
+ </button>
+ </div>
+ </form>
+
+ <div className="forgotText">
+ <a className="forgotPassword">๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?</a>
+ </div>
+ </section>
+ </div>
+ );
}
}
-export default LoginEuiyeon;
+
+export default withRouter(Login); | JavaScript | - ๋ ํจ์๋ ํ๋ ์ญํ ์ด ๋น์ทํ๊ธฐ ๋๋ฌธ์ ์ถฉ๋ถํ ํ๋์ ํจ์๋ก ํฉ์ณ๋ณผ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค.
- Refactoring CheckList ์ฐธ๊ณ ํด์ ์์ ํด ๋ณด์ธ์! |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ goToMain = e => {
+ fetch('http://10.58.0.100:8000/users/signin', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.id,
+ password: this.state.pw,
+ nick_name: '์ด์์ฐ',
+ phonenumber: '01012345678',
+ }),
+ })
+ .then(response => response.json())
+ .then(result => {
+ if (result.message === 'SUCCESS') {
+ this.props.history.push('/MainEuiyeon');
+ } else {
+ alert('์์ด๋ ๋ฐ ๋น๋ฐ๋ฒํธ๋ฅผ ํ์ธํ์ธ์!');
+ }
+ });
+ };
-class LoginEuiyeon extends React.Component {
render() {
- return <div>11</div>;
+ return (
+ <div class="Login">
+ <section className="loginBox">
+ <div className="logo">
+ <div className="logoFont">Westagram</div>
+ </div>
+
+ <form className="loginForm">
+ <div className="inputWrap">
+ <div className="inputId">
+ <input
+ className="input"
+ id="idInput"
+ type="text"
+ name="id"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ <div className="inputPassword">
+ <input
+ className="input"
+ id="pwInput"
+ type="password"
+ name="pw"
+ placeholder="๋น๋ฐ๋ฒํธ (6์๋ฆฌ ์ด์)"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ </div>
+
+ <div className="buttonWrap">
+ <button
+ className={
+ this.state.id.includes('@') && this.state.pw.length >= 6
+ ? 'loginBtn'
+ : 'loginBtn_disabled'
+ }
+ type="button"
+ onClick={this.goToMain}
+ >
+ {' '}
+ ๋ก๊ทธ์ธ{' '}
+ </button>
+ </div>
+ </form>
+
+ <div className="forgotText">
+ <a className="forgotPassword">๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?</a>
+ </div>
+ </section>
+ </div>
+ );
}
}
-export default LoginEuiyeon;
+
+export default withRouter(Login); | JavaScript | - isActive ๋ id ์ pw ๋ก ๊ณ์ฐํ ์ ์๋ ๊ฐ์ด์ด๊ธฐ ๋๋ฌธ์ state ๋ก ๊ด๋ฆฌํ ํ์๊ฐ ์์ด ๋ณด์
๋๋ค!
- ์๋ ๊ณต์ ๋ฌธ์ ์ฐธ๊ณ ํ์
์ ์ด๋ค ๊ฐ๋ค์ด state ๋ก ์ ์ ํ์ง ์์์ง ํ์
ํด๋ณด์๊ธฐ ๋ฐ๋๋๋ค!
https://www.notion.so/wecode/Westagram-React-Refactoring-Checklist-aea297cf88ed4601b769e4b2c2cfd4e1#089493d6bfca438aa328226e327cff92 |
@@ -1,8 +1,100 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
+
+class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ id: '',
+ pw: '',
+ };
+ }
+
+ handleInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ goToMain = e => {
+ fetch('http://10.58.0.100:8000/users/signin', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.id,
+ password: this.state.pw,
+ nick_name: '์ด์์ฐ',
+ phonenumber: '01012345678',
+ }),
+ })
+ .then(response => response.json())
+ .then(result => {
+ if (result.message === 'SUCCESS') {
+ this.props.history.push('/MainEuiyeon');
+ } else {
+ alert('์์ด๋ ๋ฐ ๋น๋ฐ๋ฒํธ๋ฅผ ํ์ธํ์ธ์!');
+ }
+ });
+ };
-class LoginEuiyeon extends React.Component {
render() {
- return <div>11</div>;
+ return (
+ <div class="Login">
+ <section className="loginBox">
+ <div className="logo">
+ <div className="logoFont">Westagram</div>
+ </div>
+
+ <form className="loginForm">
+ <div className="inputWrap">
+ <div className="inputId">
+ <input
+ className="input"
+ id="idInput"
+ type="text"
+ name="id"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ <div className="inputPassword">
+ <input
+ className="input"
+ id="pwInput"
+ type="password"
+ name="pw"
+ placeholder="๋น๋ฐ๋ฒํธ (6์๋ฆฌ ์ด์)"
+ onKeyUp={this.checkValid}
+ onChange={this.handleInput}
+ />
+ </div>
+ </div>
+
+ <div className="buttonWrap">
+ <button
+ className={
+ this.state.id.includes('@') && this.state.pw.length >= 6
+ ? 'loginBtn'
+ : 'loginBtn_disabled'
+ }
+ type="button"
+ onClick={this.goToMain}
+ >
+ {' '}
+ ๋ก๊ทธ์ธ{' '}
+ </button>
+ </div>
+ </form>
+
+ <div className="forgotText">
+ <a className="forgotPassword">๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?</a>
+ </div>
+ </section>
+ </div>
+ );
}
}
-export default LoginEuiyeon;
+
+export default withRouter(Login); | JavaScript | - isActive ๋ฅผ state ๋ก ๊ด๋ฆฌํ ํ์ ์์ด, ์ฌ๊ธฐ์ ๋ฐ๋ก true / false ๋ฅผ ๊ณ์ฐํ๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -1,3 +1,106 @@
-*{
- margin: 0;
-}
\ No newline at end of file
+@import '../../../styles/variable.scss';
+
+.Login {
+ @include flexCenter;
+ flex-direction: column;
+ align-items: center;
+ height: 100vh;
+
+ .loginBox {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ border: $default-border;
+ width: 430px;
+
+ .logo {
+ @include flexCenter;
+ align-items: center;
+ margin-top: 60px;
+
+ .logoFont {
+ font-size: 50px;
+ font-family: 'Lobster';
+ }
+ }
+
+ .loginForm {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-around;
+ align-items: center;
+ margin-top: 80px;
+
+ .inputWrap {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-evenly;
+ align-items: center;
+ height: 50%;
+ width: 80%;
+
+ .inputId,
+ .inputPassword {
+ width: 100%;
+ }
+
+ input {
+ width: 100%;
+ height: 45px;
+ margin-bottom: 15px;
+ padding: 2px 10px;
+ border-radius: 5px;
+ background-color: #eeeeef;
+ border: $default-border;
+ font-size: inherit;
+ }
+ }
+
+ .buttonWrap {
+ @include flexCenter;
+ flex-direction: column;
+ align-items: center;
+ width: 100%;
+ height: 40%;
+ margin-top: 25px;
+
+ .loginBtn {
+ width: 80%;
+ height: 45px;
+ border-radius: 5px;
+ border: transparent;
+ background-color: $btn-color-active;
+ /* background-color: #b2dffc; */
+ color: white;
+ font-size: 20px;
+ padding-top: 4px;
+ }
+
+ .loginBtn_disabled {
+ width: 80%;
+ height: 45px;
+ border-radius: 5px;
+ border: transparent;
+ background-color: $btn-color-disable;
+ color: white;
+ font-size: 20px;
+ padding-top: 4px;
+ }
+ }
+ }
+
+ .forgotText {
+ display: flex;
+ flex-direction: column;
+ justify-content: flex-end;
+ align-items: center;
+ margin: 80px 0 30px 0;
+
+ .forgotPassword {
+ text-align: end;
+ margin-bottom: 20px;
+ color: #2c5581;
+ }
+ }
+ }
+} | Unknown | - css ์์
์ ํ์ค๋ ๋ฐ๊นฅ ์์์ ํน์ ํ width / height ๊ฐ์ ๋ถ์ฌํ์๋ ๊ฒ ๋ณด๋ค, ๋ฐ๊นฅ ์์์ ํฌ๊ธฐ๋ ๋ด์ฉ๋ฌผ์ ํฌ๊ธฐ + margin / padding ๋ค์ ํฉ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ํฌ๊ธฐ๊ฐ ๊ฒฐ์ ๋๋๋ก ํ์๋ ๊ฒ ๋ ์ข์ต๋๋ค.
- ํญ์ bottom up ๋ฐฉ์์ผ๋ก ์คํ์ผ๋ง ํ๋ ์ต๊ด์ ๋ค์ฌ์ฃผ์ธ์! |
@@ -0,0 +1,26 @@
+import React from 'react';
+import './Aside.scss';
+
+import ProfileWrap from './ProfileWrap/ProfileWrap';
+import StoryBox from './StoryBox/StoryBox';
+import RecommendBox from './RecommendBox/RecommendBox';
+import WestaInfoBox from './WestaInfoBox/WestaInfoBox';
+
+class Aside extends React.Component {
+ render() {
+ return (
+ <aside className="sideWrapper">
+ <div className="sidebar">
+ <div className="profile_bar">
+ <ProfileWrap />
+ <StoryBox />
+ <RecommendBox />
+ <WestaInfoBox />
+ </div>
+ </div>
+ </aside>
+ );
+ }
+}
+
+export default Aside; | JavaScript | - Import ์์ ์์ ํด์ฃผ์ธ์! ์ผ๋ฐ์ ์ธ convention์ ๋ฐ๋ฅด๋ ์ด์ ๋ ์์ง๋ง ์์๋ง ์ ์ง์ผ์ฃผ์
๋ ๊ฐ๋
์ฑ์ด ์ข์์ง๋๋ค. ์๋ ์์ ์ฐธ๊ณ ํด์ฃผ์ธ์.
- React โ Library(Package) โ Component โ ๋ณ์ / ์ด๋ฏธ์ง โ css ํ์ผ(scss ํ์ผ)
```suggestion
import React from 'react';
import ProfileWrap from './ProfileWrap/ProfileWrap';
import StoryBox from './StoryBox/StoryBox';
import RecommendBox from './RecommendBox/RecommendBox';
import WestaInfoBox from './WestaInfoBox/WestaInfoBox';
import './Aside.scss';
``` |
@@ -0,0 +1,56 @@
+import React from 'react';
+import './Content.scss';
+
+import Feed from './Feed/Feed';
+import Aside from './Aside/Aside';
+
+class Content extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() {
+ fetch('http://localhost:3000/data/feedData.json', {
+ method: 'GET',
+ })
+ .then(res => res.json())
+ .then(data => {
+ this.setState({
+ feeds: data,
+ });
+ });
+ }
+
+ render() {
+ return (
+ <div class="Main">
+ <main>
+ <div className="container">
+ <section className="articleWrapper">
+ {this.state.feeds.map(e => (
+ <Feed
+ feed_id={e.feed_id}
+ profile_img={e.profile_img}
+ profile_id={e.profile_id}
+ feed_img={e.feed_img}
+ like_click={e.like_click}
+ like_user_profile_img={e.like_user_profile_img}
+ like_user_profile_id={e.like_user_profile_id}
+ like_num={e.like_num}
+ post_user_mension={e.post_user_mension}
+ comments={e.comments}
+ />
+ ))}
+ </section>
+ <Aside />
+ </div>
+ </main>
+ </div>
+ );
+ }
+}
+
+export default Content; | JavaScript | - `http://localhost:3000` ์ ์๋ต ๊ฐ๋ฅํฉ๋๋ค. ํฌํธ ๋ฒํธ๊ฐ ๋ฌ๋ผ์ง๋ฉด(ex. `localhost:3001`) fetch ํจ์๋ฅผ ์ผ์ผ์ด ์์ ํด์ฃผ์ด์ผ ํ๊ธฐ ๋๋ฌธ์ ์ ์ง๋ณด์๊ฐ ์ด๋ ค์์ง๋๋ค. ์๋ ์ฝ๋ ์ฐธ๊ณ ํด์ ์์ ํด์ฃผ์ธ์!
```jsx
const foo = () => {
// fetch("http://localhost:3000/images/1")
fetch("/images/1")
}
```
- fetchํจ์์ `get method`๋ method์ default ๊ฐ์
๋๋ค. ๋ฐ๋ผ์ ์๋ต์ด ๊ฐ๋ฅํฉ๋๋ค.
```jsx
const foo = () => {
fetch(`${cartAPI}/quantity`)
.then((res) => res.json())
``` |
@@ -0,0 +1,56 @@
+import React from 'react';
+import './Content.scss';
+
+import Feed from './Feed/Feed';
+import Aside from './Aside/Aside';
+
+class Content extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() {
+ fetch('http://localhost:3000/data/feedData.json', {
+ method: 'GET',
+ })
+ .then(res => res.json())
+ .then(data => {
+ this.setState({
+ feeds: data,
+ });
+ });
+ }
+
+ render() {
+ return (
+ <div class="Main">
+ <main>
+ <div className="container">
+ <section className="articleWrapper">
+ {this.state.feeds.map(e => (
+ <Feed
+ feed_id={e.feed_id}
+ profile_img={e.profile_img}
+ profile_id={e.profile_id}
+ feed_img={e.feed_img}
+ like_click={e.like_click}
+ like_user_profile_img={e.like_user_profile_img}
+ like_user_profile_id={e.like_user_profile_id}
+ like_num={e.like_num}
+ post_user_mension={e.post_user_mension}
+ comments={e.comments}
+ />
+ ))}
+ </section>
+ <Aside />
+ </div>
+ </main>
+ </div>
+ );
+ }
+}
+
+export default Content; | JavaScript | - mock up ๋ฐ์ดํฐ์ ํค ๊ฐ์ ์ค๋ค์ดํฌ ์ผ์ด์ค๋ก ์ฌ์ฉํด์ฃผ์
๋ ๋์ง๋ง (๋ฐฑ์๋์์๋ ๋ณดํต ์ค๋ค์ดํฌ ์ผ์ด์ค๋ฅผ ์ฐ๊ธฐ ๋๋ฌธ์) props ์ ์ด๋ฆ์ ์นด๋ฉ ์ผ์ด์ค๋ก ํต์ผํด ์ฃผ์ธ์! |
@@ -0,0 +1,210 @@
+import 'package:flutter/material.dart';
+
+class ReviewView extends StatelessWidget {
+ const ReviewView({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: _appBar(context),
+ floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
+ body: SingleChildScrollView(
+ child: Column(children: [
+ _button(),
+ ...List.generate(
+ 30,
+ (index) => Padding(
+ padding: const EdgeInsets.only(bottom: 20),
+ child: _review(),
+ )),
+ ])),
+ );
+ }
+
+ AppBar _appBar(BuildContext context) => AppBar(
+ backgroundColor:
+ Theme.of(context).colorScheme.tertiary.withOpacity(0.0),
+ foregroundColor: Theme.of(context).colorScheme.onSecondary,
+ leading: GestureDetector(
+ onTap: () => Navigator.of(context).pop(),
+ ),
+ elevation: 0.0,
+ title: Text(
+ "๋ ์ํผ ๋ฑ๋ก",
+ style: Theme.of(context).textTheme.headlineLarge,
+ ),
+ );
+
+ Widget _button() => Builder(builder: (context) {
+ return Padding(
+ padding:
+ const EdgeInsets.only(top: 20, right: 10, left: 300, bottom: 20),
+ child: Container(
+ width: 75,
+ height: 34,
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(12),
+ color: Theme.of(context).colorScheme.secondary),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(left: 8),
+ child: Text(
+ "์ต์ ์",
+ style: Theme.of(context).textTheme.bodySmall,
+ ),
+ ),
+ Icon(
+ Icons.arrow_drop_down_sharp,
+ color: Colors.white,
+ )
+ ],
+ ),
+ ),
+ );
+ });
+
+ Widget _review() => Builder(builder: (context) {
+ return Container(
+ width: 350,
+ decoration: BoxDecoration(
+ color: Theme.of(context).colorScheme.onPrimaryContainer,
+ borderRadius: BorderRadius.circular(12.0),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ children: [
+ /// ์ฌ์ฉ์ ์ ๋ณด ํ์
+ Padding(
+ padding: const EdgeInsets.only(left: 10),
+ child: Container(
+ width: 48,
+ height: 48,
+ decoration: BoxDecoration(
+ color: Theme.of(context).colorScheme.tertiary,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ ),
+ ),
+
+ Padding(
+ padding: const EdgeInsets.only(top: 10, left: 10),
+ child: Text(
+ "๋๋ค์",
+ style: Theme.of(context).textTheme.bodyMedium,
+ ),
+ )
+ ],
+ ),
+
+ /// ํค์๋ ํ์
+ Padding(
+ padding: const EdgeInsets.only(
+ top: 15, bottom: 15, left: 10, right: 5),
+ child: Row(
+ children: [
+ Container(
+ decoration: BoxDecoration(
+ color: Theme.of(context).colorScheme.tertiary,
+ borderRadius: BorderRadius.circular(10.0),
+ ),
+ padding:
+ EdgeInsets.symmetric(horizontal: 8, vertical: 4),
+ child: Text(
+ "ํผ์ ๋จน๊ธฐ ์ข์์",
+ style: Theme.of(context).textTheme.labelMedium,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 5),
+ child: Container(
+ decoration: BoxDecoration(
+ color: Theme.of(context).colorScheme.tertiary,
+ borderRadius: BorderRadius.circular(10.0),
+ ),
+ padding:
+ EdgeInsets.symmetric(horizontal: 8, vertical: 4),
+ child: Text(
+ "๋ ๋ ํด์",
+ style: Theme.of(context).textTheme.labelMedium,
+ ),
+ ),
+ ),
+ Container(
+ decoration: BoxDecoration(
+ color: Theme.of(context).colorScheme.tertiary,
+ borderRadius: BorderRadius.circular(10.0),
+ ),
+ padding:
+ EdgeInsets.symmetric(horizontal: 8, vertical: 4),
+ child: Text(
+ "์ ๋ ดํด์",
+ style: Theme.of(context).textTheme.labelMedium,
+ ),
+ ),
+ ],
+ ),
+ ),
+
+ /// ์ฌ์ง
+ Padding(
+ padding:
+ const EdgeInsets.symmetric(vertical: 10, horizontal: 10),
+ child: SingleChildScrollView(
+ scrollDirection: Axis.horizontal,
+ child: Row(
+ children: [
+ Container(
+ width: 160,
+ height: 160,
+ decoration: BoxDecoration(
+ color: Theme.of(context).colorScheme.tertiary,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 10),
+ child: Container(
+ width: 160,
+ height: 160,
+ decoration: BoxDecoration(
+ color: Theme.of(context).colorScheme.tertiary,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 10),
+ child: Container(
+ width: 160,
+ height: 160,
+ decoration: BoxDecoration(
+ color: Theme.of(context).colorScheme.tertiary,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+
+ /// ๋ด์ฉ ์
๋ ฅ
+ Padding(
+ padding: const EdgeInsets.only(top: 20),
+ child: Text(
+ "์ค๋์ ์ํ ๋งํ ๊ฐ ์์ด์ ํํ ๋งํ ๋ฅผ ์ฌ์ฉํ์ด์.^^ ์๊ฑฐ ํ ํต ๋ค ๋ค์ด๊ฐ๋ค์. ์ ์ฒด ์คํ์ ์์ 8์ธ๋ถ ์ ๋??",
+ style: Theme.of(context).textTheme.bodyMedium,
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+} | Unknown | ํ๋กํ
๋ฒํผ ์ ๊ฑฐํ์
๋ ๋ฉ๋๋ค. ์ด์ PR ์ฐธ๊ณ ํด์ฃผ์ธ์. |
@@ -5,13 +5,15 @@
import com.somemore.domains.review.dto.response.ReviewDetailResponseDto;
import com.somemore.domains.review.dto.response.ReviewDetailWithNicknameResponseDto;
import com.somemore.domains.review.usecase.ReviewQueryUseCase;
+import com.somemore.global.auth.annotation.RoleId;
import com.somemore.global.common.response.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
+import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -41,7 +43,7 @@ public ApiResponse<ReviewDetailResponseDto> getById(@PathVariable Long id) {
);
}
- @Operation(summary = "๊ธฐ๊ด๋ณ ๋ฆฌ๋ทฐ ์กฐํ", description = "๊ธฐ๊ด ID๋ฅผ ์ฌ์ฉํ์ฌ ๋ฆฌ๋ทฐ ์กฐํ")
+ @Operation(summary = "ํน์ ๊ธฐ๊ด ๋ฆฌ๋ทฐ ์กฐํ", description = "๊ธฐ๊ด ID๋ฅผ ์ฌ์ฉํ์ฌ ๋ฆฌ๋ทฐ ์กฐํ")
@GetMapping("/reviews/center/{centerId}")
public ApiResponse<Page<ReviewDetailWithNicknameResponseDto>> getReviewsByCenterId(
@PathVariable UUID centerId,
@@ -53,14 +55,34 @@ public ApiResponse<Page<ReviewDetailWithNicknameResponseDto>> getReviewsByCenter
.pageable(pageable)
.build();
+ return ApiResponse.ok(
+ 200,
+ reviewQueryUseCase.getDetailsWithNicknameByCenterId(centerId, condition),
+ "ํน์ ๊ธฐ๊ด ๋ฆฌ๋ทฐ ๋ฆฌ์คํธ ์กฐํ ์ฑ๊ณต"
+ );
+ }
+
+ @Secured("ROLE_CENTER")
+ @Operation(summary = "๊ธฐ๊ด ๋ฆฌ๋ทฐ ์กฐํ", description = "๊ธฐ๊ด ์์ ์ ๋ฆฌ๋ทฐ ์กฐํ")
+ @GetMapping("/reviews/center/me")
+ public ApiResponse<Page<ReviewDetailWithNicknameResponseDto>> getMyCenterReviews(
+ @RoleId UUID centerId,
+ @PageableDefault(sort = "created_at", direction = DESC) Pageable pageable,
+ @RequestParam(required = false) VolunteerCategory category
+ ) {
+ ReviewSearchCondition condition = ReviewSearchCondition.builder()
+ .category(category)
+ .pageable(pageable)
+ .build();
+
return ApiResponse.ok(
200,
reviewQueryUseCase.getDetailsWithNicknameByCenterId(centerId, condition),
"๊ธฐ๊ด ๋ฆฌ๋ทฐ ๋ฆฌ์คํธ ์กฐํ ์ฑ๊ณต"
);
}
- @Operation(summary = "๋ด์ฌ์ ๋ฆฌ๋ทฐ ์กฐํ", description = "๋ด์ฌ์ ID๋ฅผ ์ฌ์ฉํ์ฌ ๋ฆฌ๋ทฐ ์กฐํ")
+ @Operation(summary = "ํน์ ๋ด์ฌ์ ๋ฆฌ๋ทฐ ์กฐํ", description = "๋ด์ฌ์ ID๋ฅผ ์ฌ์ฉํ์ฌ ๋ฆฌ๋ทฐ ์กฐํ")
@GetMapping("/reviews/volunteer/{volunteerId}")
public ApiResponse<Page<ReviewDetailWithNicknameResponseDto>> getReviewsByVolunteerId(
@PathVariable UUID volunteerId,
@@ -75,7 +97,27 @@ public ApiResponse<Page<ReviewDetailWithNicknameResponseDto>> getReviewsByVolunt
return ApiResponse.ok(
200,
reviewQueryUseCase.getDetailsWithNicknameByVolunteerId(volunteerId, condition),
- "์ ์ ๋ฆฌ๋ทฐ ๋ฆฌ์คํธ ์กฐํ ์ฑ๊ณต"
+ "ํน์ ๋ด์ฌ์ ๋ฆฌ๋ทฐ ๋ฆฌ์คํธ ์กฐํ ์ฑ๊ณต"
+ );
+ }
+
+ @Secured("ROLE_VOLUNTEER")
+ @Operation(summary = "๋ด์ฌ์ ๋ฆฌ๋ทฐ ์กฐํ", description = "๋ด์ฌ์ ์์ ์ ๋ฆฌ๋ทฐ ์กฐํ")
+ @GetMapping("/reviews/volunteer/me")
+ public ApiResponse<Page<ReviewDetailWithNicknameResponseDto>> getMyVolunteerReviews(
+ @RoleId UUID volunteerId,
+ @PageableDefault(sort = "created_at", direction = DESC) Pageable pageable,
+ @RequestParam(required = false) VolunteerCategory category
+ ) {
+ ReviewSearchCondition condition = ReviewSearchCondition.builder()
+ .category(category)
+ .pageable(pageable)
+ .build();
+
+ return ApiResponse.ok(
+ 200,
+ reviewQueryUseCase.getDetailsWithNicknameByVolunteerId(volunteerId, condition),
+ "๋ด์ฌ์ ๋ฆฌ๋ทฐ ๋ฆฌ์คํธ ์กฐํ ์ฑ๊ณต"
);
}
| Java | ๋น๋ ๋ก์ง์ ์ปจ๋์
ํด๋์ค์ of ์ ์ ๋ฉ์๋์์ ์งํํ๋ฉด ๋ ๊น๋ํ ๊ฒ ๊ฐ์์~
๊ตณ์ด ์์ ํ ํ์๋ ์๋ค๊ณ ์๊ฐํฉ๋๋ค! |
@@ -1,35 +1,34 @@
package com.somemore.domains.review.service;
-import com.somemore.domains.center.usecase.query.CenterQueryUseCase;
+import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_REVIEW;
+
import com.somemore.domains.review.domain.Review;
import com.somemore.domains.review.dto.condition.ReviewSearchCondition;
import com.somemore.domains.review.dto.response.ReviewDetailResponseDto;
import com.somemore.domains.review.dto.response.ReviewDetailWithNicknameResponseDto;
import com.somemore.domains.review.repository.ReviewRepository;
import com.somemore.domains.review.usecase.ReviewQueryUseCase;
-import com.somemore.domains.volunteer.domain.Volunteer;
-import com.somemore.domains.volunteer.usecase.VolunteerQueryUseCase;
+import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryUseCase;
import com.somemore.global.exception.NoSuchElementException;
+import com.somemore.volunteer.repository.record.VolunteerNicknameAndId;
+import com.somemore.volunteer.usecase.NEWVolunteerQueryUseCase;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_REVIEW;
-
@RequiredArgsConstructor
@Transactional(readOnly = true)
@Service
public class ReviewQueryService implements ReviewQueryUseCase {
private final ReviewRepository reviewRepository;
- private final VolunteerQueryUseCase volunteerQueryUseCase;
- private final CenterQueryUseCase centerQueryUseCase;
+ private final NEWVolunteerQueryUseCase volunteerQueryUseCase;
+ private final VolunteerApplyQueryUseCase volunteerApplyQueryUseCase;
@Override
public boolean existsByVolunteerApplyId(Long volunteerApplyId) {
@@ -45,7 +44,9 @@ public Review getById(Long id) {
@Override
public ReviewDetailResponseDto getDetailById(Long id) {
Review review = getById(id);
- return ReviewDetailResponseDto.from(review);
+ Long recruitBoardId = volunteerApplyQueryUseCase.getRecruitBoardIdById(
+ review.getVolunteerApplyId());
+ return ReviewDetailResponseDto.of(review, recruitBoardId);
}
@Override
@@ -54,10 +55,11 @@ public Page<ReviewDetailWithNicknameResponseDto> getDetailsWithNicknameByVolunte
ReviewSearchCondition condition
) {
String nickname = volunteerQueryUseCase.getNicknameById(volunteerId);
- Page<Review> reviews = reviewRepository.findAllByVolunteerIdAndSearch(volunteerId, condition);
+ Page<Review> reviews = reviewRepository.findAllByVolunteerIdAndSearch(volunteerId,
+ condition);
return reviews.map(
- review -> ReviewDetailWithNicknameResponseDto.from(review, nickname)
+ review -> ReviewDetailWithNicknameResponseDto.of(review, nickname)
);
}
@@ -66,28 +68,20 @@ public Page<ReviewDetailWithNicknameResponseDto> getDetailsWithNicknameByCenterI
UUID centerId,
ReviewSearchCondition condition
) {
- centerQueryUseCase.validateCenterExists(centerId);
-
Page<Review> reviews = reviewRepository.findAllByCenterIdAndSearch(centerId, condition);
List<UUID> volunteerIds = reviews.get().map(Review::getVolunteerId).toList();
- Map<UUID, String> volunteerNicknames = getVolunteerNicknames(volunteerIds);
+ Map<UUID, String> volunteerNicknames = mapVolunteerIdsToNicknames(volunteerIds);
- return reviews.map(
- review -> {
- String nickname = volunteerNicknames.getOrDefault(review.getVolunteerId(),
- "์ญ์ ๋ ์์ด๋");
- return ReviewDetailWithNicknameResponseDto.from(review, nickname);
- });
+ return reviews.map(review ->
+ ReviewDetailWithNicknameResponseDto.of(review,
+ volunteerNicknames.get(review.getVolunteerId()))
+ );
}
- private Map<UUID, String> getVolunteerNicknames(List<UUID> volunteerIds) {
- List<Volunteer> volunteers = volunteerQueryUseCase.getAllByIds(volunteerIds);
-
- Map<UUID, String> volunteerNicknames = new HashMap<>();
- for (Volunteer volunteer : volunteers) {
- volunteerNicknames.put(volunteer.getId(), volunteer.getNickname());
- }
-
- return volunteerNicknames;
+ private Map<UUID, String> mapVolunteerIdsToNicknames(List<UUID> volunteerIds) {
+ return volunteerQueryUseCase.getVolunteerNicknameAndIdsByIds(volunteerIds)
+ .stream()
+ .collect(Collectors.toMap(VolunteerNicknameAndId::id,
+ VolunteerNicknameAndId::nickname));
}
} | Java | ๋ฉ์๋๋ก ์ฝ๋๋ฅผ ํฌ์ฅํ๋ฉด ๊ฐ๋
์ฑ์ด ๋ ์ข์ ๊ฒ ๊ฐ์์~ |
@@ -1,35 +1,34 @@
package com.somemore.domains.review.service;
-import com.somemore.domains.center.usecase.query.CenterQueryUseCase;
+import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_REVIEW;
+
import com.somemore.domains.review.domain.Review;
import com.somemore.domains.review.dto.condition.ReviewSearchCondition;
import com.somemore.domains.review.dto.response.ReviewDetailResponseDto;
import com.somemore.domains.review.dto.response.ReviewDetailWithNicknameResponseDto;
import com.somemore.domains.review.repository.ReviewRepository;
import com.somemore.domains.review.usecase.ReviewQueryUseCase;
-import com.somemore.domains.volunteer.domain.Volunteer;
-import com.somemore.domains.volunteer.usecase.VolunteerQueryUseCase;
+import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryUseCase;
import com.somemore.global.exception.NoSuchElementException;
+import com.somemore.volunteer.repository.record.VolunteerNicknameAndId;
+import com.somemore.volunteer.usecase.NEWVolunteerQueryUseCase;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_REVIEW;
-
@RequiredArgsConstructor
@Transactional(readOnly = true)
@Service
public class ReviewQueryService implements ReviewQueryUseCase {
private final ReviewRepository reviewRepository;
- private final VolunteerQueryUseCase volunteerQueryUseCase;
- private final CenterQueryUseCase centerQueryUseCase;
+ private final NEWVolunteerQueryUseCase volunteerQueryUseCase;
+ private final VolunteerApplyQueryUseCase volunteerApplyQueryUseCase;
@Override
public boolean existsByVolunteerApplyId(Long volunteerApplyId) {
@@ -45,7 +44,9 @@ public Review getById(Long id) {
@Override
public ReviewDetailResponseDto getDetailById(Long id) {
Review review = getById(id);
- return ReviewDetailResponseDto.from(review);
+ Long recruitBoardId = volunteerApplyQueryUseCase.getRecruitBoardIdById(
+ review.getVolunteerApplyId());
+ return ReviewDetailResponseDto.of(review, recruitBoardId);
}
@Override
@@ -54,10 +55,11 @@ public Page<ReviewDetailWithNicknameResponseDto> getDetailsWithNicknameByVolunte
ReviewSearchCondition condition
) {
String nickname = volunteerQueryUseCase.getNicknameById(volunteerId);
- Page<Review> reviews = reviewRepository.findAllByVolunteerIdAndSearch(volunteerId, condition);
+ Page<Review> reviews = reviewRepository.findAllByVolunteerIdAndSearch(volunteerId,
+ condition);
return reviews.map(
- review -> ReviewDetailWithNicknameResponseDto.from(review, nickname)
+ review -> ReviewDetailWithNicknameResponseDto.of(review, nickname)
);
}
@@ -66,28 +68,20 @@ public Page<ReviewDetailWithNicknameResponseDto> getDetailsWithNicknameByCenterI
UUID centerId,
ReviewSearchCondition condition
) {
- centerQueryUseCase.validateCenterExists(centerId);
-
Page<Review> reviews = reviewRepository.findAllByCenterIdAndSearch(centerId, condition);
List<UUID> volunteerIds = reviews.get().map(Review::getVolunteerId).toList();
- Map<UUID, String> volunteerNicknames = getVolunteerNicknames(volunteerIds);
+ Map<UUID, String> volunteerNicknames = mapVolunteerIdsToNicknames(volunteerIds);
- return reviews.map(
- review -> {
- String nickname = volunteerNicknames.getOrDefault(review.getVolunteerId(),
- "์ญ์ ๋ ์์ด๋");
- return ReviewDetailWithNicknameResponseDto.from(review, nickname);
- });
+ return reviews.map(review ->
+ ReviewDetailWithNicknameResponseDto.of(review,
+ volunteerNicknames.get(review.getVolunteerId()))
+ );
}
- private Map<UUID, String> getVolunteerNicknames(List<UUID> volunteerIds) {
- List<Volunteer> volunteers = volunteerQueryUseCase.getAllByIds(volunteerIds);
-
- Map<UUID, String> volunteerNicknames = new HashMap<>();
- for (Volunteer volunteer : volunteers) {
- volunteerNicknames.put(volunteer.getId(), volunteer.getNickname());
- }
-
- return volunteerNicknames;
+ private Map<UUID, String> mapVolunteerIdsToNicknames(List<UUID> volunteerIds) {
+ return volunteerQueryUseCase.getVolunteerNicknameAndIdsByIds(volunteerIds)
+ .stream()
+ .collect(Collectors.toMap(VolunteerNicknameAndId::id,
+ VolunteerNicknameAndId::nickname));
}
} | Java | ๋ณต์ํ ์ ์ ํฉํ ๋ฆฌ ๋ฉ์๋ |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
+ }
+
+ addComment = () => {
+ const { comment, commentInputValue } = this.state;
+ if (commentInputValue.length >= 1) {
+ const newComment = {
+ id: comment.length + 1,
+ content: commentInputValue,
+ isLiked: false,
+ };
+ this.setState({
+ comment: [...comment, newComment],
+ commentInputValue: '',
+ });
+ }
+ };
+
+ deleteComment = e => {
+ const { comment } = this.state;
+ const deleteCommentId = Number(e.target.id);
+ const result = comment.filter(comment => comment.id !== deleteCommentId);
+ this.setState({
+ comment: result,
+ });
+ };
+
+ inputEnterPress = e => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ this.addComment();
+ }
+ };
+
+ onChange = e => {
+ const { value } = e.target;
+ this.setState({
+ commentInputValue: value,
+ });
+ };
+
+ render() {
+ const { inputEnterPress, onChange, addComment, deleteComment } = this;
+ const { commentInputValue, comment } = this.state;
+ const { alt, img, userName } = this.props.data;
+
+ return (
+ <div className="feed">
+ <article>
+ <div className="feedTop">
+ <div className="feedUser">
+ <img className="smallUserPicture" alt={alt} src={img} />
+ <div className="feedId boldFont">{userName}</div>
+ </div>
+ <img
+ className="feedMore"
+ alt="๋๋ณด๊ธฐ"
+ src="/images/youngho/more.png"
+ />
+ </div>
+ <img className="feedPicture" alt="ํผ๋์ฌ์ง" src={img} />
+ <div className="feedBottom">
+ <div className="feedIcons">
+ <div className="FeedBottomLeftIcon">
+ <img alt="๋นจ๊ฐ์ํํธ" src="/images/youngho/redHeart.png" />
+ <img alt="๋ฉ์ธ์ง" src="/images/youngho/speech-bubble.png" />
+ <img alt="์
๋ก๋" src="/images/youngho/upload.png" />
+ </div>
+ <img alt="์ ์ฅ" src="/images/youngho/ribbon.png" />
+ </div>
+ <div className="like">
+ <img alt="์ข์์๋ฅผ ๋๋ฅธ ์ฌ๋ ์ฌ์ง" src={img} />
+ <span className="boldFont">manja</span>๋
+ <span className="boldFont">์ธ 7๋ช
</span>์ด ์ข์ํฉ๋๋ค
+ </div>
+ {comment.map(comment => {
+ return (
+ <Comment
+ key={comment.id}
+ id={comment.id}
+ userName={comment.userName}
+ comment={comment.content}
+ isLiked={comment.isLiked}
+ deleteComment={deleteComment}
+ />
+ );
+ })}
+ </div>
+ <form className="addCommentFrom">
+ <input
+ className="writeComment"
+ type="text"
+ placeholder="๋๊ธ ๋ฌ๊ธฐ..."
+ onKeyPress={inputEnterPress}
+ onChange={onChange}
+ value={commentInputValue}
+ />
+ <input
+ className={`postingButton ${
+ commentInputValue.length ? 'activeButton' : ''
+ }`}
+ type="button"
+ defaultValue="๊ฒ์"
+ onClick={addComment}
+ disabled={commentInputValue.length ? false : true}
+ />
+ </form>
+ </article>
+ </div>
+ );
+ }
+}
+
+export default Feed; | JavaScript | ๊ตฌ์กฐ๋ถํดํ ๋น์ ์ ์ฐ์ ๊ฑฐ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
+ }
+
+ addComment = () => {
+ const { comment, commentInputValue } = this.state;
+ if (commentInputValue.length >= 1) {
+ const newComment = {
+ id: comment.length + 1,
+ content: commentInputValue,
+ isLiked: false,
+ };
+ this.setState({
+ comment: [...comment, newComment],
+ commentInputValue: '',
+ });
+ }
+ };
+
+ deleteComment = e => {
+ const { comment } = this.state;
+ const deleteCommentId = Number(e.target.id);
+ const result = comment.filter(comment => comment.id !== deleteCommentId);
+ this.setState({
+ comment: result,
+ });
+ };
+
+ inputEnterPress = e => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ this.addComment();
+ }
+ };
+
+ onChange = e => {
+ const { value } = e.target;
+ this.setState({
+ commentInputValue: value,
+ });
+ };
+
+ render() {
+ const { inputEnterPress, onChange, addComment, deleteComment } = this;
+ const { commentInputValue, comment } = this.state;
+ const { alt, img, userName } = this.props.data;
+
+ return (
+ <div className="feed">
+ <article>
+ <div className="feedTop">
+ <div className="feedUser">
+ <img className="smallUserPicture" alt={alt} src={img} />
+ <div className="feedId boldFont">{userName}</div>
+ </div>
+ <img
+ className="feedMore"
+ alt="๋๋ณด๊ธฐ"
+ src="/images/youngho/more.png"
+ />
+ </div>
+ <img className="feedPicture" alt="ํผ๋์ฌ์ง" src={img} />
+ <div className="feedBottom">
+ <div className="feedIcons">
+ <div className="FeedBottomLeftIcon">
+ <img alt="๋นจ๊ฐ์ํํธ" src="/images/youngho/redHeart.png" />
+ <img alt="๋ฉ์ธ์ง" src="/images/youngho/speech-bubble.png" />
+ <img alt="์
๋ก๋" src="/images/youngho/upload.png" />
+ </div>
+ <img alt="์ ์ฅ" src="/images/youngho/ribbon.png" />
+ </div>
+ <div className="like">
+ <img alt="์ข์์๋ฅผ ๋๋ฅธ ์ฌ๋ ์ฌ์ง" src={img} />
+ <span className="boldFont">manja</span>๋
+ <span className="boldFont">์ธ 7๋ช
</span>์ด ์ข์ํฉ๋๋ค
+ </div>
+ {comment.map(comment => {
+ return (
+ <Comment
+ key={comment.id}
+ id={comment.id}
+ userName={comment.userName}
+ comment={comment.content}
+ isLiked={comment.isLiked}
+ deleteComment={deleteComment}
+ />
+ );
+ })}
+ </div>
+ <form className="addCommentFrom">
+ <input
+ className="writeComment"
+ type="text"
+ placeholder="๋๊ธ ๋ฌ๊ธฐ..."
+ onKeyPress={inputEnterPress}
+ onChange={onChange}
+ value={commentInputValue}
+ />
+ <input
+ className={`postingButton ${
+ commentInputValue.length ? 'activeButton' : ''
+ }`}
+ type="button"
+ defaultValue="๊ฒ์"
+ onClick={addComment}
+ disabled={commentInputValue.length ? false : true}
+ />
+ </form>
+ </article>
+ </div>
+ );
+ }
+}
+
+export default Feed; | JavaScript | comment๊ด๋ จ ํจ์๋ฅผ ๊น๋ํ๊ฒ ์ ์ ๋ฆฌํ์ ๊ฑฐ ๊ฐ์ต๋๋ค |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
+ }
+
+ addComment = () => {
+ const { comment, commentInputValue } = this.state;
+ if (commentInputValue.length >= 1) {
+ const newComment = {
+ id: comment.length + 1,
+ content: commentInputValue,
+ isLiked: false,
+ };
+ this.setState({
+ comment: [...comment, newComment],
+ commentInputValue: '',
+ });
+ }
+ };
+
+ deleteComment = e => {
+ const { comment } = this.state;
+ const deleteCommentId = Number(e.target.id);
+ const result = comment.filter(comment => comment.id !== deleteCommentId);
+ this.setState({
+ comment: result,
+ });
+ };
+
+ inputEnterPress = e => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ this.addComment();
+ }
+ };
+
+ onChange = e => {
+ const { value } = e.target;
+ this.setState({
+ commentInputValue: value,
+ });
+ };
+
+ render() {
+ const { inputEnterPress, onChange, addComment, deleteComment } = this;
+ const { commentInputValue, comment } = this.state;
+ const { alt, img, userName } = this.props.data;
+
+ return (
+ <div className="feed">
+ <article>
+ <div className="feedTop">
+ <div className="feedUser">
+ <img className="smallUserPicture" alt={alt} src={img} />
+ <div className="feedId boldFont">{userName}</div>
+ </div>
+ <img
+ className="feedMore"
+ alt="๋๋ณด๊ธฐ"
+ src="/images/youngho/more.png"
+ />
+ </div>
+ <img className="feedPicture" alt="ํผ๋์ฌ์ง" src={img} />
+ <div className="feedBottom">
+ <div className="feedIcons">
+ <div className="FeedBottomLeftIcon">
+ <img alt="๋นจ๊ฐ์ํํธ" src="/images/youngho/redHeart.png" />
+ <img alt="๋ฉ์ธ์ง" src="/images/youngho/speech-bubble.png" />
+ <img alt="์
๋ก๋" src="/images/youngho/upload.png" />
+ </div>
+ <img alt="์ ์ฅ" src="/images/youngho/ribbon.png" />
+ </div>
+ <div className="like">
+ <img alt="์ข์์๋ฅผ ๋๋ฅธ ์ฌ๋ ์ฌ์ง" src={img} />
+ <span className="boldFont">manja</span>๋
+ <span className="boldFont">์ธ 7๋ช
</span>์ด ์ข์ํฉ๋๋ค
+ </div>
+ {comment.map(comment => {
+ return (
+ <Comment
+ key={comment.id}
+ id={comment.id}
+ userName={comment.userName}
+ comment={comment.content}
+ isLiked={comment.isLiked}
+ deleteComment={deleteComment}
+ />
+ );
+ })}
+ </div>
+ <form className="addCommentFrom">
+ <input
+ className="writeComment"
+ type="text"
+ placeholder="๋๊ธ ๋ฌ๊ธฐ..."
+ onKeyPress={inputEnterPress}
+ onChange={onChange}
+ value={commentInputValue}
+ />
+ <input
+ className={`postingButton ${
+ commentInputValue.length ? 'activeButton' : ''
+ }`}
+ type="button"
+ defaultValue="๊ฒ์"
+ onClick={addComment}
+ disabled={commentInputValue.length ? false : true}
+ />
+ </form>
+ </article>
+ </div>
+ );
+ }
+}
+
+export default Feed; | JavaScript | ์ปค๋ฉํธ ์ปดํฌ๋ํธ์ ํ๋กญ์ค ์ ๋ฌ์ ๊น๋ํ๊ฒ ์ ํ์ ๊ฑฐ ๊ฐ์ต๋๋ค |
@@ -1,10 +1,94 @@
import React from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ loginId: '',
+ loginPassword: '',
+ };
+ }
+
+ handleLoginInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ handleLogin = () => {
+ fetch('http://10.58.0.84:8000/users/login', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.loginId,
+ password: this.state.loginPassword,
+ }),
+ })
+ .then(response => response.json())
+ .then(result => console.log('๊ฒฐ๊ณผ: ', result));
+ };
+
+ // handleLogin = () => {
+ // fetch('http://10.58.0.84:8000/users/signup', {
+ // method: 'POST',
+ // body: JSON.stringify({
+ // name: '๊น์ํธ',
+ // email: this.state.loginId,
+ // password: this.state.loginPassword,
+ // phone_number: '01012345678',
+ // date_of_birth: '1995-07-07',
+ // gender: 'M',
+ // address: 'Seoul',
+ // }),
+ // })
+ // .then(response => response.json())
+ // .then(result => console.log('๊ฒฐ๊ณผ: ', result));
+ // };
+
render() {
+ const { checkIdPassword, handleLoginInput } = this;
+ const { loginId, loginPassword } = this.state;
+
+ const condition =
+ loginId.length >= 5 && loginPassword.length >= 5 && loginId.includes('@');
+
return (
<div>
- <h3>๋ก๊ทธ์ธ</h3>
+ <div className="container">
+ <header className="header">Westagram</header>
+ <form className="loginForm" onKeyUp={checkIdPassword}>
+ <input
+ id="id"
+ name="loginId"
+ type="text"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onChange={handleLoginInput}
+ />
+ <input
+ id="password"
+ name="loginPassword"
+ type="password"
+ placeholder="๋น๋ฐ๋ฒํธ"
+ onChange={handleLoginInput}
+ />
+ <Link to="/main">
+ <button
+ onClick={this.handleLogin}
+ className={condition ? 'buttonActivate' : 'buttonDisabled'}
+ id="loginButton"
+ disabled={condition ? false : true}
+ >
+ ๋ก๊ทธ์ธ
+ </button>
+ </Link>
+ </form>
+ <a href="#!" className="findPassword">
+ ๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?
+ </a>
+ </div>
</div>
);
} | JavaScript | ์ผํญ์ฐ์ฐ์ ์ฌ์ฉ์ ์ ํ์ ๊ฑฐ ๊ฐ์ต๋๋ค. |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() {
+ fetch('/data/feedData.json', {
+ method: 'GET',
+ })
+ .then(res => res.json())
+ .then(data => {
+ this.setState({
+ feeds: data,
+ });
+ });
+ }
+
render() {
+ const { feeds } = this.state;
+
+ const STORIES = [
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder1',
+ time: 43,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder2',
+ time: 3,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder3',
+ time: 23,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder4',
+ time: 27,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder5',
+ time: 13,
+ },
+ ];
+
+ const Stories = STORIES.map(store => {
+ return (
+ <div className="story">
+ <img alt={store.alt} src={store.img} />
+ <div>
+ <div className="boldFont">{store.name}</div>
+ <div className="lightFont">{store.time}๋ถ ์ </div>
+ </div>
+ </div>
+ );
+ });
return (
<div>
- <h3>๋ฉ์ธ</h3>
+ <Nav />
+ <main>
+ <div className="content">
+ <div>
+ {feeds.map(feed => {
+ return <Feed key={`feed${feed.id}`} data={feed} />;
+ })}
+ </div>
+ <div className="mainRight">
+ <div className="rightTop">
+ <img
+ className="wecodeLogo"
+ alt="์์ฝ๋ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">wecode_bootcamp</div>
+ <div className="lightFont">WeCode | ์์ฝ๋</div>
+ </div>
+ </div>
+ <div className="rightMiddle">
+ <div className="seeAllStory">
+ <div className="lightFont">์คํ ๋ฆฌ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="seeStory">{Stories}</div>
+ </div>
+ <div className="rightMiddle">
+ <div className="friendsRecommendContainer">
+ <div className="lightFont">ํ์๋์ ์ํ ์ถ์ฒ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="friendsRecommendList">
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">ํ๊ธธ๋</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์๋ฌด๊ฐ</div>
+ <div className="lightFont">์๋์๋๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ด์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ผ์๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ ์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ก์๋ก๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ผ๋ผ์ผ๋ผ</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ </div>
+ </div>
+ <footer>
+ <div className="lightFont">
+ Westagram ์ ๋ณด . ์ง์ . ํ๋ณด ์ผํฐ . API . ์ฑ์ฉ์ ๋ณด .
+ ๊ฐ์ธ์ ๋ณด์ฒ๋ฆฌ๋ฐฉ์นจ . ์ฝ๊ด . ๋๋ ํฐ๋ฆฌ . ํ๋กํ . ํด์ํ๊ทธ . ์ธ์ด
+ </div>
+ <div className="lightFont boldFont">ยฉ 2021 WESTAGRAM</div>
+ </footer>
+ </div>
+ </div>
+ </main>
</div>
);
} | JavaScript | Lifecycle Method๋ฅผ ์ ์ฌ์ฉํ์ ๊ฑฐ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
+ }
+
+ addComment = () => {
+ const { comment, commentInputValue } = this.state;
+ if (commentInputValue.length >= 1) {
+ const newComment = {
+ id: comment.length + 1,
+ content: commentInputValue,
+ isLiked: false,
+ };
+ this.setState({
+ comment: [...comment, newComment],
+ commentInputValue: '',
+ });
+ }
+ };
+
+ deleteComment = e => {
+ const { comment } = this.state;
+ const deleteCommentId = Number(e.target.id);
+ const result = comment.filter(comment => comment.id !== deleteCommentId);
+ this.setState({
+ comment: result,
+ });
+ };
+
+ inputEnterPress = e => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ this.addComment();
+ }
+ };
+
+ onChange = e => {
+ const { value } = e.target;
+ this.setState({
+ commentInputValue: value,
+ });
+ };
+
+ render() {
+ const { inputEnterPress, onChange, addComment, deleteComment } = this;
+ const { commentInputValue, comment } = this.state;
+ const { alt, img, userName } = this.props.data;
+
+ return (
+ <div className="feed">
+ <article>
+ <div className="feedTop">
+ <div className="feedUser">
+ <img className="smallUserPicture" alt={alt} src={img} />
+ <div className="feedId boldFont">{userName}</div>
+ </div>
+ <img
+ className="feedMore"
+ alt="๋๋ณด๊ธฐ"
+ src="/images/youngho/more.png"
+ />
+ </div>
+ <img className="feedPicture" alt="ํผ๋์ฌ์ง" src={img} />
+ <div className="feedBottom">
+ <div className="feedIcons">
+ <div className="FeedBottomLeftIcon">
+ <img alt="๋นจ๊ฐ์ํํธ" src="/images/youngho/redHeart.png" />
+ <img alt="๋ฉ์ธ์ง" src="/images/youngho/speech-bubble.png" />
+ <img alt="์
๋ก๋" src="/images/youngho/upload.png" />
+ </div>
+ <img alt="์ ์ฅ" src="/images/youngho/ribbon.png" />
+ </div>
+ <div className="like">
+ <img alt="์ข์์๋ฅผ ๋๋ฅธ ์ฌ๋ ์ฌ์ง" src={img} />
+ <span className="boldFont">manja</span>๋
+ <span className="boldFont">์ธ 7๋ช
</span>์ด ์ข์ํฉ๋๋ค
+ </div>
+ {comment.map(comment => {
+ return (
+ <Comment
+ key={comment.id}
+ id={comment.id}
+ userName={comment.userName}
+ comment={comment.content}
+ isLiked={comment.isLiked}
+ deleteComment={deleteComment}
+ />
+ );
+ })}
+ </div>
+ <form className="addCommentFrom">
+ <input
+ className="writeComment"
+ type="text"
+ placeholder="๋๊ธ ๋ฌ๊ธฐ..."
+ onKeyPress={inputEnterPress}
+ onChange={onChange}
+ value={commentInputValue}
+ />
+ <input
+ className={`postingButton ${
+ commentInputValue.length ? 'activeButton' : ''
+ }`}
+ type="button"
+ defaultValue="๊ฒ์"
+ onClick={addComment}
+ disabled={commentInputValue.length ? false : true}
+ />
+ </form>
+ </article>
+ </div>
+ );
+ }
+}
+
+export default Feed; | JavaScript | ์ ๋ ์ ์ฉํด๋ณด๊ฒ ์ต๋๋ค!๐ |
@@ -1,10 +1,94 @@
import React from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ loginId: '',
+ loginPassword: '',
+ };
+ }
+
+ handleLoginInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ handleLogin = () => {
+ fetch('http://10.58.0.84:8000/users/login', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.loginId,
+ password: this.state.loginPassword,
+ }),
+ })
+ .then(response => response.json())
+ .then(result => console.log('๊ฒฐ๊ณผ: ', result));
+ };
+
+ // handleLogin = () => {
+ // fetch('http://10.58.0.84:8000/users/signup', {
+ // method: 'POST',
+ // body: JSON.stringify({
+ // name: '๊น์ํธ',
+ // email: this.state.loginId,
+ // password: this.state.loginPassword,
+ // phone_number: '01012345678',
+ // date_of_birth: '1995-07-07',
+ // gender: 'M',
+ // address: 'Seoul',
+ // }),
+ // })
+ // .then(response => response.json())
+ // .then(result => console.log('๊ฒฐ๊ณผ: ', result));
+ // };
+
render() {
+ const { checkIdPassword, handleLoginInput } = this;
+ const { loginId, loginPassword } = this.state;
+
+ const condition =
+ loginId.length >= 5 && loginPassword.length >= 5 && loginId.includes('@');
+
return (
<div>
- <h3>๋ก๊ทธ์ธ</h3>
+ <div className="container">
+ <header className="header">Westagram</header>
+ <form className="loginForm" onKeyUp={checkIdPassword}>
+ <input
+ id="id"
+ name="loginId"
+ type="text"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onChange={handleLoginInput}
+ />
+ <input
+ id="password"
+ name="loginPassword"
+ type="password"
+ placeholder="๋น๋ฐ๋ฒํธ"
+ onChange={handleLoginInput}
+ />
+ <Link to="/main">
+ <button
+ onClick={this.handleLogin}
+ className={condition ? 'buttonActivate' : 'buttonDisabled'}
+ id="loginButton"
+ disabled={condition ? false : true}
+ >
+ ๋ก๊ทธ์ธ
+ </button>
+ </Link>
+ </form>
+ <a href="#!" className="findPassword">
+ ๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?
+ </a>
+ </div>
</div>
);
} | JavaScript | ๋ฒํผ์ด ํ์ฑํ๋ ๋ ์์ ๋ณ๊ฒฝ๊ณผ ๋นํ์ฑํ ๊ธฐ๋ฅ๊น์ง ๊ตฌํํ์ ์ ๋ฐฐ์๊ฐ๋๋ค:) |
@@ -0,0 +1,74 @@
+[
+ {
+ "id": 1,
+ "userName": "bbangho",
+ "alt": "wecode",
+ "img": "/images/youngho/hanRiver.jpeg",
+ "comment": [
+ {
+ "id": 1,
+ "userName": "bbangho",
+ "content": "ํ๊ฐ ๋ค๋
๊ฐ~ โ๏ธ",
+ "isLiked": true
+ },
+ {
+ "id": 2,
+ "userName": "manja",
+ "content": "ํ๊ฐ ๊ฐฑ~ ๐ซ ๐ซ",
+ "isLiked": true
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "userName": "joonsikyang",
+ "alt": "wecode",
+ "img": "/images/youngho/we.jpeg",
+ "comment": [
+ {
+ "id": 1,
+ "userName": "joonsikyang",
+ "content": "Work hard ๐คฏ",
+ "isLiked": true
+ },
+ {
+ "id": 2,
+ "userName": "bbangho",
+ "content": "Go for it ๐คฃ",
+ "isLiked": false
+ },
+ {
+ "id": 3,
+ "userName": "manja",
+ "content": "๐ฅ๐ฅ",
+ "isLiked": false
+ }
+ ]
+ },
+ {
+ "id": 3,
+ "userName": "jayPark",
+ "alt": "wecode",
+ "img": "/images/youngho/we.jpeg",
+ "comment": [
+ {
+ "id": 1,
+ "userName": "jayPark",
+ "content": "Let's get it",
+ "isLiked": true
+ },
+ {
+ "id": 2,
+ "userName": "bbanho",
+ "content": "Skrt~ ๐",
+ "isLiked": false
+ },
+ {
+ "id": 3,
+ "userName": "gildong",
+ "content": "Yo~ ๐",
+ "isLiked": true
+ }
+ ]
+ }
+] | Unknown | ๋ชฉ๋ฐ์ดํฐ ์ฌ์ฉ ๋๋ฌด ์ข์ต๋๋ค! :) |
@@ -1,10 +1,94 @@
import React from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ loginId: '',
+ loginPassword: '',
+ };
+ }
+
+ handleLoginInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ handleLogin = () => {
+ fetch('http://10.58.0.84:8000/users/login', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.loginId,
+ password: this.state.loginPassword,
+ }),
+ })
+ .then(response => response.json())
+ .then(result => console.log('๊ฒฐ๊ณผ: ', result));
+ };
+
+ // handleLogin = () => {
+ // fetch('http://10.58.0.84:8000/users/signup', {
+ // method: 'POST',
+ // body: JSON.stringify({
+ // name: '๊น์ํธ',
+ // email: this.state.loginId,
+ // password: this.state.loginPassword,
+ // phone_number: '01012345678',
+ // date_of_birth: '1995-07-07',
+ // gender: 'M',
+ // address: 'Seoul',
+ // }),
+ // })
+ // .then(response => response.json())
+ // .then(result => console.log('๊ฒฐ๊ณผ: ', result));
+ // };
+
render() {
+ const { checkIdPassword, handleLoginInput } = this;
+ const { loginId, loginPassword } = this.state;
+
+ const condition =
+ loginId.length >= 5 && loginPassword.length >= 5 && loginId.includes('@');
+
return (
<div>
- <h3>๋ก๊ทธ์ธ</h3>
+ <div className="container">
+ <header className="header">Westagram</header>
+ <form className="loginForm" onKeyUp={checkIdPassword}>
+ <input
+ id="id"
+ name="loginId"
+ type="text"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onChange={handleLoginInput}
+ />
+ <input
+ id="password"
+ name="loginPassword"
+ type="password"
+ placeholder="๋น๋ฐ๋ฒํธ"
+ onChange={handleLoginInput}
+ />
+ <Link to="/main">
+ <button
+ onClick={this.handleLogin}
+ className={condition ? 'buttonActivate' : 'buttonDisabled'}
+ id="loginButton"
+ disabled={condition ? false : true}
+ >
+ ๋ก๊ทธ์ธ
+ </button>
+ </Link>
+ </form>
+ <a href="#!" className="findPassword">
+ ๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?
+ </a>
+ </div>
</div>
);
} | JavaScript | ```suggestion
<button
onClick={this.handleLogin}
className={condition ? 'buttonActivate' : 'buttonDisabled'}
id="loginButton"
disabled={ condition ? false : true}
>
๋ก๊ทธ์ธ
</button>
```
ํด๋น ์กฐ๊ฑด์ condition์ด๋ผ๋ ๋ณ์์ ๋ด์์ ์ฌ์ฉํ์๋ฉด ๊ฐ๋
์ฑ์ด ๋ ์ข์์ง๊ฒ ๋ค์!
ex)
```
const condition = loginId.length >= 5 && loginPassword.length >= 5 && loginId.includes('@');
``` |
@@ -1,10 +1,94 @@
import React from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ loginId: '',
+ loginPassword: '',
+ };
+ }
+
+ handleLoginInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ handleLogin = () => {
+ fetch('http://10.58.0.84:8000/users/login', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.loginId,
+ password: this.state.loginPassword,
+ }),
+ })
+ .then(response => response.json())
+ .then(result => console.log('๊ฒฐ๊ณผ: ', result));
+ };
+
+ // handleLogin = () => {
+ // fetch('http://10.58.0.84:8000/users/signup', {
+ // method: 'POST',
+ // body: JSON.stringify({
+ // name: '๊น์ํธ',
+ // email: this.state.loginId,
+ // password: this.state.loginPassword,
+ // phone_number: '01012345678',
+ // date_of_birth: '1995-07-07',
+ // gender: 'M',
+ // address: 'Seoul',
+ // }),
+ // })
+ // .then(response => response.json())
+ // .then(result => console.log('๊ฒฐ๊ณผ: ', result));
+ // };
+
render() {
+ const { checkIdPassword, handleLoginInput } = this;
+ const { loginId, loginPassword } = this.state;
+
+ const condition =
+ loginId.length >= 5 && loginPassword.length >= 5 && loginId.includes('@');
+
return (
<div>
- <h3>๋ก๊ทธ์ธ</h3>
+ <div className="container">
+ <header className="header">Westagram</header>
+ <form className="loginForm" onKeyUp={checkIdPassword}>
+ <input
+ id="id"
+ name="loginId"
+ type="text"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onChange={handleLoginInput}
+ />
+ <input
+ id="password"
+ name="loginPassword"
+ type="password"
+ placeholder="๋น๋ฐ๋ฒํธ"
+ onChange={handleLoginInput}
+ />
+ <Link to="/main">
+ <button
+ onClick={this.handleLogin}
+ className={condition ? 'buttonActivate' : 'buttonDisabled'}
+ id="loginButton"
+ disabled={condition ? false : true}
+ >
+ ๋ก๊ทธ์ธ
+ </button>
+ </Link>
+ </form>
+ <a href="#!" className="findPassword">
+ ๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?
+ </a>
+ </div>
</div>
);
} | JavaScript | ์ฐธ๊ณ ๋ก ์์ ๋ณ์๋ render ํจ์ ๋ด์์ ์ ์ธํด์ฃผ์๋ฉด ๋ฉ๋๋ค!! |
@@ -0,0 +1,78 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+body {
+ background-color: #fafafa;
+}
+
+.container {
+ text-align: center;
+ width: 600px;
+ height: 600px;
+ margin: 50px auto 0 auto;
+ border: 1px solid #e6e6e6;
+ background-color: white;
+}
+
+.header {
+ padding: 30px;
+ font-family: 'Lobster', cursive;
+ font-size: 70px;
+ font-weight: 1px;
+}
+
+.loginForm {
+ width: 425px;
+ margin: 0 auto;
+}
+
+#id {
+ display: block;
+ width: 100%;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 1px solid #efefef;
+ background-color: #fafafa;
+ border-radius: 5px;
+ font-size: 20px;
+}
+
+#password {
+ display: block;
+ width: 100%;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 1px solid #efefef;
+ background-color: #fafafa;
+ border-radius: 5px;
+ font-size: 20px;
+}
+
+#loginButton {
+ display: block;
+ width: 459px;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 0px;
+ border-radius: 5px;
+ color: white;
+ font-size: 20px;
+}
+
+.findPassword {
+ display: block;
+ height: 50px;
+ margin-top: 180px;
+ font-size: 18px;
+ text-decoration: none;
+}
+
+.buttonDisabled {
+ background-color: #c5e1fc;
+}
+
+.buttonActivate {
+ background-color: #0095f6;
+}
+
+a {
+ text-decoration: none;
+} | Unknown | ```suggestion
body {
background-color: #fafafa;
}
.container {
text-align: center;
border: 1px solid #e6e6e6;
background-color: white;
width: 600px;
height: 600px;
margin: 50px auto 0 auto;
}
.header {
font-family: 'Lobster', cursive;
font-size: 70px;
font-weight: 1px;
padding: 30px;
}
```
๊ฐ๋
์ฑ์ ์ํด ์
๋ญํฐ ์์ํ ๋๋ ํ ์ค ๋์์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. |
@@ -0,0 +1,78 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+body {
+ background-color: #fafafa;
+}
+
+.container {
+ text-align: center;
+ width: 600px;
+ height: 600px;
+ margin: 50px auto 0 auto;
+ border: 1px solid #e6e6e6;
+ background-color: white;
+}
+
+.header {
+ padding: 30px;
+ font-family: 'Lobster', cursive;
+ font-size: 70px;
+ font-weight: 1px;
+}
+
+.loginForm {
+ width: 425px;
+ margin: 0 auto;
+}
+
+#id {
+ display: block;
+ width: 100%;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 1px solid #efefef;
+ background-color: #fafafa;
+ border-radius: 5px;
+ font-size: 20px;
+}
+
+#password {
+ display: block;
+ width: 100%;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 1px solid #efefef;
+ background-color: #fafafa;
+ border-radius: 5px;
+ font-size: 20px;
+}
+
+#loginButton {
+ display: block;
+ width: 459px;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 0px;
+ border-radius: 5px;
+ color: white;
+ font-size: 20px;
+}
+
+.findPassword {
+ display: block;
+ height: 50px;
+ margin-top: 180px;
+ font-size: 18px;
+ text-decoration: none;
+}
+
+.buttonDisabled {
+ background-color: #c5e1fc;
+}
+
+.buttonActivate {
+ background-color: #0095f6;
+}
+
+a {
+ text-decoration: none;
+} | Unknown | ์ํธ๋! ์ ์ฒด์ ์ผ๋ก CSS ์์ฑ ์์ ํ์ธํด์ ์ ์ฉํด์ฃผ์ธ์~
- ํ๋์ ์์์ ์ฌ๋ฌ๊ฐ์ง ์์ฑ์ ๋ถ์ฌํ๋ ๊ฒฝ์ฐ ์ค์๋, ๊ด๋ จ๋์ ๋ฐ๋ผ์ ๋๋ฆ์ convention์ ์ง์ผ์ ์์ฑํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
- ์ผ๋ฐ์ ์ธ convention ์ ์๋์ ๊ฐ์ต๋๋ค. ์๋์ ๊ฐ์ด ์์ ์ ์ฉํด์ฃผ์ธ์.
[CSS property ์์]
- Layout Properties (position, float, clear, display)
- Box Model Properties (width, height, margin, padding)
- Visual Properties (color, background, border, box-shadow)
- Typography Properties (font-size, font-family, text-align, text-transform)
- Misc Properties (cursor, overflow, z-index) |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() {
+ fetch('/data/feedData.json', {
+ method: 'GET',
+ })
+ .then(res => res.json())
+ .then(data => {
+ this.setState({
+ feeds: data,
+ });
+ });
+ }
+
render() {
+ const { feeds } = this.state;
+
+ const STORIES = [
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder1',
+ time: 43,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder2',
+ time: 3,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder3',
+ time: 23,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder4',
+ time: 27,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder5',
+ time: 13,
+ },
+ ];
+
+ const Stories = STORIES.map(store => {
+ return (
+ <div className="story">
+ <img alt={store.alt} src={store.img} />
+ <div>
+ <div className="boldFont">{store.name}</div>
+ <div className="lightFont">{store.time}๋ถ ์ </div>
+ </div>
+ </div>
+ );
+ });
return (
<div>
- <h3>๋ฉ์ธ</h3>
+ <Nav />
+ <main>
+ <div className="content">
+ <div>
+ {feeds.map(feed => {
+ return <Feed key={`feed${feed.id}`} data={feed} />;
+ })}
+ </div>
+ <div className="mainRight">
+ <div className="rightTop">
+ <img
+ className="wecodeLogo"
+ alt="์์ฝ๋ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">wecode_bootcamp</div>
+ <div className="lightFont">WeCode | ์์ฝ๋</div>
+ </div>
+ </div>
+ <div className="rightMiddle">
+ <div className="seeAllStory">
+ <div className="lightFont">์คํ ๋ฆฌ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="seeStory">{Stories}</div>
+ </div>
+ <div className="rightMiddle">
+ <div className="friendsRecommendContainer">
+ <div className="lightFont">ํ์๋์ ์ํ ์ถ์ฒ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="friendsRecommendList">
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">ํ๊ธธ๋</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์๋ฌด๊ฐ</div>
+ <div className="lightFont">์๋์๋๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ด์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ผ์๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ ์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ก์๋ก๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ผ๋ผ์ผ๋ผ</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ </div>
+ </div>
+ <footer>
+ <div className="lightFont">
+ Westagram ์ ๋ณด . ์ง์ . ํ๋ณด ์ผํฐ . API . ์ฑ์ฉ์ ๋ณด .
+ ๊ฐ์ธ์ ๋ณด์ฒ๋ฆฌ๋ฐฉ์นจ . ์ฝ๊ด . ๋๋ ํฐ๋ฆฌ . ํ๋กํ . ํด์ํ๊ทธ . ์ธ์ด
+ </div>
+ <div className="lightFont boldFont">ยฉ 2021 WESTAGRAM</div>
+ </footer>
+ </div>
+ </div>
+ </main>
</div>
);
} | JavaScript | import ์์๋ ์ ๋ง์ถฐ์ฃผ์
จ๊ณ , ํด๋น ๋ถ๋ถ์์๋ ์ค๋ฐ๊ฟ ์์ด ์งํํด์ฃผ์ธ์~ |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() {
+ fetch('/data/feedData.json', {
+ method: 'GET',
+ })
+ .then(res => res.json())
+ .then(data => {
+ this.setState({
+ feeds: data,
+ });
+ });
+ }
+
render() {
+ const { feeds } = this.state;
+
+ const STORIES = [
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder1',
+ time: 43,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder2',
+ time: 3,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder3',
+ time: 23,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder4',
+ time: 27,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder5',
+ time: 13,
+ },
+ ];
+
+ const Stories = STORIES.map(store => {
+ return (
+ <div className="story">
+ <img alt={store.alt} src={store.img} />
+ <div>
+ <div className="boldFont">{store.name}</div>
+ <div className="lightFont">{store.time}๋ถ ์ </div>
+ </div>
+ </div>
+ );
+ });
return (
<div>
- <h3>๋ฉ์ธ</h3>
+ <Nav />
+ <main>
+ <div className="content">
+ <div>
+ {feeds.map(feed => {
+ return <Feed key={`feed${feed.id}`} data={feed} />;
+ })}
+ </div>
+ <div className="mainRight">
+ <div className="rightTop">
+ <img
+ className="wecodeLogo"
+ alt="์์ฝ๋ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">wecode_bootcamp</div>
+ <div className="lightFont">WeCode | ์์ฝ๋</div>
+ </div>
+ </div>
+ <div className="rightMiddle">
+ <div className="seeAllStory">
+ <div className="lightFont">์คํ ๋ฆฌ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="seeStory">{Stories}</div>
+ </div>
+ <div className="rightMiddle">
+ <div className="friendsRecommendContainer">
+ <div className="lightFont">ํ์๋์ ์ํ ์ถ์ฒ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="friendsRecommendList">
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">ํ๊ธธ๋</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์๋ฌด๊ฐ</div>
+ <div className="lightFont">์๋์๋๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ด์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ผ์๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ ์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ก์๋ก๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ผ๋ผ์ผ๋ผ</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ </div>
+ </div>
+ <footer>
+ <div className="lightFont">
+ Westagram ์ ๋ณด . ์ง์ . ํ๋ณด ์ผํฐ . API . ์ฑ์ฉ์ ๋ณด .
+ ๊ฐ์ธ์ ๋ณด์ฒ๋ฆฌ๋ฐฉ์นจ . ์ฝ๊ด . ๋๋ ํฐ๋ฆฌ . ํ๋กํ . ํด์ํ๊ทธ . ์ธ์ด
+ </div>
+ <div className="lightFont boldFont">ยฉ 2021 WESTAGRAM</div>
+ </footer>
+ </div>
+ </div>
+ </main>
</div>
);
} | JavaScript | fetchํจ์์ `get method๋ method์ default` ๊ฐ์
๋๋ค. ๋ฐ๋ผ์ `์๋ต์ด ๊ฐ๋ฅ`ํฉ๋๋ค.
๊ณ ๋ก get method ์์ฒญ์์๋ ์๋์ ๊ฐ์ด ๋๋ฒ์งธ ์ธ์๊ฐ ์๋ต ๊ฐ๋ฅํฉ๋๋ค.
```jsx
const foo = () => {
fetch(`${cartAPI}/quantity`)
.then((res) => res.json())
``` |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() {
+ fetch('/data/feedData.json', {
+ method: 'GET',
+ })
+ .then(res => res.json())
+ .then(data => {
+ this.setState({
+ feeds: data,
+ });
+ });
+ }
+
render() {
+ const { feeds } = this.state;
+
+ const STORIES = [
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder1',
+ time: 43,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder2',
+ time: 3,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder3',
+ time: 23,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder4',
+ time: 27,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder5',
+ time: 13,
+ },
+ ];
+
+ const Stories = STORIES.map(store => {
+ return (
+ <div className="story">
+ <img alt={store.alt} src={store.img} />
+ <div>
+ <div className="boldFont">{store.name}</div>
+ <div className="lightFont">{store.time}๋ถ ์ </div>
+ </div>
+ </div>
+ );
+ });
return (
<div>
- <h3>๋ฉ์ธ</h3>
+ <Nav />
+ <main>
+ <div className="content">
+ <div>
+ {feeds.map(feed => {
+ return <Feed key={`feed${feed.id}`} data={feed} />;
+ })}
+ </div>
+ <div className="mainRight">
+ <div className="rightTop">
+ <img
+ className="wecodeLogo"
+ alt="์์ฝ๋ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">wecode_bootcamp</div>
+ <div className="lightFont">WeCode | ์์ฝ๋</div>
+ </div>
+ </div>
+ <div className="rightMiddle">
+ <div className="seeAllStory">
+ <div className="lightFont">์คํ ๋ฆฌ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="seeStory">{Stories}</div>
+ </div>
+ <div className="rightMiddle">
+ <div className="friendsRecommendContainer">
+ <div className="lightFont">ํ์๋์ ์ํ ์ถ์ฒ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="friendsRecommendList">
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">ํ๊ธธ๋</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์๋ฌด๊ฐ</div>
+ <div className="lightFont">์๋์๋๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ด์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ผ์๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ ์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ก์๋ก๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ผ๋ผ์ผ๋ผ</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ </div>
+ </div>
+ <footer>
+ <div className="lightFont">
+ Westagram ์ ๋ณด . ์ง์ . ํ๋ณด ์ผํฐ . API . ์ฑ์ฉ์ ๋ณด .
+ ๊ฐ์ธ์ ๋ณด์ฒ๋ฆฌ๋ฐฉ์นจ . ์ฝ๊ด . ๋๋ ํฐ๋ฆฌ . ํ๋กํ . ํด์ํ๊ทธ . ์ธ์ด
+ </div>
+ <div className="lightFont boldFont">ยฉ 2021 WESTAGRAM</div>
+ </footer>
+ </div>
+ </div>
+ </main>
</div>
);
} | JavaScript | story ๋ถ๋ถ์ด ์ฌ๋ฌ๋ฒ ๋ฐ๋ณต๋๊ณ ์๋ค์!
์์ ๋ฐ์ดํฐ์ map์ ์ฌ์ฉํด์ ์ค๋ณต๋ ๋ถ๋ถ์ ์ค์ฌ์ฃผ์ธ์!
```
const STORIES = [
{img: "//", name: "wecorder1"}, {img: "//", name: "wecorder2"}, {img: "//", name: "wecorder3"}
];
STORIES.map();
``` |
@@ -0,0 +1,285 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+@media screen and (max-width: 1200px) {
+ .mainRight {
+ display: none;
+ }
+
+ .article {
+ width: 100%;
+ }
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ border-collapse: collapse;
+}
+
+article {
+ width: 800px;
+ background-color: white;
+}
+
+nav {
+ display: flex;
+ justify-content: space-around;
+ align-items: center;
+ margin: 0px 170px;
+ height: 60px;
+}
+
+.logo {
+ width: 30px;
+ height: 30px;
+ padding-right: 15px;
+ border-right: 1px solid black;
+}
+
+.rightIcon {
+ width: 30px;
+ height: 30px;
+ margin-right: 30px;
+}
+
+.instagram {
+ margin-left: 15px;
+ font-family: 'Lobster', cursive;
+ font-size: 33px;
+ font-weight: 1;
+}
+
+.search {
+ outline: none;
+}
+
+.writeComment {
+ width: 100%;
+ height: 40px;
+ padding-left: 10px;
+ border: 1px solid #efefef;
+ outline: none;
+}
+
+.search-box {
+ > input {
+ width: 200px;
+ height: 20px;
+ border: 1px solid #dbdbdb;
+ text-align: center;
+ }
+
+ position: relative;
+ > img {
+ position: absolute;
+ width: 11px;
+ height: 11px;
+ left: 75px;
+ top: 7px;
+ }
+}
+
+main {
+ padding: 60px 0px;
+ background-color: #fafafa;
+}
+
+.content {
+ display: flex;
+ justify-content: space-around;
+ flex-direction: row;
+ margin: 0px 350px;
+}
+
+.mainRight {
+ width: 330px;
+ margin-left: 10px;
+}
+
+.feedTop {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ width: 780px;
+ padding: 10px 10px;
+ border: 1px solid #e6e6e6;
+}
+
+.feedUser {
+ display: flex;
+ align-items: center;
+}
+
+.feedPicture {
+ height: 800px;
+ border: 1px solid #e6e6e6;
+}
+
+.feedId {
+ margin-left: 10px;
+}
+
+.feedMore {
+ width: 15px;
+ height: 15px;
+}
+
+.smallUserPicture {
+ width: 40px;
+ height: 40px;
+ border: 1px solid #e6e6e6;
+ border-radius: 50px;
+}
+
+.feedIcons {
+ > img {
+ width: 27px;
+ height: 27px;
+ }
+
+ > div {
+ > img {
+ width: 27px;
+ height: 27px;
+ }
+ }
+ display: flex;
+ justify-content: space-between;
+ flex-direction: row;
+ margin: 0px;
+}
+
+.feedBottom {
+ padding: 10px 10px;
+ border-left: 1px solid #efefef;
+ border-right: 1px solid #efefef;
+ border-bottom: 1px solid #efefef;
+}
+
+.FeedBottomLeftIcon {
+ > img {
+ padding-right: 10px;
+ }
+}
+
+.like {
+ > img {
+ width: 15px;
+ height: 15px;
+ margin-right: 5px;
+ border: 1px solid #e6e6e6;
+ border-radius: 7px;
+ }
+ display: flex;
+ align-items: center;
+}
+
+.comment {
+ > div {
+ > div {
+ color: #a4a4a4;
+ }
+ }
+}
+
+.commentIcons {
+ float: right;
+ display: inline;
+ width: 15px;
+ height: 15px;
+ margin-left: 5px;
+}
+
+.boldFont {
+ font-weight: bolder;
+}
+
+.addCommentFrom {
+ position: relative;
+ width: 786px;
+}
+
+.postingButton {
+ position: absolute;
+ color: #cde6fc;
+ background-color: white;
+ top: 14px;
+ right: 10px;
+ border: 0;
+ outline: 0;
+}
+
+.rightTop {
+ display: flex;
+ align-items: center;
+ width: 300px;
+}
+
+.wecodeLogo {
+ width: 60px;
+ height: 60px;
+ margin-right: 20px;
+ border-radius: 50px;
+}
+
+.lightFont {
+ color: #9e9e9e;
+}
+
+.followFont {
+ color: #3797f0;
+}
+
+.rightMiddle {
+ height: 200px;
+ margin: 20px 0px;
+ padding: 12px;
+ background: white;
+ border: 3px solid #e6e6e6;
+ border-radius: 7px;
+ overflow: scroll;
+}
+
+.seeAllStory {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.friendsRecommendContainer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.story {
+ display: flex;
+ align-items: center;
+ margin: 10px;
+
+ > img {
+ width: 40px;
+ height: 40px;
+ margin-right: 10px;
+ border-radius: 50px;
+ border: 2px solid #d93081;
+ }
+}
+
+.friendsRecommend {
+ display: flex;
+ align-items: center;
+ margin: 10px;
+ > img {
+ width: 40px;
+ height: 40px;
+ border-radius: 50px;
+ margin-right: 10px;
+ }
+}
+
+footer {
+ margin-top: 20px;
+ > .boldFont {
+ margin-top: 10px;
+ }
+} | Unknown | ๋ฐ์ํ ์์ฃผ ์ข๋ค์!!
๋ธ๋ ์ดํฌ ํฌ์ธํธ๋ ๊ธฐํ๋ง๋ค ๋ฌ๋ผ์ง์ง๋ง ๋ณดํต ํ๋ธ๋ฆฟ๊ณผ ๋ฐ์คํฌํ์ ๊ตฌ๋ถ์ ์ 1078px์ด๋ผ๋ ์ ์์๋์ธ์!
๋ชจ๋ฐ์ผ๊ณผ ํ๋ธ๋ฆฟ์ 768px์
๋๋ค! |
@@ -0,0 +1,285 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+@media screen and (max-width: 1200px) {
+ .mainRight {
+ display: none;
+ }
+
+ .article {
+ width: 100%;
+ }
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ border-collapse: collapse;
+}
+
+article {
+ width: 800px;
+ background-color: white;
+}
+
+nav {
+ display: flex;
+ justify-content: space-around;
+ align-items: center;
+ margin: 0px 170px;
+ height: 60px;
+}
+
+.logo {
+ width: 30px;
+ height: 30px;
+ padding-right: 15px;
+ border-right: 1px solid black;
+}
+
+.rightIcon {
+ width: 30px;
+ height: 30px;
+ margin-right: 30px;
+}
+
+.instagram {
+ margin-left: 15px;
+ font-family: 'Lobster', cursive;
+ font-size: 33px;
+ font-weight: 1;
+}
+
+.search {
+ outline: none;
+}
+
+.writeComment {
+ width: 100%;
+ height: 40px;
+ padding-left: 10px;
+ border: 1px solid #efefef;
+ outline: none;
+}
+
+.search-box {
+ > input {
+ width: 200px;
+ height: 20px;
+ border: 1px solid #dbdbdb;
+ text-align: center;
+ }
+
+ position: relative;
+ > img {
+ position: absolute;
+ width: 11px;
+ height: 11px;
+ left: 75px;
+ top: 7px;
+ }
+}
+
+main {
+ padding: 60px 0px;
+ background-color: #fafafa;
+}
+
+.content {
+ display: flex;
+ justify-content: space-around;
+ flex-direction: row;
+ margin: 0px 350px;
+}
+
+.mainRight {
+ width: 330px;
+ margin-left: 10px;
+}
+
+.feedTop {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ width: 780px;
+ padding: 10px 10px;
+ border: 1px solid #e6e6e6;
+}
+
+.feedUser {
+ display: flex;
+ align-items: center;
+}
+
+.feedPicture {
+ height: 800px;
+ border: 1px solid #e6e6e6;
+}
+
+.feedId {
+ margin-left: 10px;
+}
+
+.feedMore {
+ width: 15px;
+ height: 15px;
+}
+
+.smallUserPicture {
+ width: 40px;
+ height: 40px;
+ border: 1px solid #e6e6e6;
+ border-radius: 50px;
+}
+
+.feedIcons {
+ > img {
+ width: 27px;
+ height: 27px;
+ }
+
+ > div {
+ > img {
+ width: 27px;
+ height: 27px;
+ }
+ }
+ display: flex;
+ justify-content: space-between;
+ flex-direction: row;
+ margin: 0px;
+}
+
+.feedBottom {
+ padding: 10px 10px;
+ border-left: 1px solid #efefef;
+ border-right: 1px solid #efefef;
+ border-bottom: 1px solid #efefef;
+}
+
+.FeedBottomLeftIcon {
+ > img {
+ padding-right: 10px;
+ }
+}
+
+.like {
+ > img {
+ width: 15px;
+ height: 15px;
+ margin-right: 5px;
+ border: 1px solid #e6e6e6;
+ border-radius: 7px;
+ }
+ display: flex;
+ align-items: center;
+}
+
+.comment {
+ > div {
+ > div {
+ color: #a4a4a4;
+ }
+ }
+}
+
+.commentIcons {
+ float: right;
+ display: inline;
+ width: 15px;
+ height: 15px;
+ margin-left: 5px;
+}
+
+.boldFont {
+ font-weight: bolder;
+}
+
+.addCommentFrom {
+ position: relative;
+ width: 786px;
+}
+
+.postingButton {
+ position: absolute;
+ color: #cde6fc;
+ background-color: white;
+ top: 14px;
+ right: 10px;
+ border: 0;
+ outline: 0;
+}
+
+.rightTop {
+ display: flex;
+ align-items: center;
+ width: 300px;
+}
+
+.wecodeLogo {
+ width: 60px;
+ height: 60px;
+ margin-right: 20px;
+ border-radius: 50px;
+}
+
+.lightFont {
+ color: #9e9e9e;
+}
+
+.followFont {
+ color: #3797f0;
+}
+
+.rightMiddle {
+ height: 200px;
+ margin: 20px 0px;
+ padding: 12px;
+ background: white;
+ border: 3px solid #e6e6e6;
+ border-radius: 7px;
+ overflow: scroll;
+}
+
+.seeAllStory {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.friendsRecommendContainer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.story {
+ display: flex;
+ align-items: center;
+ margin: 10px;
+
+ > img {
+ width: 40px;
+ height: 40px;
+ margin-right: 10px;
+ border-radius: 50px;
+ border: 2px solid #d93081;
+ }
+}
+
+.friendsRecommend {
+ display: flex;
+ align-items: center;
+ margin: 10px;
+ > img {
+ width: 40px;
+ height: 40px;
+ border-radius: 50px;
+ margin-right: 10px;
+ }
+}
+
+footer {
+ margin-top: 20px;
+ > .boldFont {
+ margin-top: 10px;
+ }
+} | Unknown | ๊ฐ์ ์คํ์ผ์ ๊ฒฝ์ฐ์๋ ์ค๋ณตํ์ฌ ์ฃผ์์ง ๋ง๊ณ ๊ฐ์ ํด๋์ค๋ช
์ ์ฌ์ฉํ์
๋ ๋ฉ๋๋ค! |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
+ }
+
+ addComment = () => {
+ const { comment, commentInputValue } = this.state;
+ if (commentInputValue.length >= 1) {
+ const newComment = {
+ id: comment.length + 1,
+ content: commentInputValue,
+ isLiked: false,
+ };
+ this.setState({
+ comment: [...comment, newComment],
+ commentInputValue: '',
+ });
+ }
+ };
+
+ deleteComment = e => {
+ const { comment } = this.state;
+ const deleteCommentId = Number(e.target.id);
+ const result = comment.filter(comment => comment.id !== deleteCommentId);
+ this.setState({
+ comment: result,
+ });
+ };
+
+ inputEnterPress = e => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ this.addComment();
+ }
+ };
+
+ onChange = e => {
+ const { value } = e.target;
+ this.setState({
+ commentInputValue: value,
+ });
+ };
+
+ render() {
+ const { inputEnterPress, onChange, addComment, deleteComment } = this;
+ const { commentInputValue, comment } = this.state;
+ const { alt, img, userName } = this.props.data;
+
+ return (
+ <div className="feed">
+ <article>
+ <div className="feedTop">
+ <div className="feedUser">
+ <img className="smallUserPicture" alt={alt} src={img} />
+ <div className="feedId boldFont">{userName}</div>
+ </div>
+ <img
+ className="feedMore"
+ alt="๋๋ณด๊ธฐ"
+ src="/images/youngho/more.png"
+ />
+ </div>
+ <img className="feedPicture" alt="ํผ๋์ฌ์ง" src={img} />
+ <div className="feedBottom">
+ <div className="feedIcons">
+ <div className="FeedBottomLeftIcon">
+ <img alt="๋นจ๊ฐ์ํํธ" src="/images/youngho/redHeart.png" />
+ <img alt="๋ฉ์ธ์ง" src="/images/youngho/speech-bubble.png" />
+ <img alt="์
๋ก๋" src="/images/youngho/upload.png" />
+ </div>
+ <img alt="์ ์ฅ" src="/images/youngho/ribbon.png" />
+ </div>
+ <div className="like">
+ <img alt="์ข์์๋ฅผ ๋๋ฅธ ์ฌ๋ ์ฌ์ง" src={img} />
+ <span className="boldFont">manja</span>๋
+ <span className="boldFont">์ธ 7๋ช
</span>์ด ์ข์ํฉ๋๋ค
+ </div>
+ {comment.map(comment => {
+ return (
+ <Comment
+ key={comment.id}
+ id={comment.id}
+ userName={comment.userName}
+ comment={comment.content}
+ isLiked={comment.isLiked}
+ deleteComment={deleteComment}
+ />
+ );
+ })}
+ </div>
+ <form className="addCommentFrom">
+ <input
+ className="writeComment"
+ type="text"
+ placeholder="๋๊ธ ๋ฌ๊ธฐ..."
+ onKeyPress={inputEnterPress}
+ onChange={onChange}
+ value={commentInputValue}
+ />
+ <input
+ className={`postingButton ${
+ commentInputValue.length ? 'activeButton' : ''
+ }`}
+ type="button"
+ defaultValue="๊ฒ์"
+ onClick={addComment}
+ disabled={commentInputValue.length ? false : true}
+ />
+ </form>
+ </article>
+ </div>
+ );
+ }
+}
+
+export default Feed; | JavaScript | import ๊ตฌ๋ถ์ ๋๋ฌด ์ข์ง๋ง ์ค๋ฐ๊ฟ์ ์ํ์
๋ ๋ฉ๋๋ค!!! |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
+ }
+
+ addComment = () => {
+ const { comment, commentInputValue } = this.state;
+ if (commentInputValue.length >= 1) {
+ const newComment = {
+ id: comment.length + 1,
+ content: commentInputValue,
+ isLiked: false,
+ };
+ this.setState({
+ comment: [...comment, newComment],
+ commentInputValue: '',
+ });
+ }
+ };
+
+ deleteComment = e => {
+ const { comment } = this.state;
+ const deleteCommentId = Number(e.target.id);
+ const result = comment.filter(comment => comment.id !== deleteCommentId);
+ this.setState({
+ comment: result,
+ });
+ };
+
+ inputEnterPress = e => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ this.addComment();
+ }
+ };
+
+ onChange = e => {
+ const { value } = e.target;
+ this.setState({
+ commentInputValue: value,
+ });
+ };
+
+ render() {
+ const { inputEnterPress, onChange, addComment, deleteComment } = this;
+ const { commentInputValue, comment } = this.state;
+ const { alt, img, userName } = this.props.data;
+
+ return (
+ <div className="feed">
+ <article>
+ <div className="feedTop">
+ <div className="feedUser">
+ <img className="smallUserPicture" alt={alt} src={img} />
+ <div className="feedId boldFont">{userName}</div>
+ </div>
+ <img
+ className="feedMore"
+ alt="๋๋ณด๊ธฐ"
+ src="/images/youngho/more.png"
+ />
+ </div>
+ <img className="feedPicture" alt="ํผ๋์ฌ์ง" src={img} />
+ <div className="feedBottom">
+ <div className="feedIcons">
+ <div className="FeedBottomLeftIcon">
+ <img alt="๋นจ๊ฐ์ํํธ" src="/images/youngho/redHeart.png" />
+ <img alt="๋ฉ์ธ์ง" src="/images/youngho/speech-bubble.png" />
+ <img alt="์
๋ก๋" src="/images/youngho/upload.png" />
+ </div>
+ <img alt="์ ์ฅ" src="/images/youngho/ribbon.png" />
+ </div>
+ <div className="like">
+ <img alt="์ข์์๋ฅผ ๋๋ฅธ ์ฌ๋ ์ฌ์ง" src={img} />
+ <span className="boldFont">manja</span>๋
+ <span className="boldFont">์ธ 7๋ช
</span>์ด ์ข์ํฉ๋๋ค
+ </div>
+ {comment.map(comment => {
+ return (
+ <Comment
+ key={comment.id}
+ id={comment.id}
+ userName={comment.userName}
+ comment={comment.content}
+ isLiked={comment.isLiked}
+ deleteComment={deleteComment}
+ />
+ );
+ })}
+ </div>
+ <form className="addCommentFrom">
+ <input
+ className="writeComment"
+ type="text"
+ placeholder="๋๊ธ ๋ฌ๊ธฐ..."
+ onKeyPress={inputEnterPress}
+ onChange={onChange}
+ value={commentInputValue}
+ />
+ <input
+ className={`postingButton ${
+ commentInputValue.length ? 'activeButton' : ''
+ }`}
+ type="button"
+ defaultValue="๊ฒ์"
+ onClick={addComment}
+ disabled={commentInputValue.length ? false : true}
+ />
+ </form>
+ </article>
+ </div>
+ );
+ }
+}
+
+export default Feed; | JavaScript | ์ด๋ ๊ฒ ๊ตฌ์กฐ๋ถํดํ ๋น ๋๋ฌด ์ข๋ค์!! |
@@ -0,0 +1,74 @@
+[
+ {
+ "id": 1,
+ "userName": "bbangho",
+ "alt": "wecode",
+ "img": "/images/youngho/hanRiver.jpeg",
+ "comment": [
+ {
+ "id": 1,
+ "userName": "bbangho",
+ "content": "ํ๊ฐ ๋ค๋
๊ฐ~ โ๏ธ",
+ "isLiked": true
+ },
+ {
+ "id": 2,
+ "userName": "manja",
+ "content": "ํ๊ฐ ๊ฐฑ~ ๐ซ ๐ซ",
+ "isLiked": true
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "userName": "joonsikyang",
+ "alt": "wecode",
+ "img": "/images/youngho/we.jpeg",
+ "comment": [
+ {
+ "id": 1,
+ "userName": "joonsikyang",
+ "content": "Work hard ๐คฏ",
+ "isLiked": true
+ },
+ {
+ "id": 2,
+ "userName": "bbangho",
+ "content": "Go for it ๐คฃ",
+ "isLiked": false
+ },
+ {
+ "id": 3,
+ "userName": "manja",
+ "content": "๐ฅ๐ฅ",
+ "isLiked": false
+ }
+ ]
+ },
+ {
+ "id": 3,
+ "userName": "jayPark",
+ "alt": "wecode",
+ "img": "/images/youngho/we.jpeg",
+ "comment": [
+ {
+ "id": 1,
+ "userName": "jayPark",
+ "content": "Let's get it",
+ "isLiked": true
+ },
+ {
+ "id": 2,
+ "userName": "bbanho",
+ "content": "Skrt~ ๐",
+ "isLiked": false
+ },
+ {
+ "id": 3,
+ "userName": "gildong",
+ "content": "Yo~ ๐",
+ "isLiked": true
+ }
+ ]
+ }
+] | Unknown | ๊ฐ์ฌํฉ๋๋ค! |
@@ -1,10 +1,94 @@
import React from 'react';
+import { Link } from 'react-router-dom';
+
+import './Login.scss';
class Login extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ loginId: '',
+ loginPassword: '',
+ };
+ }
+
+ handleLoginInput = e => {
+ const { value, name } = e.target;
+ this.setState({
+ [name]: value,
+ });
+ };
+
+ handleLogin = () => {
+ fetch('http://10.58.0.84:8000/users/login', {
+ method: 'POST',
+ body: JSON.stringify({
+ email: this.state.loginId,
+ password: this.state.loginPassword,
+ }),
+ })
+ .then(response => response.json())
+ .then(result => console.log('๊ฒฐ๊ณผ: ', result));
+ };
+
+ // handleLogin = () => {
+ // fetch('http://10.58.0.84:8000/users/signup', {
+ // method: 'POST',
+ // body: JSON.stringify({
+ // name: '๊น์ํธ',
+ // email: this.state.loginId,
+ // password: this.state.loginPassword,
+ // phone_number: '01012345678',
+ // date_of_birth: '1995-07-07',
+ // gender: 'M',
+ // address: 'Seoul',
+ // }),
+ // })
+ // .then(response => response.json())
+ // .then(result => console.log('๊ฒฐ๊ณผ: ', result));
+ // };
+
render() {
+ const { checkIdPassword, handleLoginInput } = this;
+ const { loginId, loginPassword } = this.state;
+
+ const condition =
+ loginId.length >= 5 && loginPassword.length >= 5 && loginId.includes('@');
+
return (
<div>
- <h3>๋ก๊ทธ์ธ</h3>
+ <div className="container">
+ <header className="header">Westagram</header>
+ <form className="loginForm" onKeyUp={checkIdPassword}>
+ <input
+ id="id"
+ name="loginId"
+ type="text"
+ placeholder="์ ํ๋ฒํธ, ์ฌ์ฉ์ ์ด๋ฆ ๋๋ ์ด๋ฉ์ผ"
+ onChange={handleLoginInput}
+ />
+ <input
+ id="password"
+ name="loginPassword"
+ type="password"
+ placeholder="๋น๋ฐ๋ฒํธ"
+ onChange={handleLoginInput}
+ />
+ <Link to="/main">
+ <button
+ onClick={this.handleLogin}
+ className={condition ? 'buttonActivate' : 'buttonDisabled'}
+ id="loginButton"
+ disabled={condition ? false : true}
+ >
+ ๋ก๊ทธ์ธ
+ </button>
+ </Link>
+ </form>
+ <a href="#!" className="findPassword">
+ ๋น๋ฐ๋ฒํธ๋ฅผ ์์ผ์
จ๋์?
+ </a>
+ </div>
</div>
);
} | JavaScript | ๋ฐ์ ์๋ฃํ์ต๋๋ค! |
@@ -0,0 +1,78 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+body {
+ background-color: #fafafa;
+}
+
+.container {
+ text-align: center;
+ width: 600px;
+ height: 600px;
+ margin: 50px auto 0 auto;
+ border: 1px solid #e6e6e6;
+ background-color: white;
+}
+
+.header {
+ padding: 30px;
+ font-family: 'Lobster', cursive;
+ font-size: 70px;
+ font-weight: 1px;
+}
+
+.loginForm {
+ width: 425px;
+ margin: 0 auto;
+}
+
+#id {
+ display: block;
+ width: 100%;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 1px solid #efefef;
+ background-color: #fafafa;
+ border-radius: 5px;
+ font-size: 20px;
+}
+
+#password {
+ display: block;
+ width: 100%;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 1px solid #efefef;
+ background-color: #fafafa;
+ border-radius: 5px;
+ font-size: 20px;
+}
+
+#loginButton {
+ display: block;
+ width: 459px;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 0px;
+ border-radius: 5px;
+ color: white;
+ font-size: 20px;
+}
+
+.findPassword {
+ display: block;
+ height: 50px;
+ margin-top: 180px;
+ font-size: 18px;
+ text-decoration: none;
+}
+
+.buttonDisabled {
+ background-color: #c5e1fc;
+}
+
+.buttonActivate {
+ background-color: #0095f6;
+}
+
+a {
+ text-decoration: none;
+} | Unknown | ๋ฐ์ ์๋ฃํ์ต๋๋ค! |
@@ -0,0 +1,78 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+body {
+ background-color: #fafafa;
+}
+
+.container {
+ text-align: center;
+ width: 600px;
+ height: 600px;
+ margin: 50px auto 0 auto;
+ border: 1px solid #e6e6e6;
+ background-color: white;
+}
+
+.header {
+ padding: 30px;
+ font-family: 'Lobster', cursive;
+ font-size: 70px;
+ font-weight: 1px;
+}
+
+.loginForm {
+ width: 425px;
+ margin: 0 auto;
+}
+
+#id {
+ display: block;
+ width: 100%;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 1px solid #efefef;
+ background-color: #fafafa;
+ border-radius: 5px;
+ font-size: 20px;
+}
+
+#password {
+ display: block;
+ width: 100%;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 1px solid #efefef;
+ background-color: #fafafa;
+ border-radius: 5px;
+ font-size: 20px;
+}
+
+#loginButton {
+ display: block;
+ width: 459px;
+ margin: 20px 0px auto;
+ padding: 15px;
+ border: 0px;
+ border-radius: 5px;
+ color: white;
+ font-size: 20px;
+}
+
+.findPassword {
+ display: block;
+ height: 50px;
+ margin-top: 180px;
+ font-size: 18px;
+ text-decoration: none;
+}
+
+.buttonDisabled {
+ background-color: #c5e1fc;
+}
+
+.buttonActivate {
+ background-color: #0095f6;
+}
+
+a {
+ text-decoration: none;
+} | Unknown | ๋ฐ์ ์๋ฃํ์ต๋๋ค! |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() {
+ fetch('/data/feedData.json', {
+ method: 'GET',
+ })
+ .then(res => res.json())
+ .then(data => {
+ this.setState({
+ feeds: data,
+ });
+ });
+ }
+
render() {
+ const { feeds } = this.state;
+
+ const STORIES = [
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder1',
+ time: 43,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder2',
+ time: 3,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder3',
+ time: 23,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder4',
+ time: 27,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder5',
+ time: 13,
+ },
+ ];
+
+ const Stories = STORIES.map(store => {
+ return (
+ <div className="story">
+ <img alt={store.alt} src={store.img} />
+ <div>
+ <div className="boldFont">{store.name}</div>
+ <div className="lightFont">{store.time}๋ถ ์ </div>
+ </div>
+ </div>
+ );
+ });
return (
<div>
- <h3>๋ฉ์ธ</h3>
+ <Nav />
+ <main>
+ <div className="content">
+ <div>
+ {feeds.map(feed => {
+ return <Feed key={`feed${feed.id}`} data={feed} />;
+ })}
+ </div>
+ <div className="mainRight">
+ <div className="rightTop">
+ <img
+ className="wecodeLogo"
+ alt="์์ฝ๋ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">wecode_bootcamp</div>
+ <div className="lightFont">WeCode | ์์ฝ๋</div>
+ </div>
+ </div>
+ <div className="rightMiddle">
+ <div className="seeAllStory">
+ <div className="lightFont">์คํ ๋ฆฌ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="seeStory">{Stories}</div>
+ </div>
+ <div className="rightMiddle">
+ <div className="friendsRecommendContainer">
+ <div className="lightFont">ํ์๋์ ์ํ ์ถ์ฒ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="friendsRecommendList">
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">ํ๊ธธ๋</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์๋ฌด๊ฐ</div>
+ <div className="lightFont">์๋์๋๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ด์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ผ์๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ ์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ก์๋ก๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ผ๋ผ์ผ๋ผ</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ </div>
+ </div>
+ <footer>
+ <div className="lightFont">
+ Westagram ์ ๋ณด . ์ง์ . ํ๋ณด ์ผํฐ . API . ์ฑ์ฉ์ ๋ณด .
+ ๊ฐ์ธ์ ๋ณด์ฒ๋ฆฌ๋ฐฉ์นจ . ์ฝ๊ด . ๋๋ ํฐ๋ฆฌ . ํ๋กํ . ํด์ํ๊ทธ . ์ธ์ด
+ </div>
+ <div className="lightFont boldFont">ยฉ 2021 WESTAGRAM</div>
+ </footer>
+ </div>
+ </div>
+ </main>
</div>
);
} | JavaScript | ๋ฐ์ ์๋ฃํ์ต๋๋ค! |
@@ -1,10 +1,178 @@
import React from 'react';
+import Nav from '../../../components/Nav/Nav';
+import Feed from '../../../components/Feed/Feed';
+import './Main.scss';
+
class Main extends React.Component {
+ constructor() {
+ super();
+ this.state = {
+ feeds: [],
+ };
+ }
+
+ componentDidMount() {
+ fetch('/data/feedData.json', {
+ method: 'GET',
+ })
+ .then(res => res.json())
+ .then(data => {
+ this.setState({
+ feeds: data,
+ });
+ });
+ }
+
render() {
+ const { feeds } = this.state;
+
+ const STORIES = [
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder1',
+ time: 43,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder2',
+ time: 3,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder3',
+ time: 23,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder4',
+ time: 27,
+ },
+ {
+ alt: '์คํ ๋ฆฌ ํ๋กํ ์ฌ์ง',
+ img: '/images/youngho/wecode.png',
+ name: 'wecorder5',
+ time: 13,
+ },
+ ];
+
+ const Stories = STORIES.map(store => {
+ return (
+ <div className="story">
+ <img alt={store.alt} src={store.img} />
+ <div>
+ <div className="boldFont">{store.name}</div>
+ <div className="lightFont">{store.time}๋ถ ์ </div>
+ </div>
+ </div>
+ );
+ });
return (
<div>
- <h3>๋ฉ์ธ</h3>
+ <Nav />
+ <main>
+ <div className="content">
+ <div>
+ {feeds.map(feed => {
+ return <Feed key={`feed${feed.id}`} data={feed} />;
+ })}
+ </div>
+ <div className="mainRight">
+ <div className="rightTop">
+ <img
+ className="wecodeLogo"
+ alt="์์ฝ๋ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">wecode_bootcamp</div>
+ <div className="lightFont">WeCode | ์์ฝ๋</div>
+ </div>
+ </div>
+ <div className="rightMiddle">
+ <div className="seeAllStory">
+ <div className="lightFont">์คํ ๋ฆฌ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="seeStory">{Stories}</div>
+ </div>
+ <div className="rightMiddle">
+ <div className="friendsRecommendContainer">
+ <div className="lightFont">ํ์๋์ ์ํ ์ถ์ฒ</div>
+ <div className="boldFont">๋ชจ๋ ๋ณด๊ธฐ</div>
+ </div>
+ <div className="friendsRecommendList">
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">ํ๊ธธ๋</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์๋ฌด๊ฐ</div>
+ <div className="lightFont">์๋์๋๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ด์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ผ์๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ ์ฉ๊ตฌ</div>
+ <div className="lightFont">์๋ก์๋ก๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ <div className="friendsRecommend">
+ <img
+ alt="์น๊ตฌ์ถ์ฒ ํ๋กํ ์ฌ์ง"
+ src="/images/youngho/wecode.png"
+ />
+ <div>
+ <div className="boldFont">์ผ๋ผ์ผ๋ผ</div>
+ <div className="lightFont">๋ธ๋ผ๋ธ๋ผ๋ ์ธ 2๋ช
์ด ...</div>
+ </div>
+ <div className="followFont boldFont">ํ๋ก์ฐ</div>
+ </div>
+ </div>
+ </div>
+ <footer>
+ <div className="lightFont">
+ Westagram ์ ๋ณด . ์ง์ . ํ๋ณด ์ผํฐ . API . ์ฑ์ฉ์ ๋ณด .
+ ๊ฐ์ธ์ ๋ณด์ฒ๋ฆฌ๋ฐฉ์นจ . ์ฝ๊ด . ๋๋ ํฐ๋ฆฌ . ํ๋กํ . ํด์ํ๊ทธ . ์ธ์ด
+ </div>
+ <div className="lightFont boldFont">ยฉ 2021 WESTAGRAM</div>
+ </footer>
+ </div>
+ </div>
+ </main>
</div>
);
} | JavaScript | ๋ฐ์ ์๋ฃํ์ต๋๋ค! |
@@ -0,0 +1,285 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+@media screen and (max-width: 1200px) {
+ .mainRight {
+ display: none;
+ }
+
+ .article {
+ width: 100%;
+ }
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ border-collapse: collapse;
+}
+
+article {
+ width: 800px;
+ background-color: white;
+}
+
+nav {
+ display: flex;
+ justify-content: space-around;
+ align-items: center;
+ margin: 0px 170px;
+ height: 60px;
+}
+
+.logo {
+ width: 30px;
+ height: 30px;
+ padding-right: 15px;
+ border-right: 1px solid black;
+}
+
+.rightIcon {
+ width: 30px;
+ height: 30px;
+ margin-right: 30px;
+}
+
+.instagram {
+ margin-left: 15px;
+ font-family: 'Lobster', cursive;
+ font-size: 33px;
+ font-weight: 1;
+}
+
+.search {
+ outline: none;
+}
+
+.writeComment {
+ width: 100%;
+ height: 40px;
+ padding-left: 10px;
+ border: 1px solid #efefef;
+ outline: none;
+}
+
+.search-box {
+ > input {
+ width: 200px;
+ height: 20px;
+ border: 1px solid #dbdbdb;
+ text-align: center;
+ }
+
+ position: relative;
+ > img {
+ position: absolute;
+ width: 11px;
+ height: 11px;
+ left: 75px;
+ top: 7px;
+ }
+}
+
+main {
+ padding: 60px 0px;
+ background-color: #fafafa;
+}
+
+.content {
+ display: flex;
+ justify-content: space-around;
+ flex-direction: row;
+ margin: 0px 350px;
+}
+
+.mainRight {
+ width: 330px;
+ margin-left: 10px;
+}
+
+.feedTop {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ width: 780px;
+ padding: 10px 10px;
+ border: 1px solid #e6e6e6;
+}
+
+.feedUser {
+ display: flex;
+ align-items: center;
+}
+
+.feedPicture {
+ height: 800px;
+ border: 1px solid #e6e6e6;
+}
+
+.feedId {
+ margin-left: 10px;
+}
+
+.feedMore {
+ width: 15px;
+ height: 15px;
+}
+
+.smallUserPicture {
+ width: 40px;
+ height: 40px;
+ border: 1px solid #e6e6e6;
+ border-radius: 50px;
+}
+
+.feedIcons {
+ > img {
+ width: 27px;
+ height: 27px;
+ }
+
+ > div {
+ > img {
+ width: 27px;
+ height: 27px;
+ }
+ }
+ display: flex;
+ justify-content: space-between;
+ flex-direction: row;
+ margin: 0px;
+}
+
+.feedBottom {
+ padding: 10px 10px;
+ border-left: 1px solid #efefef;
+ border-right: 1px solid #efefef;
+ border-bottom: 1px solid #efefef;
+}
+
+.FeedBottomLeftIcon {
+ > img {
+ padding-right: 10px;
+ }
+}
+
+.like {
+ > img {
+ width: 15px;
+ height: 15px;
+ margin-right: 5px;
+ border: 1px solid #e6e6e6;
+ border-radius: 7px;
+ }
+ display: flex;
+ align-items: center;
+}
+
+.comment {
+ > div {
+ > div {
+ color: #a4a4a4;
+ }
+ }
+}
+
+.commentIcons {
+ float: right;
+ display: inline;
+ width: 15px;
+ height: 15px;
+ margin-left: 5px;
+}
+
+.boldFont {
+ font-weight: bolder;
+}
+
+.addCommentFrom {
+ position: relative;
+ width: 786px;
+}
+
+.postingButton {
+ position: absolute;
+ color: #cde6fc;
+ background-color: white;
+ top: 14px;
+ right: 10px;
+ border: 0;
+ outline: 0;
+}
+
+.rightTop {
+ display: flex;
+ align-items: center;
+ width: 300px;
+}
+
+.wecodeLogo {
+ width: 60px;
+ height: 60px;
+ margin-right: 20px;
+ border-radius: 50px;
+}
+
+.lightFont {
+ color: #9e9e9e;
+}
+
+.followFont {
+ color: #3797f0;
+}
+
+.rightMiddle {
+ height: 200px;
+ margin: 20px 0px;
+ padding: 12px;
+ background: white;
+ border: 3px solid #e6e6e6;
+ border-radius: 7px;
+ overflow: scroll;
+}
+
+.seeAllStory {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.friendsRecommendContainer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.story {
+ display: flex;
+ align-items: center;
+ margin: 10px;
+
+ > img {
+ width: 40px;
+ height: 40px;
+ margin-right: 10px;
+ border-radius: 50px;
+ border: 2px solid #d93081;
+ }
+}
+
+.friendsRecommend {
+ display: flex;
+ align-items: center;
+ margin: 10px;
+ > img {
+ width: 40px;
+ height: 40px;
+ border-radius: 50px;
+ margin-right: 10px;
+ }
+}
+
+footer {
+ margin-top: 20px;
+ > .boldFont {
+ margin-top: 10px;
+ }
+} | Unknown | ๊ฐ์ฌํฉ๋๋ค! |
@@ -0,0 +1,285 @@
+@import 'https://fonts.googleapis.com/css2?family=Lobster&display=swap';
+@media screen and (max-width: 1200px) {
+ .mainRight {
+ display: none;
+ }
+
+ .article {
+ width: 100%;
+ }
+}
+
+body {
+ margin: 0;
+ padding: 0;
+ border-collapse: collapse;
+}
+
+article {
+ width: 800px;
+ background-color: white;
+}
+
+nav {
+ display: flex;
+ justify-content: space-around;
+ align-items: center;
+ margin: 0px 170px;
+ height: 60px;
+}
+
+.logo {
+ width: 30px;
+ height: 30px;
+ padding-right: 15px;
+ border-right: 1px solid black;
+}
+
+.rightIcon {
+ width: 30px;
+ height: 30px;
+ margin-right: 30px;
+}
+
+.instagram {
+ margin-left: 15px;
+ font-family: 'Lobster', cursive;
+ font-size: 33px;
+ font-weight: 1;
+}
+
+.search {
+ outline: none;
+}
+
+.writeComment {
+ width: 100%;
+ height: 40px;
+ padding-left: 10px;
+ border: 1px solid #efefef;
+ outline: none;
+}
+
+.search-box {
+ > input {
+ width: 200px;
+ height: 20px;
+ border: 1px solid #dbdbdb;
+ text-align: center;
+ }
+
+ position: relative;
+ > img {
+ position: absolute;
+ width: 11px;
+ height: 11px;
+ left: 75px;
+ top: 7px;
+ }
+}
+
+main {
+ padding: 60px 0px;
+ background-color: #fafafa;
+}
+
+.content {
+ display: flex;
+ justify-content: space-around;
+ flex-direction: row;
+ margin: 0px 350px;
+}
+
+.mainRight {
+ width: 330px;
+ margin-left: 10px;
+}
+
+.feedTop {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ width: 780px;
+ padding: 10px 10px;
+ border: 1px solid #e6e6e6;
+}
+
+.feedUser {
+ display: flex;
+ align-items: center;
+}
+
+.feedPicture {
+ height: 800px;
+ border: 1px solid #e6e6e6;
+}
+
+.feedId {
+ margin-left: 10px;
+}
+
+.feedMore {
+ width: 15px;
+ height: 15px;
+}
+
+.smallUserPicture {
+ width: 40px;
+ height: 40px;
+ border: 1px solid #e6e6e6;
+ border-radius: 50px;
+}
+
+.feedIcons {
+ > img {
+ width: 27px;
+ height: 27px;
+ }
+
+ > div {
+ > img {
+ width: 27px;
+ height: 27px;
+ }
+ }
+ display: flex;
+ justify-content: space-between;
+ flex-direction: row;
+ margin: 0px;
+}
+
+.feedBottom {
+ padding: 10px 10px;
+ border-left: 1px solid #efefef;
+ border-right: 1px solid #efefef;
+ border-bottom: 1px solid #efefef;
+}
+
+.FeedBottomLeftIcon {
+ > img {
+ padding-right: 10px;
+ }
+}
+
+.like {
+ > img {
+ width: 15px;
+ height: 15px;
+ margin-right: 5px;
+ border: 1px solid #e6e6e6;
+ border-radius: 7px;
+ }
+ display: flex;
+ align-items: center;
+}
+
+.comment {
+ > div {
+ > div {
+ color: #a4a4a4;
+ }
+ }
+}
+
+.commentIcons {
+ float: right;
+ display: inline;
+ width: 15px;
+ height: 15px;
+ margin-left: 5px;
+}
+
+.boldFont {
+ font-weight: bolder;
+}
+
+.addCommentFrom {
+ position: relative;
+ width: 786px;
+}
+
+.postingButton {
+ position: absolute;
+ color: #cde6fc;
+ background-color: white;
+ top: 14px;
+ right: 10px;
+ border: 0;
+ outline: 0;
+}
+
+.rightTop {
+ display: flex;
+ align-items: center;
+ width: 300px;
+}
+
+.wecodeLogo {
+ width: 60px;
+ height: 60px;
+ margin-right: 20px;
+ border-radius: 50px;
+}
+
+.lightFont {
+ color: #9e9e9e;
+}
+
+.followFont {
+ color: #3797f0;
+}
+
+.rightMiddle {
+ height: 200px;
+ margin: 20px 0px;
+ padding: 12px;
+ background: white;
+ border: 3px solid #e6e6e6;
+ border-radius: 7px;
+ overflow: scroll;
+}
+
+.seeAllStory {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.friendsRecommendContainer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.story {
+ display: flex;
+ align-items: center;
+ margin: 10px;
+
+ > img {
+ width: 40px;
+ height: 40px;
+ margin-right: 10px;
+ border-radius: 50px;
+ border: 2px solid #d93081;
+ }
+}
+
+.friendsRecommend {
+ display: flex;
+ align-items: center;
+ margin: 10px;
+ > img {
+ width: 40px;
+ height: 40px;
+ border-radius: 50px;
+ margin-right: 10px;
+ }
+}
+
+footer {
+ margin-top: 20px;
+ > .boldFont {
+ margin-top: 10px;
+ }
+} | Unknown | ๋ฐ์ ์๋ฃํ์ต๋๋ค! |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
+ }
+
+ addComment = () => {
+ const { comment, commentInputValue } = this.state;
+ if (commentInputValue.length >= 1) {
+ const newComment = {
+ id: comment.length + 1,
+ content: commentInputValue,
+ isLiked: false,
+ };
+ this.setState({
+ comment: [...comment, newComment],
+ commentInputValue: '',
+ });
+ }
+ };
+
+ deleteComment = e => {
+ const { comment } = this.state;
+ const deleteCommentId = Number(e.target.id);
+ const result = comment.filter(comment => comment.id !== deleteCommentId);
+ this.setState({
+ comment: result,
+ });
+ };
+
+ inputEnterPress = e => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ this.addComment();
+ }
+ };
+
+ onChange = e => {
+ const { value } = e.target;
+ this.setState({
+ commentInputValue: value,
+ });
+ };
+
+ render() {
+ const { inputEnterPress, onChange, addComment, deleteComment } = this;
+ const { commentInputValue, comment } = this.state;
+ const { alt, img, userName } = this.props.data;
+
+ return (
+ <div className="feed">
+ <article>
+ <div className="feedTop">
+ <div className="feedUser">
+ <img className="smallUserPicture" alt={alt} src={img} />
+ <div className="feedId boldFont">{userName}</div>
+ </div>
+ <img
+ className="feedMore"
+ alt="๋๋ณด๊ธฐ"
+ src="/images/youngho/more.png"
+ />
+ </div>
+ <img className="feedPicture" alt="ํผ๋์ฌ์ง" src={img} />
+ <div className="feedBottom">
+ <div className="feedIcons">
+ <div className="FeedBottomLeftIcon">
+ <img alt="๋นจ๊ฐ์ํํธ" src="/images/youngho/redHeart.png" />
+ <img alt="๋ฉ์ธ์ง" src="/images/youngho/speech-bubble.png" />
+ <img alt="์
๋ก๋" src="/images/youngho/upload.png" />
+ </div>
+ <img alt="์ ์ฅ" src="/images/youngho/ribbon.png" />
+ </div>
+ <div className="like">
+ <img alt="์ข์์๋ฅผ ๋๋ฅธ ์ฌ๋ ์ฌ์ง" src={img} />
+ <span className="boldFont">manja</span>๋
+ <span className="boldFont">์ธ 7๋ช
</span>์ด ์ข์ํฉ๋๋ค
+ </div>
+ {comment.map(comment => {
+ return (
+ <Comment
+ key={comment.id}
+ id={comment.id}
+ userName={comment.userName}
+ comment={comment.content}
+ isLiked={comment.isLiked}
+ deleteComment={deleteComment}
+ />
+ );
+ })}
+ </div>
+ <form className="addCommentFrom">
+ <input
+ className="writeComment"
+ type="text"
+ placeholder="๋๊ธ ๋ฌ๊ธฐ..."
+ onKeyPress={inputEnterPress}
+ onChange={onChange}
+ value={commentInputValue}
+ />
+ <input
+ className={`postingButton ${
+ commentInputValue.length ? 'activeButton' : ''
+ }`}
+ type="button"
+ defaultValue="๊ฒ์"
+ onClick={addComment}
+ disabled={commentInputValue.length ? false : true}
+ />
+ </form>
+ </article>
+ </div>
+ );
+ }
+}
+
+export default Feed; | JavaScript | ๋ฐ์ ์๋ฃํ์ต๋๋ค! |
@@ -0,0 +1,125 @@
+import React from 'react';
+import Comment from '../Comment/Comment';
+import './Feed.scss';
+
+class Feed extends React.Component {
+ constructor(props) {
+ super(props);
+ const { comment } = this.props.data;
+ this.state = {
+ comment: comment,
+ commentInputValue: '',
+ };
+ }
+
+ addComment = () => {
+ const { comment, commentInputValue } = this.state;
+ if (commentInputValue.length >= 1) {
+ const newComment = {
+ id: comment.length + 1,
+ content: commentInputValue,
+ isLiked: false,
+ };
+ this.setState({
+ comment: [...comment, newComment],
+ commentInputValue: '',
+ });
+ }
+ };
+
+ deleteComment = e => {
+ const { comment } = this.state;
+ const deleteCommentId = Number(e.target.id);
+ const result = comment.filter(comment => comment.id !== deleteCommentId);
+ this.setState({
+ comment: result,
+ });
+ };
+
+ inputEnterPress = e => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ this.addComment();
+ }
+ };
+
+ onChange = e => {
+ const { value } = e.target;
+ this.setState({
+ commentInputValue: value,
+ });
+ };
+
+ render() {
+ const { inputEnterPress, onChange, addComment, deleteComment } = this;
+ const { commentInputValue, comment } = this.state;
+ const { alt, img, userName } = this.props.data;
+
+ return (
+ <div className="feed">
+ <article>
+ <div className="feedTop">
+ <div className="feedUser">
+ <img className="smallUserPicture" alt={alt} src={img} />
+ <div className="feedId boldFont">{userName}</div>
+ </div>
+ <img
+ className="feedMore"
+ alt="๋๋ณด๊ธฐ"
+ src="/images/youngho/more.png"
+ />
+ </div>
+ <img className="feedPicture" alt="ํผ๋์ฌ์ง" src={img} />
+ <div className="feedBottom">
+ <div className="feedIcons">
+ <div className="FeedBottomLeftIcon">
+ <img alt="๋นจ๊ฐ์ํํธ" src="/images/youngho/redHeart.png" />
+ <img alt="๋ฉ์ธ์ง" src="/images/youngho/speech-bubble.png" />
+ <img alt="์
๋ก๋" src="/images/youngho/upload.png" />
+ </div>
+ <img alt="์ ์ฅ" src="/images/youngho/ribbon.png" />
+ </div>
+ <div className="like">
+ <img alt="์ข์์๋ฅผ ๋๋ฅธ ์ฌ๋ ์ฌ์ง" src={img} />
+ <span className="boldFont">manja</span>๋
+ <span className="boldFont">์ธ 7๋ช
</span>์ด ์ข์ํฉ๋๋ค
+ </div>
+ {comment.map(comment => {
+ return (
+ <Comment
+ key={comment.id}
+ id={comment.id}
+ userName={comment.userName}
+ comment={comment.content}
+ isLiked={comment.isLiked}
+ deleteComment={deleteComment}
+ />
+ );
+ })}
+ </div>
+ <form className="addCommentFrom">
+ <input
+ className="writeComment"
+ type="text"
+ placeholder="๋๊ธ ๋ฌ๊ธฐ..."
+ onKeyPress={inputEnterPress}
+ onChange={onChange}
+ value={commentInputValue}
+ />
+ <input
+ className={`postingButton ${
+ commentInputValue.length ? 'activeButton' : ''
+ }`}
+ type="button"
+ defaultValue="๊ฒ์"
+ onClick={addComment}
+ disabled={commentInputValue.length ? false : true}
+ />
+ </form>
+ </article>
+ </div>
+ );
+ }
+}
+
+export default Feed; | JavaScript | ๊ฐ์ฌํฉ๋๋ค ๐ |
@@ -0,0 +1,17 @@
+from django.db import models
+
+class User(models.Model):
+ email = models.EmailField(max_length=50, unique=True)
+ password = models.CharField(max_length=100)
+ relation = models.ManyToManyField('self', through='Follow', symmetrical=False)
+
+ class Meta:
+ db_table = "users"
+
+
+class Follow(models.Model):
+ following = models.ForeignKey(User, on_delete = models.SET_NULL, null=True, related_name = "following")
+ follower = models.ForeignKey(User, on_delete = models.SET_NULL, null=True, related_name = "follower")
+
+ class Meta:
+ db_table = "follows"
\ No newline at end of file | Python | ๋ค๋ฏผ๋! ์ ์์ฑํด์ฃผ์
จ๋๋ฐ `email` ์ ๊ฒน์น ์ ์๋ ์ ๋ณด์ด๊ธฐ ๋๋ฌธ์ ํด๋นํ๋ ์ต์
์ ์ถ๊ฐํด์ฃผ์๋๊ฒ ์ข์ต๋๋ค! ์์๋ณด์๊ณ ์๋ง์ ์ต์
์ ์ถ๊ฐํด์ฃผ์ธ์~ |
@@ -0,0 +1,10 @@
+from django.urls import path
+from .views import SignupView, LoginView, FollowView
+
+urlpatterns = [
+ path('/user', SignupView.as_view()),
+ path('/login', LoginView.as_view()),
+ path('/follow', FollowView.as_view()),
+
+]
+'''Error๊ฐ ์๋๋ผ django์ ๊ถ์ฅ์ฌํญ. ํ์ง๋ง ํจํด ์ปจ๋ฒค์
์๋ ์ ์ฌํญ์ด ๋ง๋ค.''' | Python | import ํ์ค ๋ `*` ์ฌ์ฉํ์ง ๋ง์๊ณ ๋ช
ํํ๊ฒ ๊ฐ์ ธ์ค๊ณ ์ถ์ class ๋ฅผ ์ ์ด์ฃผ์ธ์! |
@@ -0,0 +1,10 @@
+from django.urls import path
+from .views import SignupView, LoginView, FollowView
+
+urlpatterns = [
+ path('/user', SignupView.as_view()),
+ path('/login', LoginView.as_view()),
+ path('/follow', FollowView.as_view()),
+
+]
+'''Error๊ฐ ์๋๋ผ django์ ๊ถ์ฅ์ฌํญ. ํ์ง๋ง ํจํด ์ปจ๋ฒค์
์๋ ์ ์ฌํญ์ด ๋ง๋ค.''' | Python | ์ด ๋ถ๋ถ ์ธ์
์ค ํ๋ฒ ์ค๋ช
๋๋ ธ๋๋ฐ, ์ `/` ๊ด๋ จ warning ์ด ๋ฌ๋ค๊ณ ์๊ฐํ์๋์!? |
@@ -0,0 +1,21 @@
+"""westagram URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+ https://docs.djangoproject.com/en/3.1/topics/http/urls/
+Examples:
+Function views
+ 1. Add an import: from my_app import views
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
+Class-based views
+ 1. Add an import: from other_app.views import Home
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
+Including another URLconf
+ 1. Import the include() function: from django.urls import include, path
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
+"""
+from django.urls import path, include
+
+urlpatterns = [
+ path('account', include('account.urls')),
+ path('posting', include('posting.urls')),
+] | Python | ์ด ๋ถ๋ถ์ ์์ฝ๋ url ํจํด ์ปจ๋ฒค์
์ ๋ง์ง ์์ต๋๋ค. ์์ ๋ฆฌ๋ทฐ๋๋ฆฐ ๋ด์ฉ ์ค `/` ๊ด๋ จ ์ง๋ฌธ ๋จ๊ฒจ๋๋ ธ์ผ๋ ํ์ธํด์ฃผ์ธ์. |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ๊น๋ํ๋ค์~! ๐ฏ |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | `json.loads()` ๋ ํธ๋คํด์ฃผ์
์ผํ๋ exception ์ด ๋ฐ์ํ ์ ์์ต๋๋ค. ํ์ธํด๋ณด์๊ณ ์ถ๊ฐํด์ฃผ์ธ์! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ๋ค๋ฏผ๋์ด ์์ฑํ์ ์ฝ๋ ๋ก์ง์ ์์๋๋ก ์ ๋ฆฌํด๋ณด๊ฒ ์ต๋๋ค.
1. `client` ์์ ๋ค์ด์จ `email`, `password` ๊ฐ์ ์ด์ฉํ์ฌ ์ผ์นํ๋ user ๋ฅผ filter ํ๋ ์ฟผ๋ฆฌ๋ฅผ ๋ ๋ ค user ๋ณ์์ ์ ์ฅํด์ค๋ค.
2. `email` ๋ก filter ์ฟผ๋ฆฌ๋ฅผ ๋ ๋ ค ์กด์ฌํ๋ user ์ธ์ง ํ์ธํ๋ค.
3. `password` ๋ก filter ์ฟผ๋ฆฌ๋ฅผ ๋ ๋ ค ์กด์ฌํ๋ user ์ธ์ง ํ์ธํ๋ค.
4. client ์์ ๋ค์ด์จ `email`, `password` ๊ฐ ์ ํจํ ํฌ๋งท์ธ์ง ๊ฒ์ฌํ์ฌ ์ ํจํ๋ค๋ฉด CREATE ๋ฅผ ์งํํ๋ค.
์ด๋ ๊ฒ ๋ง๋ก ์ ๋ฆฌํด๋ณด๋ ํ๋ฆ์ด ์ข ์ด์ํ์ง ์๋์?
์ด ๋ถ๋ถ์ ์ด๋ค ์์๋๋ก ์์ฑํ๋ฉด ์ข์์ง ์ ๊ฐ ํ๊ฒ์ฒ๋ผ ๊ธ๋ก ์ ๋ฆฌํด์ comment ๋จ๊ฒจ์ฃผ์ธ์. |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ์ฌ๊ธฐ์ ์ ๊น ์ง๋ฌธ!
`KeyError` ์ด๋ค ์๋ฌ์ด๋ฉฐ, ์ธ์ ๋ฐ์ํ ๊น์? |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | SignupView ์ ๋น์ทํ ๋ก์ง ํ๋ฆ์ด๋ค์. ์์ชฝ ๋จ๊ฒจ๋๋ฆฐ ์ง๋ฌธ ๋จผ์ ํ์ธํด์ฃผ์ธ์! |
@@ -0,0 +1,17 @@
+from django.db import models
+
+class User(models.Model):
+ email = models.EmailField(max_length=50, unique=True)
+ password = models.CharField(max_length=100)
+ relation = models.ManyToManyField('self', through='Follow', symmetrical=False)
+
+ class Meta:
+ db_table = "users"
+
+
+class Follow(models.Model):
+ following = models.ForeignKey(User, on_delete = models.SET_NULL, null=True, related_name = "following")
+ follower = models.ForeignKey(User, on_delete = models.SET_NULL, null=True, related_name = "follower")
+
+ class Meta:
+ db_table = "follows"
\ No newline at end of file | Python | `from django.db import models
class User(models.Model):
email = models.EmailField(max_length=50, unique=True)` ๋ก ํด๊ฒฐํ์ต๋๋ค. |
@@ -0,0 +1,10 @@
+from django.urls import path
+from .views import SignupView, LoginView, FollowView
+
+urlpatterns = [
+ path('/user', SignupView.as_view()),
+ path('/login', LoginView.as_view()),
+ path('/follow', FollowView.as_view()),
+
+]
+'''Error๊ฐ ์๋๋ผ django์ ๊ถ์ฅ์ฌํญ. ํ์ง๋ง ํจํด ์ปจ๋ฒค์
์๋ ์ ์ฌํญ์ด ๋ง๋ค.''' | Python | `from django.urls import path
from .views import SignupView, LoginView` ๋ก ํ์ํ ๋ทฐ ํด๋์ค ๊ฐ์ ธ์ค๋ ๊ฒ์ผ๋ก ์์ ํ์์ต๋๋ค. |
@@ -0,0 +1,10 @@
+from django.urls import path
+from .views import SignupView, LoginView, FollowView
+
+urlpatterns = [
+ path('/user', SignupView.as_view()),
+ path('/login', LoginView.as_view()),
+ path('/follow', FollowView.as_view()),
+
+]
+'''Error๊ฐ ์๋๋ผ django์ ๊ถ์ฅ์ฌํญ. ํ์ง๋ง ํจํด ์ปจ๋ฒค์
์๋ ์ ์ฌํญ์ด ๋ง๋ค.''' | Python | Error๊ฐ ์๋๋ผ django์ ๊ถ์ฅ์ฌํญ์ด์ด์ ๊ทธ๋ ์ต๋๋ค. ํ์ง๋ง ํจํด ์ปจ๋ฒค์
์๋ ๊ณ ์ณ์ ์ฐ๋ ๊ฒ์ด ๋ง๊ธฐ ๋๋ฌธ์ ๊ณ ์ณค์ต๋๋ค. |
@@ -0,0 +1,21 @@
+"""westagram URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+ https://docs.djangoproject.com/en/3.1/topics/http/urls/
+Examples:
+Function views
+ 1. Add an import: from my_app import views
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
+Class-based views
+ 1. Add an import: from other_app.views import Home
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
+Including another URLconf
+ 1. Import the include() function: from django.urls import include, path
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
+"""
+from django.urls import path, include
+
+urlpatterns = [
+ path('account', include('account.urls')),
+ path('posting', include('posting.urls')),
+] | Python | ์์ ํ์์ต๋๋ค. |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | `class SignupView(View):
def post(self, request):
try:
data = json.loads(request.body)
user = User.objects.filter(email=data['email'],password=data['password'])`
์๋ ๋ก๊ทธ์ธ๋ทฐ๋ ๋๊ฐ์ ํํ๋ก ๋ฐ๊ฟจ์ต๋๋ค.
์ด์ : ์ฌ์ฉ์์๊ฒ ํ์์ ๋ฐ์ ๋ ๊ผญ ๋ด๊ฐ ์ํ๋ ํํ๋ก json์ด ์ค์ง ์์ ์ ์๊ธฐ์ Key-error ์ํฉ์ ์ค์ผ ํ๊ธฐ ๋๋ฌธ. |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ์ด๊ฑฐ ํํฅ๋ํ๊ณ ์ด์ผ๊ธฐํ๋ค๊ฐ ์ ๊ฒ์ธ๋ฐ, ํค ์๋ฌ๋ ๋์
๋๋ฆฌ ํํ์์ ์์ฃผ ๋ฐ์ํ๋ฉฐ ๋์
๋๋ฆฌ ๋ด๋ถ์ ์กด์ฌํ์ง ์๋ ํค๋ฅผ ์ฌ์ฉํด์ ๊ฐ์ ๋ด๋ ค๊ณ ํ ๋ ๋๋ ์๋ฌ์
๋๋ค. ์ด๋ฒ ์์๋ก๋ ๋ง์ผ ๋ฐ์ดํฐ๊ฐ email=~~~ password=~~~ ๋ก ์ค๋ ๊ฒ์ด ์๋๋ผ emailadkfj=~~~ apsdkfjsa=~~~์ฒ๋ผ ํค ๋ด์ฉ์ด ์๋ชป ์๋ฒ๋ฆฌ๋ ๊ฒฝ์ฐ ์์ธ ์ฒ๋ฆฌ๋ก ํค ์๋ฌ๋ฅผ ๋ด๊ธฐ ์ํด ํ๋ ๊ฒ์ผ๋ก ์๋ํ๊ณ ํ์ต๋๋ค! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ํ์ธํ์ต๋๋ค |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ๋จผ์ ๋ ํด๋์ค ๋ชจ๋ ๊ณตํต์ ์ผ๋ก user๋ผ๋ ๋ณ์๊ฐ ๋ถํ์ํด์ ์ง์ ์ต๋๋ค.
- ์ด์ : ์ด๋ฏธ User.~๋ฅผ ํตํด ์ฟผ๋ฆฌ๋ฅผ ๋ ๋ ค ๋ฐ์ดํฐ์์ ํ์ํ ์๋ฃ๋ฅผ ๊ฐ์ ธ์ฌ ์ ์๋ค. ๋ถํ์ํ ๋ณ์์๋ค.
- comment :
1. client์์ ๋ค์ด์จ ๊ฐ ์ค ์ด๋ฉ์ผ ํํฐ ์ฟผ๋ฆฌ๋ฅผ ๋ ๋ ค ์กด์ฌํ๋ ์ด๋ฉ์ผ์ผ ๊ฒฝ์ฐ์ธ์ง ํ์ธ.
2. (๋ง์ฐฌ๊ฐ์ง๋ก) ๋น๋ฐ๋ฒํธ ํํฐ ์ฟผ๋ฆฌ๋ฅผ ๋ ๋ ค ์กด์ฌํ๋ ๋น๋ฐ๋ฒํธ์ธ์ง ํ์ธ.
3. ์ด๋ฉ์ผ๊ณผ ๋น๋ฐ๋ฒํธ๊ฐ ์ ํจํ ํฌ๋งท์ธ์ง ๊ฒ์ฌํ์ฌ ์ ํจํ๋ฉด ๊ฐ ๋ง๋ค๊ธฐ ์งํ.
- ์์ง ์ฟผ๋ฆฌ๋ฅผ ๋ ๋ฆฐ๋ค๋ ๊ฐ๋
์ด ํ์คํ ์์ง ์์ ํํ์ด ๋ง๋๊ฑด์ง๋ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค. ๋ฌธ๋ฒ์ ์ธ ์ ์ ๊ฒํ ํด์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค..! |
@@ -0,0 +1,17 @@
+from django.db import models
+
+class User(models.Model):
+ email = models.EmailField(max_length=50, unique=True)
+ password = models.CharField(max_length=100)
+ relation = models.ManyToManyField('self', through='Follow', symmetrical=False)
+
+ class Meta:
+ db_table = "users"
+
+
+class Follow(models.Model):
+ following = models.ForeignKey(User, on_delete = models.SET_NULL, null=True, related_name = "following")
+ follower = models.ForeignKey(User, on_delete = models.SET_NULL, null=True, related_name = "follower")
+
+ class Meta:
+ db_table = "follows"
\ No newline at end of file | Python | `unique=True` ๊ตณ์
๋๋ค!! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | @damin0320 ์ ํํฉ๋๋ค ๋ค๋ฏผ๋! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ๊ฐ๋
์ฑ์ ์ํด ๋ก์ง๋ณ๋ก ๋ถ๋ฆฌํด์ ๋์ด์ฐ๊ธฐ๋ก ๊ตฌ๋ถํด์ฃผ์ธ์! ์ง๊ธ์ ๋๋ฌด ๋ค ๋ถ์ด์์ด์ ์ฝ๊ธฐ๊ฐ ์ข์ ์ฝ๋๊ฐ ์๋๋๋ค ๋ค๋ฏผ๋! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | exists() ํ์ฉ gooood ๐ |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ์ด ๋ถ๋ถ์ ๋ก์ง์ด ์กฐ๊ธ ์ด์ํ๋ฐ์.
password ๋ ๊ณ ์ ๊ฐ์ด ์๋๊ณ , ๊ฐ์ password ๋ฅผ ๊ฐ์ง ์ ์ ์ ๋ณด๋ค์ด ์ถฉ๋ถํ ์กด์ฌํ ์ ์๋๋ฐ password ๋ก ํํฐ๋ฅผ ๊ฑธ์ด์ค ํ์๋ ์๋ค๊ณ ์๊ฐํฉ๋๋ค~ |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ์ํธํ ๊ณผ์ ์ ์ฉ ์ ๋ง ์ํ์
จ์ต๋๋ค! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | create() ๋ค์ save() ๋ ๋ถํ์ํฉ๋๋ค ๋ค๋ฏผ๋. ์์ ์ฃผ์ธ์! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | get() ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์๋ฉด ๊ผญ ์ก์์ฃผ์
์ผํ๋ exception ๋ค์ด ์์ต๋๋ค.
์์๋ณด์๊ณ exception handling ๋ก์ง์ ์ถ๊ฐํด์ฃผ์ธ์! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ์ฌ๊ธฐ๋ ๋ง์ฐฌ๊ฐ์ง๋ก ๊ฐ๋
์ฑ์ ์ํด ๋ก์ง์ ๋ธ๋ก์ผ๋ก ๊ตฌ๋ถํ์ฌ ํ์ค์ฉ ์ถ๊ฐํด์ฃผ์ธ์! |
@@ -0,0 +1,103 @@
+import json
+import bcrypt
+import jwt
+
+from django.views import View
+from django.http import JsonResponse
+
+from .models import User, Follow
+from my_settings import SECRET_KEY
+
+class SignupView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ if User.objects.filter(email=data['email']).exists():
+ return JsonResponse({"message": "EMAIL_ERROR"}, status=400)
+
+ if not '@' in data['email'] or not '.' in data['email']:
+ return JsonResponse({"message":"EMAIL_FAIL"}, status=400)
+ if len(data['password']) < 8:
+ return JsonResponse({"message":"PASSWORD_TOO_SHORT"}, status=400)
+
+ byted_password = data['password'].encode('utf-8')
+ hash_password = bcrypt.hashpw(byted_password, bcrypt.gensalt()).decode()
+ password = hash_password
+ user = User.objects.create(
+ email = data['email'],
+ password = password
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ except KeyError:
+ return JsonResponse({"message": "KEY_ERROR"}, status=400)
+
+
+class LoginView(View):
+ def post(self, request):
+ try:
+ data = json.loads(request.body)
+ try:
+ user = User.objects.get(email=data['email'])
+ # user๋ ๊ฐ์ฒด๋ค
+ user_id = user.id
+ # ๊ฐ์ฒด์ .~ํ๋ฉด ๋ฐ๋ก ๋ด์ฉ์ ๊บผ๋ผ ์ ์๋ค.
+ except User.DoesNotExist:
+ return JsonResponse({"message":"USER_DOES_NOT_EXIST"}, status=400)
+
+ if bcrypt.checkpw(data['password'].encode('utf-8'), user.password.encode('utf-8')):
+ token = jwt.encode({'user_id' : user_id}, SECRET_KEY, algorithm="HS256")
+ # ์ ์ id๋ฅผ ํ ํฐ ๋ด์ฉ๋ฌผ์ ๋ฃ๋๋ค. ์ด๋ ์ด๋ฏธ ์ซ์๊ฐ ๋์์ผ๋ฏ๋ก data๋ก ํ ํ์ ์์
+ return JsonResponse({'token' : token, "message":"SUCCESS"}, status=200)
+
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+ except KeyError:
+ return JsonResponse({"message":"KEY_ERROR"}, status=400)
+
+class TokenCheckView(View):
+ def post(self,request):
+ data = json.loads(request.body)
+
+ user_token_info = jwt.decode(data['token'], SECRET_KEY, algorithms='HS256')
+
+ if User.objects.filter(email=user_token_info['email']).exists():
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+ return JsonResponse({"message":"INVALID_USER"}, status=401)
+
+class FollowView(View):
+ def post(self, request):
+ data = json.loads(request.body)
+ following = User.objects.get(email=data['following'])
+ follower = User.objects.get(email=data['follower'])
+ if following == follower:
+ return JsonResponse({"message":"SAME_PERSON!"})
+ follow = Follow.objects.create(
+ following = following,
+ follower = follower
+ )
+ return JsonResponse({"message": "SUCCESS"}, status=200)
+
+def TokenCheck(func):
+ def wrapper(self, request, *args, **kwargs):
+ # ๋ฆฌํ์คํธํด์ ํ ํฐ ๊น๋ ์
+ # ํ ํฐ์ ํต์ฌ์ ๊ณต๊ฐ๊ฐ ๋์ด๋ ๋๋ค -> ๊ทธ๋์ ์์ ๊ฐ user_id์๋ ๊ฒ.
+ try:
+ token = request.headers.get('Authorization')
+ if token:
+ payload = jwt.decode(token, SECRET_KEY, algorithms="HS256")
+ user_id = payload['user_id']
+ user = User.objects.get(id=user_id)
+ # user_id ๊ฐ์ ธ์จ ๊ฒ์ user๋ผ๋ ๋ณ์์ ๋ด๊ณ
+
+ request.user = user
+ # ๋ณ์์ ๋ด์ ๊ฒ์ ๋ค์์ ๋ถ๋ฅผ request.user์ ๋ ๋ด์์ค๋ค.
+ return func(self, request, *args, **kwargs)
+ # ์๋ returnํ๋ฉด์ request๋ฅผ posting์์ ์ฌ์ฉํ ์์ (.user ๋ง ๋ถ์ด๋ฉด ์ด์ ์๋ ์์ฑ)
+ return JsonResponse({"message":"GIVE_ME_TOKEN"}, status=400)
+ except jwt.InvalidTokenError:
+ return JsonResponse({"message":"YOUR_TOKEN_ERROR"}, status=400)
+
+ # ์ง๊ธ์ ์ซ์๋ง ํ์ธ ์ํฉ(id๊ฐ๋ง ๋ฐ์์ ํ์ธํ ์ํฉ)
+ # ์ถ๊ฐ : ํ ํฐ์ ๋ค์ ์ ๊ฐ๋ค์ค ์ํฉ(๋ฆฌํ์คํธ์ ์ ๋ณด๋ฅผ ๋ฃ์ด์ค๋ค.) ; ๋ฆฌํ์คํธ์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด์ค๋ค.(์์ด๋๊ฐ์ ๋ฃ์ด์ค๋ค.->์ด๊ฑธ ๊บผ๋ด ์ด๋ค.)
+
+ return wrapper
\ No newline at end of file | Python | ์ด์ผ~ jwt ์์ฑ ๋ก์ง๊น์ง ๋๋ฌด ์ ์ ์ฉํ์
จ๋ค์!
ํ์ง๋ง ์์ฑ์ ์๋ฃํ๋๋ฐ ์์ฑ๋งํ๊ณ ์ฌ์ฉ์ ์ํ๊ณ ๊ณ์๋ค์. ๋ค์ ์คํ
์ ๋ฌด์์ผ๊น์? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.