1
1
'use client' ;
2
2
3
3
import { Modules } from '@o2s/api-harmonization' ;
4
- import React , { ReactNode , createContext , useContext } from 'react' ;
4
+ import React , { ReactNode , createContext , useContext , useState } from 'react' ;
5
5
6
6
import { PriceService , usePriceService } from '@/hooks/usePriceService' ;
7
7
@@ -14,14 +14,37 @@ interface GlobalProviderProps {
14
14
export interface GlobalContextType {
15
15
config : Modules . Page . Model . Init ;
16
16
priceService : PriceService ;
17
+ alternativeUrls : {
18
+ values : {
19
+ [ key : string ] : string ;
20
+ } ;
21
+ set : ( values : { [ key : string ] : string } ) => void ;
22
+ } ;
17
23
}
18
24
19
25
export const GlobalContext = createContext ( { } as GlobalContextType ) ;
20
26
21
27
export const GlobalProvider = ( { config, locale, children } : GlobalProviderProps ) => {
28
+ const [ alternativeUrls , setAlternativeUrls ] = useState < {
29
+ [ key : string ] : string ;
30
+ } > ( { } ) ;
31
+
22
32
const priceService = usePriceService ( locale ) ;
23
33
24
- return < GlobalContext . Provider value = { { config, priceService } } > { children } </ GlobalContext . Provider > ;
34
+ return (
35
+ < GlobalContext . Provider
36
+ value = { {
37
+ config,
38
+ priceService,
39
+ alternativeUrls : {
40
+ values : alternativeUrls ,
41
+ set : setAlternativeUrls ,
42
+ } ,
43
+ } }
44
+ >
45
+ { children }
46
+ </ GlobalContext . Provider >
47
+ ) ;
25
48
} ;
26
49
27
50
export const useGlobalContext = ( ) => useContext ( GlobalContext ) ;
0 commit comments