1
1
import { AppContext } from "../mod.ts" ;
2
2
import { GetShopInfo } from "../utils/storefront/queries.ts" ;
3
3
import {
4
+ CountryCode ,
5
+ LanguageCode ,
4
6
Shop ,
5
7
ShopMetafieldsArgs ,
6
8
} from "../utils/storefront/storefront.graphql.gen.ts" ;
7
- import { Metafield } from "../utils/types.ts" ;
9
+ import { LanguageContextArgs , Metafield } from "../utils/types.ts" ;
8
10
9
11
export interface Props {
10
12
/**
11
13
* @title Metafields
12
14
* @description search for metafields
13
15
*/
14
16
metafields ?: Metafield [ ] ;
17
+ /**
18
+ * @title Language Code
19
+ * @description Language code for the storefront API
20
+ * @example "EN" for English, "FR" for French, etc.
21
+ */
22
+ languageCode ?: LanguageCode ;
23
+ /**
24
+ * @title Country Code
25
+ * @description Country code for the storefront API
26
+ * @example "US" for United States, "FR" for France, etc.
27
+ */
28
+ countryCode ?: CountryCode ;
15
29
}
16
30
17
31
export const defaultVisibility = "private" ;
@@ -22,10 +36,13 @@ const loader = async (
22
36
ctx : AppContext ,
23
37
) : Promise < Shop > => {
24
38
const { storefront } = ctx ;
25
- const { metafields = [ ] } = props ;
39
+ const { metafields = [ ] , languageCode = "PT" , countryCode = "BR" } = props ;
26
40
27
- const shop = await storefront . query < { shop : Shop } , ShopMetafieldsArgs > ( {
28
- variables : { identifiers : metafields } ,
41
+ const shop = await storefront . query <
42
+ { shop : Shop } ,
43
+ ShopMetafieldsArgs & LanguageContextArgs
44
+ > ( {
45
+ variables : { identifiers : metafields , languageCode, countryCode } ,
29
46
...GetShopInfo ,
30
47
} ) . then ( ( data ) => data . shop ) ;
31
48
0 commit comments