Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

release: v0.7.0 #99

Merged
merged 24 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bee1bc9
feat: Add axios interceptor setup (#83)
cjeongmin May 16, 2024
1e823bb
Merge branch 'dev' into feat/error-handler
cjeongmin May 17, 2024
cbdbd5e
Merge branch 'dev' into feat/error-handler
cjeongmin May 20, 2024
d905d7d
feat: Add isCreateable state
cjeongmin May 21, 2024
47b4a14
feat: RangeSlider 컴포넌트 값 표시
cjeongmin May 21, 2024
f08e568
feat: Refetch post data when follow, unfollow, scrap
cjeongmin May 21, 2024
39c8a21
feat: Apply data refetching for follow, unfollow, and scrap actions i…
cjeongmin May 21, 2024
122b604
Merge branch 'dev' into feat/error-handler
cjeongmin May 21, 2024
f74c96b
feat: Add a message when there are no recommended mates on the main page
cjeongmin May 21, 2024
7b06fab
feat: Add a message when there are no recommended mates on the posts …
cjeongmin May 21, 2024
75d5090
feat: Add a message when there are no recommended posts on the posts …
cjeongmin May 21, 2024
8973891
fix: Fix /shared/posts/... API error
cjeongmin May 21, 2024
66610df
Merge pull request #96 from capstone-maru/fix/writing-post-page
cjeongmin May 22, 2024
ba87d5a
Merge branch 'dev' into feat/error-handler
cjeongmin May 22, 2024
241835e
fix: Change the layout from desktop to tablet
cjeongmin May 27, 2024
3b1c1e8
fix: Modify page container min-width in profile-page
cjeongmin May 27, 2024
488e227
Merge pull request #97 from capstone-maru/fix/layout
cjeongmin May 27, 2024
f214472
Merge branch 'dev' into feat/error-handler
cjeongmin May 27, 2024
3fb97ea
feat: Add loading message when fetching data that recommend posts, mates
cjeongmin May 27, 2024
35ecc3c
fix: change render function into useMemo hook
cjeongmin May 28, 2024
e5528a8
fix: Set mini card container max-width in user-input-page
cjeongmin May 28, 2024
c9c08ed
feat: Add Authorization Error Handler (#83)
cjeongmin May 28, 2024
1651628
Merge pull request #98 from capstone-maru/feat/error-handler
cjeongmin May 28, 2024
8d4b9d2
v0.7.0
cjeongmin May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maru",
"version": "0.6.0",
"version": "0.7.0",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
2 changes: 1 addition & 1 deletion src/app/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:root,
body {
min-height: 100dvh;
min-width: 90rem;
min-width: 1194px;
max-width: 100dvw;

@media (max-width: 768px) {
Expand Down
1 change: 1 addition & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import React from 'react';
import './globals.scss';
import './lib/axios';

import {
AuthProvider,
Expand Down
71 changes: 71 additions & 0 deletions src/app/lib/axios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
'use client';

import axios, { type AxiosError, type AxiosResponse } from 'axios';

import { postTokenRefresh } from '@/features/auth';
import { load, save } from '@/shared/storage';
import { type FailureDTO } from '@/shared/types';

let isRefreshing = false;
let refreshSubscribers: Array<(token: string) => void> = [];

const subscribeTokenRefresh = (callback: (token: string) => void) => {
refreshSubscribers.push(callback);
};

const onRefreshed = (token: string) => {
refreshSubscribers.forEach(callback => {
callback(token);
});
refreshSubscribers = [];
};

axios.interceptors.response.use(
(response: AxiosResponse) => response,
async (error: AxiosError<FailureDTO>) => {
if (error.response?.status !== 401 || error.response?.data.code !== 'C002')
return await Promise.reject(error);

const refreshToken = load<string>({ type: 'local', key: 'refreshToken' });
if (refreshToken == null) {
window.location.href = '/';
return await Promise.reject(error);
}

if (isRefreshing) {
return await new Promise(resolve => {
subscribeTokenRefresh((token: string) => {
const { config } = error;
if (config?.headers != null) {
config.headers.Authorization = `Bearer ${token}`;
resolve(axios(config));
}
});
});
}

isRefreshing = true;
try {
const {
data: { accessToken, refreshToken: newRefreshToken, expiresIn },
} = await postTokenRefresh(refreshToken);

axios.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
save({ type: 'local', key: 'refreshToken', value: newRefreshToken });
save({ type: 'local', key: 'expiresIn', value: `${expiresIn}` });

const { config } = error;
onRefreshed(accessToken);
if (config != null) {
config.headers.Authorization = `Bearer ${accessToken}`;
return await axios(config);
}
} catch (refreshError) {
return await Promise.reject(error);
} finally {
isRefreshing = false;
}

return await Promise.reject(error);
},
);
1 change: 0 additions & 1 deletion src/app/lib/providers/InitializationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function InitialzationProvider({
const { data: userData } = useUserData(auth?.accessToken != null);

useEffect(() => {
console.log(userData);
if (userData != null) {
setAuthUserData(userData);
if (userData.initialized) {
Expand Down
58 changes: 11 additions & 47 deletions src/app/pages/landing-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const styles = {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 0rem 13.75rem;
`,
img: styled.img`
Expand All @@ -24,9 +25,9 @@ const styles = {
description: styled.div`
display: flex;
flex-direction: column;
align-items: end;
align-items: flex-end;
gap: 1.75rem;
width: 27.8125rem;
width: 21.875rem;
margin-top: 6.25rem;
flex-shrink: 0;

Expand All @@ -38,8 +39,8 @@ const styles = {
font-style: normal;
font-weight: 700;
line-height: normal;
margin-bottom: 2rem;
}

p {
color: #000;
text-align: right;
Expand All @@ -48,7 +49,6 @@ const styles = {
font-style: normal;
font-weight: 500;
line-height: normal;
margin-bottom: 6.5rem;
}
`,
loginButtons: styled.div`
Expand All @@ -71,19 +71,15 @@ const styles = {
object-fit: cover;
}
`,
section2: styled.div`
position: relative;
width: 100dvw;
height: 31.25rem;
flex-shrink: 0;
background: #f7f6f9;
`,
section3: styled.div`
display: flex;
justify-content: end;
height: 30rem;
padding-left: 50%;
justify-content: center;
align-items: center;

height: 31.25rem;
padding-right: 21.25rem;
background: #f7f6f9;
overflow-y: hidden;
`,
imageBox: styled.div`
display: flex;
Expand Down Expand Up @@ -112,35 +108,7 @@ const styles = {
flex-shrink: 0;

border-radius: 16px;
background: rgba(247, 246, 249, 0.5);
`,
section4: styled.div`
display: flex;
position: relative;
width: 100dvw;
height: 17.9375rem;
padding: 10.0625rem 38.71875rem 5.0625rem 39.90625rem;
justify-content: center;
align-items: center;
flex-shrink: 0;
background: #f7f6f9;
`,
findMateButton: styled.button`
all: unset;
flex-shrink: 0;
padding: 0.5rem 1.5rem;
flex-shrink: 0;

border-radius: 8px;
background: #e15637;

color: #fff;
font-family: 'Noto Sans KR';
font-size: 1.25rem;
font-style: normal;
font-weight: 700;
line-height: normal;
cursor: pointer;
background: white;
`,
};

Expand Down Expand Up @@ -191,7 +159,6 @@ export function LandingPage() {
</styles.loginButtons>
</styles.description>
</styles.section1>
<styles.section2 />
<styles.section3>
<styles.imageBox>
{images.map((column, i) => (
Expand All @@ -209,9 +176,6 @@ export function LandingPage() {
))}
</styles.imageBox>
</styles.section3>
<styles.section4>
<styles.findMateButton>메이트 찾아보기</styles.findMateButton>
</styles.section4>
</styles.container>
);
}
88 changes: 57 additions & 31 deletions src/app/pages/main-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const styles = {
`,
map: styled.div`
width: 100%;
height: 50dvh;
height: 30rem;

display: flex;
flex-direction: column;
Expand Down Expand Up @@ -49,9 +49,7 @@ const styles = {
width: 100%;
display: flex;
flex-direction: column;
gap: 2.6875rem;

margin-bottom: 5rem;
gap: 3rem;
`,
mateRecommendationTitle: styled.h1`
color: #000;
Expand All @@ -67,14 +65,14 @@ const styles = {
flex-direction: row;
justify-content: space-between;
align-items: center;
gap: 2.12rem;
padding: 0 2.5rem;
gap: 2rem;
padding: 0 2.25rem;
`,
mateRecommendation: styled.div`
display: flex;
flex-grow: 1;
flex-direction: row;
gap: 2.625rem;
gap: 2rem;
overflow-x: auto;

-ms-overflow-style: none;
Expand All @@ -83,6 +81,19 @@ const styles = {
display: none;
}
`,
mateRecommendationIsEmpty: styled.div`
color: #000;
font-family: 'Noto Sans KR';
font-size: 1.5rem;
font-style: normal;
font-weight: 500;
line-height: normal;

display: flex;
width: 100%;
justify-content: center;
padding-block: 2rem;
`,
};

export function MainPage() {
Expand Down Expand Up @@ -146,30 +157,45 @@ export function MainPage() {
{auth?.user?.name}님의 추천 메이트
</styles.mateRecommendationTitle>
<styles.mateRecommendationRow>
<CircularButton
direction="left"
disabled={false}
onClick={handleScrollLeft}
/>
<styles.mateRecommendation ref={scrollRef}>
{recommendationMates?.data?.map(
({ memberId, score, nickname, location, profileImageUrl }) => (
<Link href={`/profile/${memberId}`} key={memberId}>
<UserCard
name={nickname}
percentage={score}
profileImage={profileImageUrl}
location={location}
/>
</Link>
),
)}
</styles.mateRecommendation>
<CircularButton
direction="right"
disabled={false}
onClick={handleScrollRight}
/>
{recommendationMates?.data != null &&
recommendationMates.data.length > 0 ? (
<>
<CircularButton
direction="left"
disabled={false}
onClick={handleScrollLeft}
/>
<styles.mateRecommendation ref={scrollRef}>
{recommendationMates.data.map(
({
memberId,
score,
nickname,
location,
profileImageUrl,
}) => (
<Link href={`/profile/${memberId}`} key={memberId}>
<UserCard
name={nickname}
percentage={score}
profileImage={profileImageUrl}
location={location}
/>
</Link>
),
)}
</styles.mateRecommendation>
<CircularButton
direction="right"
disabled={false}
onClick={handleScrollRight}
/>
</>
) : (
<styles.mateRecommendationIsEmpty style={{ alignSelf: 'center' }}>
<p>추천되는 메이트가 없습니다.</p>
</styles.mateRecommendationIsEmpty>
)}
</styles.mateRecommendationRow>
</styles.mateRecommendationContainer>
</styles.container>
Expand Down
Loading