Added support for the homepage languages
This commit is contained in:
@@ -23,7 +23,7 @@ interface Contact {
|
|||||||
number: string;
|
number: string;
|
||||||
}
|
}
|
||||||
async function get(req: NextApiRequest, res: NextApiResponse) {
|
async function get(req: NextApiRequest, res: NextApiResponse) {
|
||||||
const { code } = req.query as { code: string };
|
const { code, language = 'en' } = req.query as { code: string, language: string};
|
||||||
|
|
||||||
const usersQuery = query(
|
const usersQuery = query(
|
||||||
collection(db, "users"),
|
collection(db, "users"),
|
||||||
@@ -44,8 +44,10 @@ async function get(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
}) as Contact[];
|
}) as Contact[];
|
||||||
|
|
||||||
const country = countryCodes.findOne("countryCode" as any, code);
|
const country = countryCodes.findOne("countryCode" as any, code);
|
||||||
|
const key = language === 'ar' ? 'countryNameLocal' : 'countryNameEn';
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
label: country.countryNameEn,
|
label: country[key],
|
||||||
entries,
|
entries,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ interface Contact {
|
|||||||
number: string;
|
number: string;
|
||||||
}
|
}
|
||||||
async function get(req: NextApiRequest, res: NextApiResponse) {
|
async function get(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
const { language = 'en' } = req.query as { language: string };
|
||||||
|
|
||||||
const usersQuery = query(
|
const usersQuery = query(
|
||||||
collection(db, "users"),
|
collection(db, "users"),
|
||||||
where("type", "==", "agent")
|
where("type", "==", "agent")
|
||||||
@@ -50,8 +52,9 @@ async function get(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
|
|
||||||
const result = Object.keys(data).map((code) => {
|
const result = Object.keys(data).map((code) => {
|
||||||
const country = countryCodes.findOne("countryCode" as any, code);
|
const country = countryCodes.findOne("countryCode" as any, code);
|
||||||
|
const key = language === 'ar' ? 'countryNameLocal' : 'countryNameEn';
|
||||||
return {
|
return {
|
||||||
label: country.countryNameEn,
|
label: country[key],
|
||||||
key: code,
|
key: code,
|
||||||
entries: data[code],
|
entries: data[code],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user