Skip to content

Commit

Permalink
Merge pull request #73 from 9oormthonUniv-seoultech/develop
Browse files Browse the repository at this point in the history
2차 배포
  • Loading branch information
jaeyo03 authored Nov 7, 2024
2 parents c5938cb + bed5064 commit 75ed9be
Show file tree
Hide file tree
Showing 50 changed files with 1,953 additions and 1,113 deletions.
4 changes: 2 additions & 2 deletions src/@types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type CommonResponse<T> = {
};

export type CommonError = {
errorCode: string;
statusCode: string;
message: string;
success: boolean;
content: string;
};
7 changes: 7 additions & 0 deletions src/@types/my.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export type MyLikedBooth = {
photoBoothId: number;
name: string;
rating: number;
feature: string;
featureCount: number;
};
80 changes: 44 additions & 36 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { BrowserRouter, Navigate, Outlet, Route, Routes, useNavigate } from "react-router-dom";
import { BrowserRouter, Navigate, Outlet, Route, Routes } from "react-router-dom";
import Home from "./pages/Home";
import SplashScreen from "./pages/SplashScreen";
import Album from "./pages/Album";
import My from "./pages/My";
import PhotoUpload from "./pages/PhotoUpload";

import QRScan from "./pages/QRScan";
import PhotoReview from "./pages/PhotoReview";
import PhotoCheck from "./pages/PhotoCheck";
import PhotoReview from "./pages/PhotoUpload/ReviewPhoto";

import LoginPage from "./pages/LoginPage";
import Token from "./pages/Token";
Expand All @@ -25,7 +24,11 @@ import MyReviewPage from "./pages/My/MyReviewPage";
import LikeBoothsPage from "./pages/My/LikeBoothsPage";
import VisitedBoothsPage from "./pages/My/VisitedBoothsPage";
import { useAuthStore } from "./store/useAuthStore";
import Modal from "./components/Common/Modal";
import UploadComplete from "./pages/PhotoUpload/UploadComplete";
import CheckPhoto from "./pages/PhotoUpload/CheckPhoto";
import WriteDetail from "./pages/PhotoUpload/WriteDetail";
import Share from "./pages/Share";
import AlertDialog from "./components/Alert/AlertDialog";

function App() {
const { isLoggedIn } = useAuthStore();
Expand All @@ -45,45 +48,50 @@ function App() {
};

return (
<BrowserRouter basename="/page">
<Routes>
<Route path="/" element={<SplashScreen />} />
<Route path="/home" element={<Home />} />
<AlertDialog>
<BrowserRouter basename="/page">
<Routes>
<Route path="/" element={<SplashScreen />} />
<Route path="/home" element={<Home />} />

<Route path="/login" element={<LoginPage />} />
<Route path="/token" element={<Token />} />
<Route path="/login" element={<LoginPage />} />
<Route path="/token" element={<Token />} />

<Route path="/home/:boothId" element={<BoothDetail />}>
<Route path="feed" element={<FeedPage />} />
<Route path="review" element={<ReviewPage />} />
<Route path="image" element={<ImagePage />} />
</Route>

<Route element={<PrivateRoute />}>
<Route path="/my" element={<My />}>
<Route path="booth-records" element={<RecordPage />} />
<Route path="favorites" element={<FavoritesPage />} />
<Route path="/home/:boothId" element={<BoothDetail />}>
<Route path="feed" element={<FeedPage />} />
<Route path="review" element={<ReviewPage />} />
<Route path="image" element={<ImagePage />} />
</Route>

<Route path="my-reviews" element={<MyReviewPage />} />
<Route path="like-booths" element={<LikeBoothsPage />} />
<Route path="visited-booths" element={<VisitedBoothsPage />} />
<Route element={<PrivateRoute />}>
<Route path="/my" element={<My />}>
<Route path="booth-records" element={<RecordPage />} />
<Route path="favorites" element={<FavoritesPage />} />
</Route>

<Route path="/write-review/:boothId" element={<WriteReview />}>
<Route path="step/1" element={<Step1 />} />
<Route path="step/2" element={<Step2 />} />
</Route>
<Route path="/write-review/complete" element={<CompleteScreen />} />
<Route path="my-reviews" element={<MyReviewPage />} />
<Route path="like-booths" element={<LikeBoothsPage />} />
<Route path="visited-booths" element={<VisitedBoothsPage />} />

<Route path="/photo-upload" element={<PhotoUpload />} />
<Route path="/write-review/:boothId" element={<WriteReview />}>
<Route path="step/1" element={<Step1 />} />
<Route path="step/2" element={<Step2 />} />
</Route>
<Route path="/write-review/complete" element={<CompleteScreen />} />

<Route path="/qr-scan" element={<QRScan />} />
<Route path="/photo-review" element={<PhotoReview />} />
<Route path="/photo-check" element={<PhotoCheck />} />
<Route path="/album" element={<Album />} />
</Route>
</Routes>
</BrowserRouter>
<Route path="/photo-upload" element={<PhotoUpload />} />

<Route path="/qr-scan" element={<QRScan />} />
<Route path="/photo-review" element={<PhotoReview />} />
<Route path="/photo-check" element={<CheckPhoto />} />
<Route path="/write-detail" element={<WriteDetail />} />
<Route path="/upload-complete" element={<UploadComplete />} />
<Route path="/album" element={<Album />} />
</Route>
<Route path="/share" element={<Share />} />
</Routes>
</BrowserRouter>
</AlertDialog>
);
}

