refactor: improve key assignment in FrequentSearches and update TextHeader to use async getStateInfo
This commit is contained in:
+7
-3
@@ -6,12 +6,16 @@ import statesData from "@/data/state.json";
|
||||
|
||||
export async function getStateInfo() {
|
||||
const headersList = await headers();
|
||||
|
||||
const host = headersList.get("host") || "";
|
||||
const subdomain = host.split(".")[0];
|
||||
|
||||
const matchedCity = citiesData.find((city) =>
|
||||
city.domain.includes(subdomain),
|
||||
);
|
||||
// Match city by domain (supports both full domain and subdomain)
|
||||
const matchedCity = citiesData.find((city) => {
|
||||
const cityDomain = city.domain.split(".")[0]; // Extract subdomain from domain (e.g., "yasuj-nobat" from "yasuj-nobat.ir")
|
||||
return cityDomain === subdomain;
|
||||
});
|
||||
|
||||
const matchedState =
|
||||
matchedCity &&
|
||||
statesData.find((state) => state.id === matchedCity.province_id);
|
||||
|
||||
Reference in New Issue
Block a user