Replace hardcoded /COMPANY_7/ URL prefixes across POP pages and components with usePopCompanyPath() so navigation derives the company code from the authenticated user. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
26 lines
778 B
TypeScript
26 lines
778 B
TypeScript
"use client";
|
|
|
|
import { useCallback } from "react";
|
|
import { useAuth } from "@/hooks/useAuth";
|
|
|
|
/**
|
|
* POP 화면 내 경로 조립 훅.
|
|
* `/COMPANY_7/pop/...` 같은 하드코딩 접두사를 제거하고 로그인 사용자의 회사코드로 동적 조립.
|
|
*
|
|
* 사용 예:
|
|
* const companyPath = usePopCompanyPath();
|
|
* router.push(companyPath("/pop/inbound")); // → /COMPANY_50/pop/inbound (COMPANY_50 사용자인 경우)
|
|
* href={companyPath("/pop/inbound/purchase")}
|
|
*/
|
|
export function usePopCompanyPath() {
|
|
const { companyCode } = useAuth();
|
|
return useCallback(
|
|
(subpath: string) => {
|
|
const cc = companyCode || "";
|
|
const normalized = subpath.startsWith("/") ? subpath : `/${subpath}`;
|
|
return `/${cc}${normalized}`;
|
|
},
|
|
[companyCode],
|
|
);
|
|
}
|