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 }) {
|
||||
|
||||
async function Doctors({ 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;
|
||||
|
||||
let doctors = null;
|
||||
@@ -59,6 +59,13 @@ async function Doctors({ searchParams }) {
|
||||
|
||||
const params = buildDoctorParams(newSearchParams);
|
||||
|
||||
// دامنهی نماینده سراسری: backend فقط پزشکان همان نماینده را برمیگرداند؛ فیلتر شهر بیمعنی است.
|
||||
if (repContext?.is_global) {
|
||||
delete params.city_id;
|
||||
delete params.state_id;
|
||||
params.domain = host;
|
||||
}
|
||||
|
||||
doctors = await fetchReq(`${API_URL}/api/v1/doctors`, {
|
||||
params,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user