Expand Down
25 changes: 21 additions & 4 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,36 @@ export const axiosInstance = axios.create({
withCredentials: true,
});

const errorCodes = ["SEC4001", "SEC4011", "SEC4012"];
const errorCodes = ["SEC4001", "SEC4011", "SEC4012", "SEC4010"];

axiosInstance.interceptors.response.use(
(response) => response,
async (error: AxiosError<CommonError>) => {
if (error.config && error.response && error.response.data.errorCode in errorCodes) {
console.log(error.response);
if (error.config && error.response?.status && errorCodes.includes(error.response!.data.statusCode)) {
console.log("진입");
// 토큰 재발급 수행
const accessToken = useAuthStore((state) => state.accessToken);
const { accessToken } = useAuthStore();
console.log(accessToken);

if (!accessToken) {
throw new Error("AccessToken is undefined or null");
}

try {
const res = await reissueToken(accessToken!);

if (res) {
useAuthStore.setState({
isLoggedIn: true,
accessToken: res.accessToken,
});

// 새로 발급 받은 accessToken을 에러가 발생한 요청의 헤더에 설정
error.config.headers.Authorization = `Bearer ${res.accessToken}`;
//로직 재수행
return await axiosInstance(error.config);
} else {
throw new Error("AccessToken not received");
}
} catch (error) {
console.error("Error in reissuing token:", error);
Expand All @@ -57,3 +66,11 @@ export const Post = async <T>(
const response = await axiosInstance.post(url, body, config);
return response;
};

export const Delete = async <T>(
url: string,
config?: AxiosRequestConfig
): Promise<AxiosResponse<CommonResponse<T>>> => {
const response = await axiosInstance.delete(url, config);
return response;
};
41 changes: 40 additions & 1 deletion src/api/my.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Get } from ".";
import { Get, Post } from ".";
import { MyLikedBooth } from "../@types/my";
import { MyReview } from "../@types/review";

export const getMyReviews = async (accessToken: string) => {
Expand Down Expand Up @@ -27,3 +28,41 @@ export const getVisitedBooths = async (accessToken: string) => {
return res.data.payload;
} catch (error) {}
};

export const getLikedBooths = async (accessToken: string) => {
try {
const res = await Get<MyLikedBooth[]>("/api/v1/photobooth/like", {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});

return res.data.payload;
} catch (error) {}
};

export const postboothLike = async (accessToken: string, boothId: string) => {
try {
const res = await Post(
`/api/v1/photobooth/like/${boothId}`,
{},
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);
return res.data.payload;
} catch (error) {}
};

export const getPhotoLikes = async (accessToken: string) => {
try {
const res = await Get<{ albumId: number; photoUrl: string; like: boolean }[]>("/api/v1/album/favorite", {
headers: {
Authorization: `Bearer: ${accessToken}`,
},
});
return res.data.payload;
} catch (error) {}
};
13 changes: 11 additions & 2 deletions src/api/photoupload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ export const uploadPhoto = async (
filePath: string
) => {
try {
const res = await Post(
const res = await Post<{
photoboothId: number;
year: number;
month: number;
date: number;
hashtag: string[];
albumId: string;
memo: string;
filePath: string;
}>(
"/api/v1/album",
{
photoboothId: photoboothId,
Expand All @@ -28,7 +37,7 @@ export const uploadPhoto = async (
},
}
);
return res.data.result;
return res.data.payload;
} catch (error) {
console.log(error);
}
Expand Down
34 changes: 34 additions & 0 deletions src/api/share.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { AxiosError } from "axios";
import { Post } from ".";

export const createLink = async (albumId: string, accessToken: string) => {
try {
const res = await Post<string>(
`/api/v1/album/share?albumId=${albumId}`,
{},
{
headers: { Authorization: `Bearer ${accessToken}` },
}
);

return res.data.payload;
} catch (error) {}
};

export const saveShare = async (accessToken: string, shareId: string) => {
try {
const res = await Post(
`/api/v1/album/${shareId}/saveShare`,
{},
{
headers: { Authorization: `Bearer ${accessToken}` },
}
);

return res.data;
} catch (error) {
if (error instanceof AxiosError) {
return error.status;
}
}
};
11 changes: 11 additions & 0 deletions src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,14 @@ export const reissueToken = async (accessToken: string) => {
return res.data.payload;
} catch (error) {}
};

export const getLogout = async (accessToken: string) => {
try {
const res = await Get("/api/v1/users/logout", {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return res.data;
} catch (error) {}
};
6 changes: 2 additions & 4 deletions src/assets/icons/like-filled-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ function LikeFilledIcon({ width, height, color }: IconProps) {
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M21.1153 2.17264C20.1305 1.41416 18.9618 1.04053 17.7979 1.04053C16.5426 1.04053 15.2679 1.48792 14.2562 2.36032C13.9298 2.64531 13.6491 2.99357 13.388 3.39441L13.3866 3.39659L13.0939 3.8425L12.4669 4.79797L11.8399 3.8425L11.5472 3.39659L11.5416 3.388L11.5417 3.38796C11.2865 2.98735 11.0094 2.63996 10.6859 2.36748L10.6791 2.36171L10.6791 2.36167C9.66634 1.4876 8.40972 1.04053 7.1359 1.04053C5.86086 1.04053 4.6168 1.47567 3.58544 2.36242L21.1153 2.17264ZM21.1153 2.17264L21.3354 2.36221C23.6071 4.31835 23.8675 7.74888 21.9202 10.028L13.7653 18.8107C13.4195 19.1732 12.9471 19.358 12.4733 19.358H12.4732H12.4732H12.4732H12.4731H12.4731H12.473H12.473H12.473H12.4729H12.4729H12.4729H12.4728H12.4728H12.4728H12.4727H12.4727H12.4727H12.4726H12.4726H12.4725H12.4725H12.4725H12.4724H12.4724H12.4724H12.4723H12.4723H12.4723H12.4722H12.4722H12.4722H12.4721H12.4721H12.4721H12.472H12.472H12.472H12.472H12.4719H12.4719H12.4719H12.4718H12.4718H12.4718H12.4717H12.4717H12.4717H12.4716H12.4716H12.4716H12.4715H12.4715H12.4715H12.4715H12.4714H12.4714H12.4714H12.4713H12.4713H12.4713H12.4712H12.4712H12.4712H12.4712H12.4711H12.4711H12.4711H12.471H12.471H12.471H12.471H12.4709H12.4709H12.4709H12.4708H12.4708H12.4708H12.4708H12.4707H12.4707H12.4707H12.4706H12.4706H12.4706H12.4706H12.4705H12.4705H12.4705H12.4705H12.4704H12.4704H12.4704H12.4704H12.4703H12.4703H12.4703H12.4702H12.4702H12.4702H12.4702H12.4701H12.4701H12.4701H12.4701H12.47H12.47H12.47H12.47H12.4699H12.4699H12.4699H12.4699H12.4698H12.4698H12.4698H12.4698H12.4698H12.4697H12.4697H12.4697H12.4697H12.4696H12.4696H12.4696H12.4696H12.4695H12.4695H12.4695H12.4695H12.4694H12.4694H12.4694H12.4694H12.4694H12.4693H12.4693H12.4693H12.4693H12.4692H12.4692H12.4692H12.4692H12.4691H12.4691H12.4691H12.4691H12.4691H12.469H12.469H12.469H12.469H12.4689H12.4689H12.4689H12.4689H12.4689H12.4688H12.4688H12.4688H12.4688H12.4688H12.4687H12.4687H12.4687H12.4687H12.4687H12.4686H12.4686H12.4686H12.4686H12.4685H12.4685H12.4685H12.4685H12.4685H12.4684H12.4684H12.4684H12.4684H12.4684H12.4683H12.4683H12.4683H12.4683H12.4683H12.4682H12.4682H12.4682H12.4682H12.4682H12.4681H12.4681H12.4681H12.4681H12.4681H12.468H12.468H12.468H12.468H12.468H12.4679H12.4679H12.4679H12.4679H12.4679H12.4678H12.4678H12.4678H12.4678H12.4678H12.4678H12.4677H12.4677H12.4677H12.4677H12.4677H12.4676H12.4676H12.4676H12.4676H12.4676H12.4675H12.4675H12.4675H12.4675H12.4675H12.4674H12.4674H12.4674H12.4674H12.4674H12.4674H12.4673H12.4673H12.4673H12.4673H12.4673H12.4672H12.4672H12.4672H12.4672H12.4672H12.4671H12.4671H12.4671H12.4671H12.4671H12.4671H12.467H12.467H12.467H12.467H12.467H12.4669H12.4669H12.4669H12.4669H12.4669H12.4668H12.4668H12.4668H12.4668H12.4668H12.4668H12.4667H12.4667H12.4667H12.4667H12.4667H12.4666H12.4666H12.4666H12.4666H12.4666H12.4665H12.4665H12.4665H12.4665H12.4665H12.4665H12.4664H12.4664H12.4664H12.4664H12.4664H12.4663H12.4663H12.4663H12.4663H12.4663H12.4662H12.4662H12.4662H12.4662H12.4662H12.4662H12.4661H12.4661H12.4661H12.4661H12.4661H12.466H12.466H12.466H12.466H12.466H12.4659H12.4659H12.4659H12.4659H12.4659H12.4658H12.4658H12.4658H12.4658H12.4658H12.4657H12.4657H12.4657H12.4657H12.4657H12.4656H12.4656H12.4656H12.4656H12.4656H12.4655H12.4655H12.4655H12.4655H12.4655H12.4654H12.4654H12.4654H12.4654H12.4654H12.4653H12.4653H12.4653H12.4653H12.4653H12.4652H12.4652H12.4652H12.4652H12.4652H12.4651H12.4651H12.4651H12.4651H12.4651H12.465H12.465H12.465H12.465H12.4649H12.4649H12.4649H12.4649H12.4649H12.4648H12.4648H12.4648H12.4648H12.4647H12.4647H12.4647H12.4647H12.4647H12.4646H12.4646H12.4646H12.4646H12.4645H12.4645H12.4645H12.4645H12.4645H12.4644H12.4644H12.4644H12.4644H12.4643H12.4643H12.4643H12.4643H12.4642H12.4642H12.4642H12.4642H12.4642H12.4641H12.4641H12.4641H12.4641H12.464H12.464H12.464H12.464H12.4639H12.4639H12.4639H12.4639H12.4638H12.4638H12.4638H12.4638H12.4637H12.4637H12.4637H12.4637H12.4636H12.4636H12.4636H12.4636H12.4635H12.4635H12.4635H12.4635H12.4634H12.4634H12.4634H12.4633H12.4633H12.4633H12.4633H12.4632H12.4632H12.4632H12.4632H12.4631H12.4631H12.4631H12.4631H12.463H12.463H12.463H12.4629H12.4629H12.4629H12.4629H12.4628H12.4628H12.4628H12.4627H12.4627H12.4627H12.4627H12.4626H12.4626H12.4626H12.4625H12.4625H12.4625H12.4624H12.4624H12.4624H12.4624H12.4623H12.4623H12.4623H12.4622H12.4622H12.4622H12.4621H12.4621H12.4621H12.462H12.462H12.462H12.462H12.4619H12.4619H12.4619H12.4618H12.4618H12.4618H12.4617H12.4617H12.4617H12.4616H12.4616H12.4616H12.4615H12.4615H12.4615H12.4614H12.4614H12.4614H12.4613H12.4613H12.4613H12.4612H12.4612H12.4612H12.4611H12.4611H12.461H12.461H12.461H12.4609H12.4609H12.4609H12.4608H12.4608H12.4608H12.4607H12.4607H12.4607H12.4606H12.4606H12.4605H12.4605H12.4605H12.4604H12.4604H12.4604H12.4603H12.4603H12.4602H12.4602H12.4602H12.4601H12.4601H12.4601H12.46H12.46H12.4599H12.4599H12.4599H12.4598H12.4598H12.4598H12.4597H12.4597H12.4596H12.4596H12.4596H12.4595H12.4595H12.4595H12.4594H12.4594H12.4593H12.4593H12.4593H12.4592H12.4592H12.4592H12.4591H12.4591H12.4591H12.459H12.459H12.4589H12.4589H12.4589H12.4588H12.4588H12.4588H12.4587H12.4587H12.4586H12.4586H12.4586H12.4585H12.4585H12.4585H12.4584H12.4584H12.4584H12.4583H12.4583H12.4582H12.4582H12.4582H12.4581H12.4581H12.4581H12.458H12.458H12.4579H12.4579H12.4579H12.4578H12.4578H12.4578H12.4577H12.4577H12.4577H12.4576H12.4576H12.4575H12.4575H12.4575H12.4574H12.4574H12.4574H12.4573H12.4573H12.4573H12.4572H12.4572H12.4571H12.4571H12.4571H12.457H12.457H12.457H12.4569H12.4569H12.4569H12.4568H12.4568H12.4568H12.4567H12.4567H12.4566H12.4566H12.4566H12.4565H12.4565H12.4565H12.4564H12.4564H12.4564H12.4563H12.4563H12.4563H12.4562H12.4562H12.4562H12.4561H12.4561H12.456H12.456H12.456H12.4559H12.4559H12.4559H12.4558H12.4558H12.4558H12.4557H12.4557H12.4557H12.4556H12.4556H12.4556H12.4555H12.4555H12.4555H12.4554H12.4554H12.4553H12.4553H12.4553H12.4552H12.4552H12.4552H12.4551H12.4551H12.4551H12.455H12.455H12.455H12.4549H12.4549H12.4549H12.4548H12.4548H12.4548H12.4547H12.4547H12.4547H12.4546H12.4546H12.4546H12.4545H12.4545H12.4545H12.4544H12.4544H12.4544H12.4543H12.4543H12.4543H12.4542H12.4542H12.4542H12.4541H12.4541H12.4541H12.454H12.454H12.454H12.4539H12.4539H12.4539H12.4538H12.4538H12.4538H12.4538H12.4537H12.4537H12.4537H12.4536H12.4536H12.4536H12.4535H12.4535H12.4535H12.4534H12.4534H12.4534H12.4533H12.4533H12.4533H12.4532H12.4532H12.4532H12.4532H12.4531H12.4531H12.4531H12.453H12.453H12.453H12.4529H12.4529H12.4529H12.4528H12.4528H12.4528H12.4528H12.4527H12.4527H12.4527H12.4526H12.4526H12.4526H12.4525H12.4525H12.4525H12.4525H12.4524H12.4524H12.4524H12.4523H12.4523H12.4523H12.4523H12.4522H12.4522H12.4522H12.4521H12.4521H12.4521H12.452H12.452H12.452H12.452H12.4519H12.4519H12.4519H12.4519H12.4518H12.4518H12.4518H12.4517H12.4517H12.4517H12.4517H12.4516H12.4516H12.4516H12.4515H12.4515H12.4515H12.4515H12.4514H12.4514H12.4514H12.4514H12.4513H12.4513H12.4513H12.4513H12.4512H12.4512H12.4512H12.4511H12.4511H12.4511H12.4511H12.451H12.451H12.451H12.451H12.4509H12.4509H12.4509H12.4509H12.4508H12.4508H12.4508H12.4508H12.4507H12.4507H12.4507H12.4507H12.4506H12.4506H12.4506H12.4506H12.4505H12.4505H12.4505H12.4505H12.4504H12.4504H12.4504H12.4504H12.4504H12.4503H12.4503H12.4503H12.4503H12.4502H12.4502H12.4502H12.4502H12.4501H12.4501H12.4501H12.4501H12.4501H12.45H12.45H12.45H12.45H12.4499H12.4499H12.4499H12.4499H12.4499H12.4498H12.4498H12.4498H12.4498H12.4498H12.4497H12.4497H12.4497H12.4497H12.4496H12.4496H12.4496H12.4496H12.4496H12.4495H12.4495H12.4495H12.4495H12.4495H12.4494H12.4494H12.4494H12.4494H12.4494H12.4494H12.4493H12.4493H12.4493H12.4493H12.4493H12.4492H12.4492H12.4492H12.4492H12.4492H12.4492H12.4491H12.4491H12.4491H12.4491H12.4491H12.449H12.449H12.449H12.449H12.449H12.449H12.4489H12.4489H12.4489H12.4489H12.4489H12.4489H12.4488H12.4488H12.4488H12.4488H12.4488H12.4488H12.4488H12.4487H12.4487H12.4487H12.4487H12.4487H12.4487H12.4487H12.4486H12.4486H12.4486H12.4486H12.4486H12.4485H12.4485H12.4485H12.4485H12.4484H12.4484H12.4484H12.4484H12.4483H12.4483H12.4483H12.4483H12.4483H12.4482H12.4482H12.4482H12.4482H12.4482H12.4481H12.4481H12.4481H12.4481H12.4481H12.448H12.448H12.448H12.448H12.448H12.448H12.448H12.4479H12.4479H12.4479H12.4479H12.4479H12.4479H12.4478H12.4478C11.969 19.358 11.4995 19.1763 11.1574 18.8125C11.157 18.8121 11.1566 18.8117 11.1562 18.8112L3.00087 10.028C1.0537 7.74905 1.31398 4.31877 3.58528 2.36256L21.1153 2.17264Z"
fill={color ? color : "#B0B0EE"}
stroke={color ? color : "#B0B0EE"}
stroke-width="1.5"
d="M21.8414 2.29583C20.6709 1.28935 19.2332 0.79248 17.8018 0.79248C16.3705 0.79248 14.92 1.30209 13.7686 2.29583C13.3742 2.63982 13.0497 3.04751 12.7634 3.48705L12.4708 3.93296L12.1782 3.48705C11.8983 3.04751 11.5738 2.63345 11.173 2.29583C10.0216 1.30209 8.59025 0.79248 7.13981 0.79248C5.68936 0.79248 4.27073 1.28935 3.1002 2.29583C0.511037 4.52538 0.2184 8.43664 2.44495 11.0293L10.6132 19.8264C11.1094 20.3552 11.7838 20.61 12.4517 20.61C12.4517 20.61 12.4581 20.61 12.4644 20.61C12.4708 20.61 12.4708 20.61 12.4772 20.61C13.1451 20.61 13.8195 20.3488 14.3157 19.8264L22.4839 11.0293C24.7105 8.43664 24.4179 4.52538 21.8287 2.29583H21.8414Z"
fill="#B0B0EE"
/>
</svg>
);
Expand Down
Loading

0 comments on commit 75ed9be

Please sign in to comment.