-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from themoment-team/develop
Release v1.3.0 (Gwangya)
- Loading branch information
Showing
34 changed files
with
722 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { cookies } from 'next/headers'; | ||
import type { NextRequest } from 'next/server'; | ||
import { NextResponse } from 'next/server'; | ||
|
||
import { gwangyaUrl } from '@/libs'; | ||
import type { GetGwangyaTokenType } from '@/types'; | ||
|
||
const cookieDomain = | ||
process.env.NODE_ENV === 'development' ? 'localhost' : '.gsm-networking.com'; | ||
|
||
const setCookie = (name: string, value: string, expires: Date) => { | ||
cookies().set(name, value, { | ||
expires, | ||
domain: cookieDomain, | ||
}); | ||
}; | ||
|
||
export async function GET(request: NextRequest) { | ||
const searchParams = request.nextUrl.searchParams; | ||
|
||
const redirectPath = searchParams.get('redirect') || '/community/gwangya'; | ||
|
||
const cookieStore = cookies(); | ||
|
||
const accessToken = cookieStore.get('accessToken')?.value; | ||
|
||
const res = await fetch( | ||
new URL(`/api/v1${gwangyaUrl.getGwangyaToken()}`, process.env.BASE_URL), | ||
{ | ||
method: 'GET', | ||
headers: { | ||
Cookie: `accessToken=${accessToken}`, | ||
}, | ||
} | ||
); | ||
|
||
if (!res.ok) { | ||
return NextResponse.redirect( | ||
new URL(`/auth/refresh?redirect=/auth/refresh/gwangya`, request.url) | ||
); | ||
} | ||
|
||
const body: GetGwangyaTokenType = await res.json(); | ||
|
||
const gwangyaToken = body.gwangyaToken; | ||
const expires = body.expiredTime; | ||
|
||
const expiresDate = new Date(`${expires}Z`); | ||
|
||
setCookie('gwangyaToken', gwangyaToken, expiresDate); | ||
|
||
return NextResponse.redirect(new URL(redirectPath, request.url)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const UploadIcon = () => ( | ||
<svg | ||
width='2.25rem' | ||
height='2.25rem' | ||
viewBox='0 0 36 36' | ||
fill='none' | ||
xmlns='http://www.w3.org/2000/svg' | ||
> | ||
<circle cx='18' cy='18' r='15' fill='#94CCFF' /> | ||
<path | ||
d='M17.25 24C17.25 24.4142 17.5858 24.75 18 24.75C18.4142 24.75 18.75 24.4142 18.75 24L17.25 24ZM18.5303 11.4697C18.2374 11.1768 17.7626 11.1768 17.4697 11.4697L12.6967 16.2426C12.4038 16.5355 12.4038 17.0104 12.6967 17.3033C12.9896 17.5962 13.4645 17.5962 13.7574 17.3033L18 13.0607L22.2426 17.3033C22.5355 17.5962 23.0104 17.5962 23.3033 17.3033C23.5962 17.0104 23.5962 16.5355 23.3033 16.2426L18.5303 11.4697ZM18.75 24L18.75 12L17.25 12L17.25 24L18.75 24Z' | ||
fill='#148EFF' | ||
/> | ||
</svg> | ||
); | ||
|
||
export default UploadIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,47 @@ | ||
import React from 'react'; | ||
'use client'; | ||
|
||
import React, { forwardRef } from 'react'; | ||
|
||
import * as S from './style'; | ||
|
||
interface Props { | ||
index: number; | ||
content: string; | ||
} | ||
|
||
const CommunityCard: React.FC<Props> = ({ index, content }) => ( | ||
<S.CardWrapper> | ||
<S.Header> | ||
<S.Index>#{index}</S.Index> | ||
<S.DateBox> | ||
{/* TODO: 추후에 api 연동 시, Date 핸들링 구체화 하겠습니다. */} | ||
<S.Date>2020.01.01</S.Date> | ||
<S.Time>12:12</S.Time> | ||
</S.DateBox> | ||
</S.Header> | ||
<S.Content>{content}</S.Content> | ||
</S.CardWrapper> | ||
import type { GwangyaPostType } from '@/types'; | ||
|
||
const addZero = (num: number): string => (num < 10 ? `0${num}` : `${num}`); | ||
|
||
const removeDuplicateEnter = (str: string) => str.replaceAll(/\n+/g, '\n'); | ||
|
||
const CommunityCard = forwardRef<HTMLDivElement, GwangyaPostType>( | ||
({ id, content, createdAt }, ref) => { | ||
const createdDate = new Date(createdAt + 'Z'); | ||
|
||
const createdMonth = createdDate.getMonth() + 1; | ||
const createdDay = createdDate.getDate(); | ||
const createdTime = createdDate.getHours(); | ||
const createdMinute = createdDate.getMinutes(); | ||
const morningOrAfternoon = createdTime < 12 ? '오전' : '오후'; | ||
const convertCreatedTime = | ||
createdTime > 12 ? createdTime - 12 : createdTime; | ||
|
||
return ( | ||
<S.CardWrapper ref={ref}> | ||
<S.Header> | ||
<S.Index>#{id}</S.Index> | ||
<S.DateBox> | ||
<S.Date> | ||
{createdMonth}월 {createdDay}일 | ||
</S.Date> | ||
<S.Time> | ||
{morningOrAfternoon} {addZero(convertCreatedTime)}: | ||
{addZero(createdMinute)} | ||
</S.Time> | ||
</S.DateBox> | ||
</S.Header> | ||
<S.Content>{removeDuplicateEnter(content)}</S.Content> | ||
</S.CardWrapper> | ||
); | ||
} | ||
); | ||
|
||
CommunityCard.displayName = 'CommunityCard'; | ||
|
||
export default CommunityCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import TextArea from '.'; | ||
|
||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
const meta: Meta<typeof TextArea> = { | ||
component: TextArea, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof TextArea>; | ||
|
||
export const Primary: Story = {}; |
Oops, something went wrong.