-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathApp.js
More file actions
91 lines (79 loc) · 1.93 KB
/
Copy pathApp.js
File metadata and controls
91 lines (79 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import React from 'react';
import ReactDOM from 'react-dom';
import i18n from "i18next";
import {initReactI18next} from "react-i18next";
import "/styles/style.css"
import "tailwindcss/dist/base.min.css"
import "bulma/css/bulma.min.css"
import Pages from './pages';
import GlobalStyles from "./styles/GlobalStyles";
import english from "./translations/english";
import sinhala from "./translations/sinhala";
import tamil from "./translations/tamil";
//Setting up apollo client
import { ApolloClient, ApolloProvider, InMemoryCache, createHttpLink } from "@apollo/client";
import {setContext} from "apollo-link-context";
import { ToastProvider } from "react-toast-notifications";
import { CloudinaryContext } from "cloudinary-react";
const uri = process.env.API_URI;
const httpLink = createHttpLink({uri});
const cache = new InMemoryCache();
const authLink = setContext((_,{headers})=>{
return{
headers:{
...headers,
authorization:localStorage.getItem('token')||''
}
}
})
const client = new ApolloClient({
link:authLink.concat(httpLink),
cache,
resolvers:{},
connectToDevTools:true
})
const data = {
isLoggedIn: !!localStorage.getItem('token')
}
cache.writeData({data});
client.onResetStore(()=>cache.writeData({data}))
//End of query
//Translation stuff
i18n.use(initReactI18next).init({
resources:{
en:{
translation:{
...english
}
},
si:{
translation:{
...sinhala
}
},
ta:{
translation:{
...tamil
}
}
}
,
lng:"en",
fallbackLng:"en",
interpolation:{
escapeValue:false
}
});
const App = () => {
return (
<ApolloProvider client={client}>
<CloudinaryContext cloudName={"ded0k5ukr"}>
<ToastProvider>
<GlobalStyles/>
<Pages />
</ToastProvider>
</CloudinaryContext>
</ApolloProvider>
);
};
ReactDOM.render(<App />, document.getElementById('root'));