Files
vexplor_dev/frontend/hooks/usePopCompanyPath.ts

26 lines
778 B
TypeScript
Raw Normal View History

"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],
);
}