2022-03-07 14:50:00 +00:00
|
|
|
import {
|
|
|
|
getCurrencies,
|
|
|
|
getLanguages,
|
|
|
|
getWebsiteInterface,
|
|
|
|
} from "graphql/operations";
|
|
|
|
import {
|
|
|
|
GetCurrenciesQuery,
|
|
|
|
GetLanguagesQuery,
|
|
|
|
GetWebsiteInterfaceQuery,
|
|
|
|
} from "graphql/operations-types";
|
2022-03-27 15:01:14 +00:00
|
|
|
import { GetStaticPropsContext } from "next";
|
2022-03-07 14:50:00 +00:00
|
|
|
|
|
|
|
export interface AppStaticProps {
|
|
|
|
langui: GetWebsiteInterfaceQuery["websiteInterfaces"]["data"][number]["attributes"];
|
|
|
|
currencies: GetCurrenciesQuery["currencies"]["data"];
|
|
|
|
languages: GetLanguagesQuery["languages"]["data"];
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getAppStaticProps(
|
2022-03-27 15:01:14 +00:00
|
|
|
context: GetStaticPropsContext
|
2022-03-07 14:50:00 +00:00
|
|
|
): Promise<AppStaticProps> {
|
|
|
|
const languages = (await getLanguages({})).languages.data;
|
2022-03-27 15:01:14 +00:00
|
|
|
languages.sort((a, b) =>
|
|
|
|
a.attributes.localized_name.localeCompare(b.attributes.localized_name)
|
|
|
|
);
|
2022-03-07 14:50:00 +00:00
|
|
|
|
|
|
|
const currencies = (await getCurrencies({})).currencies.data;
|
2022-03-27 15:01:14 +00:00
|
|
|
currencies.sort((a, b) => a.attributes.code.localeCompare(b.attributes.code));
|
2022-03-07 14:50:00 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
langui: (
|
|
|
|
await getWebsiteInterface({
|
2022-03-27 15:01:14 +00:00
|
|
|
language_code: context.locale ?? "en",
|
2022-03-07 14:50:00 +00:00
|
|
|
})
|
|
|
|
).websiteInterfaces.data[0].attributes,
|
|
|
|
currencies: currencies,
|
|
|
|
languages: languages,
|
|
|
|
};
|
|
|
|
}
|