261027_01_ENH: KON·KIWI 프로젝트 목록 및 현황 URL 조회를 backend bypass로 전환하고 연동 403 로그아웃 방지
This commit is contained in:
@@ -85,6 +85,15 @@ const SurveyProgressPage = () => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{redirectUrlEnabled && redirectUrlQuery.isError ? (
|
||||
<div role="alert" className="flex items-center gap-2 text-destructive">
|
||||
<span>설문 현황 링크를 불러오지 못했습니다.</span>
|
||||
<Button type="button" variant="outline" onClick={() => void redirectUrlQuery.refetch()}>
|
||||
다시 시도
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{openedUrl ? (
|
||||
<p>
|
||||
새 창에서 열립니다. 열리지 않았다면{" "}
|
||||
|
||||
@@ -279,6 +279,14 @@ const SurveyCard = ({ survey, index, itrntPrjctCd, userTeam, invalidField, onReg
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
/>
|
||||
{kartProjectListQuery.isError && (
|
||||
<div role="alert" className="flex items-center gap-2 text-destructive">
|
||||
<span>프로젝트 목록을 불러오지 못했습니다.</span>
|
||||
<Button type="button" variant="outline" size="sm" onClick={() => void kartProjectListQuery.refetch()}>
|
||||
다시 시도
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createKartApi} from "@/lib/http-server";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {KonKiwiProjectInfo} from "@/types/project";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
|
||||
@@ -9,30 +9,39 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const {slug = []} = await context.params;
|
||||
const [action] = slug;
|
||||
const kartApi = await createKartApi();
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if(action === "project-list" && slug.length === 4){
|
||||
if(action === "project-list" && slug.length === 3){
|
||||
const keyword = (searchParams.get("keyword") ?? "").trim();
|
||||
const result = await kartApi.get<KonKiwiProjectInfo[]>(
|
||||
`/project/list/${slug[1]}/${slug[2]}/${slug[3]}`,
|
||||
{ query: keyword ? { keyword } : {} }
|
||||
);
|
||||
const [, intranetCode, projectType] = slug;
|
||||
if (!intranetCode.trim() || intranetCode.length > 32 || !["0", "1"].includes(projectType)) {
|
||||
return NextResponse.json({ message: "프로젝트 정보를 확인해 주세요." }, { status: 400 });
|
||||
}
|
||||
const result = await contactApi.get<KonKiwiProjectInfo[]>(`/kart/project/list`, {
|
||||
query: { intranetCode, projectType, ...(keyword ? { keyword } : {}) },
|
||||
});
|
||||
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "survey-redirect-url" && slug.length === 3){
|
||||
const [, isKiwi, pkey] = slug;
|
||||
if (!["0", "1"].includes(isKiwi)) {
|
||||
return NextResponse.json({ message: "프로젝트 정보를 확인해 주세요." }, { status: 400 });
|
||||
}
|
||||
|
||||
const skey = await kartApi.get<string>(`/encrypt/pkey`, {
|
||||
headers: { pkey, iskiwi: isKiwi },
|
||||
});
|
||||
|
||||
const shortUrl = await kartApi.post<string>(
|
||||
`/uri/short`,
|
||||
{ realURI: "/Report/Current", mode: "U" },
|
||||
{ headers: { skey } },
|
||||
// Contact backend를 거쳐 KON/KIWI 현황 공유 링크를 발급한다.
|
||||
const result = await contactApi.post<unknown>(
|
||||
`/kart/project/${isKiwi}/${encodeURIComponent(pkey)}/share`,
|
||||
{},
|
||||
{ expectText: true },
|
||||
);
|
||||
const shortUrl = typeof result === "string" && /^https?:\/\//.test(result)
|
||||
? result
|
||||
: null;
|
||||
if (!shortUrl) {
|
||||
return NextResponse.json({ message: "KART 공유 링크 응답을 확인해 주세요." }, { status: 502 });
|
||||
}
|
||||
|
||||
return NextResponse.json(shortUrl, { status: 200 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user