Skip to content

Commit

Permalink
Merge branch 'main' of github.com-A:YAPP-Github/24th-Web-Team-1-FE in…
Browse files Browse the repository at this point in the history
…to develop
  • Loading branch information
Happhee committed Jul 7, 2024
2 parents f9df6e0 + 308303a commit 3104a95
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/app/problem/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import { useProblemIdsViewModel } from "@common/models/useProblemIdsViewModel";
import { getProblemsQueryOptions } from "@problem/remotes/getProblemsQueryOptions";
import { IS_EXIST_PROBLEMS } from "@shared/constants/middlewareConstant";
import { postLogMutationOptions } from "@shared/remotes/postLogMutationOptions";
import { useMutation, useQuery } from "@tanstack/react-query";
import { setCookie } from "cookies-next";
import { useRouter, useSearchParams } from "next/navigation";
import { useEffect } from "react";

Expand All @@ -28,6 +30,7 @@ export default function ProblemPage() {
problemIds: problemData.problemIds,
articleId,
});
setCookie(IS_EXIST_PROBLEMS, "true");
postLog({ from: "email", to: "solveProblem" });
push(`/problem/${problemData.problemIds[currentIdx]}`);
}
Expand Down
7 changes: 3 additions & 4 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ export default async function middleware(req: NextRequest) {
const articleId = searchParams.get("articleId");
const workbookId = searchParams.get("workbookId");
const fromEmail = searchParams.get(LOG_PARAMS.FROM_EMAIL);

if (pathname === "/") {
return NextResponse.redirect(
"https://fewletter.notion.site/FEW-a87459feb21246b0bc63c68ef6140645"
"https://fewletter.notion.site/FEW-a87459feb21246b0bc63c68ef6140645",
);
}

Expand Down Expand Up @@ -92,7 +91,7 @@ export default async function middleware(req: NextRequest) {
return undefined;
}
}
if (pathname.includes("/problem")) {
if (pathname.includes("/problem") && !articleId) {
/** problme url 진입시 전역상태 없으면 들어올 수 없게 방어하는 로직 */
const isProblemIds = req.cookies.get(IS_EXIST_PROBLEMS)?.value === "true";

Expand All @@ -114,6 +113,6 @@ export const config = {
"/workbook/:path*",
"/problem/:path*",
"/article/:path*",
"/"
"/",
],
};
2 changes: 1 addition & 1 deletion src/problem/components/AnswerChoiceButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function AnswerChoiceButton({
)}
onClick={onClickAnswerChoice}
>
<span className="sub2-bold max-w-[247px] whitespace-normal">
<span className="sub2-bold max-w-[247px] whitespace-normal text-left">
{content}
</span>

Expand Down
6 changes: 4 additions & 2 deletions src/problem/components/AnswerSubmitButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ export default function AnswerSubmitButton() {
}
if (problemAnswerInfo[0] && !isExistNextProblem()) {
push("/");
clearProblem();
deleteCookie(IS_EXIST_PROBLEMS);
setTimeout(() => {
clearProblem();
deleteCookie(IS_EXIST_PROBLEMS);
}, 2000);
}
};
const isPostAnswerSuccess = problemAnswerInfo[0];
Expand Down

0 comments on commit 3104a95

Please sign in to comment.