Skip to content

Commit

Permalink
Merge branch 'develop' of github.com-A:YAPP-Github/24th-Web-Team-1-FE…
Browse files Browse the repository at this point in the history
… into bugfix/QA-107
  • Loading branch information
Happhee committed Jul 7, 2024
2 parents 4c4bb4e + 3104a95 commit 06ff56a
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/app/problem/[problemId]/problemLastIdPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,6 @@ describe("마지막 문제 풀이 페이지 테스트", () => {
expect(isExistNextProblem).toBeCalled();

expect(clearProblem).toHaveBeenCalledOnce();
expect(push).toHaveBeenNthCalledWith(1, "/workbook/1");
expect(push).toHaveBeenNthCalledWith(1, "/");
});
});
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
22 changes: 9 additions & 13 deletions src/app/workbook/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import { getWorkbookId } from "@workbook/utils";

import SubscribeBottomBar from "@subscription/components/SubscribeBottomBar";

import { EVENT_NAME } from "@shared/constants/mixpanel";
import { Mixpanel } from "@shared/utils/mixpanel";
import { useEffect } from "react";

export default function WorkbookPage() {
// usePathname 로 workbook id 받기
const pathname = usePathname();
Expand All @@ -30,15 +26,15 @@ export default function WorkbookPage() {
...getWorkbookQueryOptions(workbookId),
});

useEffect(
function trackMixpanel() {
Mixpanel.track({
name: EVENT_NAME.WORKBOOK_APPEAR,
property: { id: workbookId },
});
},
[pathname],
);
// useEffect(
// function trackMixpanel() {
// Mixpanel.track({
// name: EVENT_NAME.WORKBOOK_APPEAR,
// property: { id: workbookId },
// });
// },
// [pathname],
// );

if (isLoading) return <WorkbookSkeleton />;

Expand Down
12 changes: 5 additions & 7 deletions src/article/components/ArticleBottomButton/indext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import { useProblemIdsViewModel } from "@common/models/useProblemIdsViewModel";
import { Button } from "@shared/components/ui/button";
import { EVENT_NAME } from "@shared/constants/mixpanel";
import { Mixpanel } from "@shared/utils/mixpanel";
import { useParams, useRouter } from "next/navigation";
import React, { HTMLAttributes } from "react";
import { HTMLAttributes } from "react";

interface ArticleBottomButtonProps extends HTMLAttributes<HTMLButtonElement> {}
export default function ArticleBottomButton({
Expand All @@ -16,10 +14,10 @@ export default function ArticleBottomButton({
const { getCurrentProblemId } = useProblemIdsViewModel();
const onClickGoProblem = () => {
push(`/problem/${getCurrentProblemId()}`);
Mixpanel.track({
name: EVENT_NAME.ARTICLE_PROBLEMBUTTON_TAPPED,
property: { id: articleId },
});
// Mixpanel.track({
// name: EVENT_NAME.ARTICLE_PROBLEMBUTTON_TAPPED,
// property: { id: articleId },
// });
};
return (
<Button
Expand Down
26 changes: 12 additions & 14 deletions src/article/components/ArticleTitle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import { getArticleWithWorkbookQueryOptions } from "@article/remotes/getArticleW
import { ArticleDetail, ArticleWithWorkbookDetail } from "@article/types";
import { ARTICLE_INFO_TYPE } from "@common/constants/articleCase";
import { useProblemIdsViewModel } from "@common/models/useProblemIdsViewModel";
import { EVENT_NAME } from "@shared/constants/mixpanel";
import { Mixpanel } from "@shared/utils/mixpanel";
import ArticleSkeleton from "../ArticleSkeleton";
import WriterInfo from "../WriterInfo";
import { IS_EXIST_PROBLEMS } from "@shared/constants/middlewareConstant";
Expand Down Expand Up @@ -63,18 +61,18 @@ export default function ArticleTitle() {
[articleInfo],
);

useEffect(
function trackMixpanel() {
if (!isFirstRender.current) {
isFirstRender.current = true;
Mixpanel.track({
name: EVENT_NAME.ARTICLE_APPREAR,
property: { id: articleId },
});
}
},
[articleInfo],
);
// useEffect(
// function trackMixpanel() {
// if (!isFirstRender.current) {
// isFirstRender.current = true;
// Mixpanel.track({
// name: EVENT_NAME.ARTICLE_APPREAR,
// property: { id: articleId },
// });
// }
// },
// [articleInfo],
// );

if (isLoading || isError || !articleInfo)
return <ArticleSkeleton.TitleSkeleton />;
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
21 changes: 9 additions & 12 deletions src/problem/components/ProblemTitle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import { PROBLEM_TITLE_INFO } from "@problem/constants/problemInfo";
import { QUERY_KEY } from "@problem/remotes/api";
import { getProblemQueryOptions } from "@problem/remotes/getProblemQueryOptions";
import { AnswerCheckInfo } from "@problem/types/problemInfo";
import { EVENT_NAME } from "@shared/constants/mixpanel";
import { Mixpanel } from "@shared/utils/mixpanel";
import { useEffect } from "react";
import ProblemSkeleton from "../ProblemSkeleton";

export default function ProblemTitle() {
Expand All @@ -31,15 +28,15 @@ export default function ProblemTitle() {
select: (mutation) => mutation.state.data as ApiResponse<AnswerCheckInfo>,
});

useEffect(
function trackMixpanel() {
Mixpanel.track({
name: EVENT_NAME.PROBLEM_APPEAR,
property: { id: problemId },
});
},
[problemId],
);
// useEffect(
// function trackMixpanel() {
// Mixpanel.track({
// name: EVENT_NAME.PROBLEM_APPEAR,
// property: { id: problemId },
// });
// },
// [problemId],
// );
if (isLoading || isError || !problemInfo)
return <ProblemSkeleton.TitleSkeleton />;

Expand Down

0 comments on commit 06ff56a

Please sign in to comment.