feat: enhance domain handling for global representatives
- Updated `getStateInfo` to fetch site context for domains not in city.json, returning `repContext` with representative details. - Implemented caching for site context requests to optimize performance. - Modified doctor and clinic listing pages to pass the `domain` parameter when fetching data for global representatives. - Adjusted metadata generation in layout and pages to reflect representative branding based on `repContext`. - Added documentation for the new functionality in `.claude/prompt/global-rep-domain-site.md`.
This commit is contained in:
+10
-3
@@ -18,8 +18,8 @@ function listingRobots(params) {
|
||||
|
||||
export async function generateMetadata({ searchParams }) {
|
||||
const awaitedParams = await searchParams;
|
||||
const { matchedCity, matchedState } = await getStateInfo();
|
||||
const siteName = matchedCity?.site_name || "نوبت 724";
|
||||
const { matchedCity, matchedState, repContext } = await getStateInfo();
|
||||
const siteName = matchedCity?.site_name || repContext?.full_name || "نوبت 724";
|
||||
const cityName = matchedCity?.name || matchedState?.name || "";
|
||||
const title = cityName
|
||||
? `کلینیکهای ${cityName} | جستجو و رزرو نوبت | ${siteName}`
|
||||
@@ -39,7 +39,7 @@ export async function generateMetadata({ searchParams }) {
|
||||
|
||||
export default async function Clinics({ searchParams }) {
|
||||
const awaitedSearchParams = await searchParams;
|
||||
const { matchedCity, matchedState, isRoot } = await getStateInfo();
|
||||
const { matchedCity, matchedState, isRoot, repContext, host } = await getStateInfo();
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
||||
const stateParams = awaitedSearchParams.state;
|
||||
const cityParams = awaitedSearchParams.city;
|
||||
@@ -59,6 +59,13 @@ export default async function Clinics({ searchParams }) {
|
||||
|
||||
const params = buildClinicParams(newSearchParams);
|
||||
|
||||
// دامنهی نماینده سراسری: backend فقط کلینیکهای همان نماینده را برمیگرداند؛ فیلتر شهر بیمعنی است.
|
||||
if (repContext?.is_global) {
|
||||
delete params.city;
|
||||
delete params.state;
|
||||
params.domain = host;
|
||||
}
|
||||
|
||||
// Req
|
||||
clinics = await fetchReq(`${API_URL}/api/v1/clinics`, {
|
||||
params,
|
||||
|
||||
Reference in New Issue
Block a user