-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added use query to the project and removed sagas
- Loading branch information
1 parent
5df8b2b
commit a49101a
Showing
54 changed files
with
305 additions
and
1,031 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, { createContext } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import { useGetUser } from '../queries/user/user'; | ||
|
||
export const UserContext = createContext(null); | ||
|
||
const UserContextProvider = ({ children }) => { | ||
const { data } = useGetUser(); | ||
|
||
return ( | ||
<UserContext.Provider value={data?.data}>{children}</UserContext.Provider> | ||
); | ||
}; | ||
|
||
UserContextProvider.propTypes = { | ||
children: PropTypes.node | ||
}; | ||
|
||
export default UserContextProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,45 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
import App from 'next/app'; | ||
import React from 'react'; | ||
import cookies from 'next-cookies'; | ||
import PropTypes from 'prop-types'; | ||
import { QueryClient, QueryClientProvider } from 'react-query'; | ||
|
||
import { appWithTranslation } from '../i18n'; | ||
import { wrapper } from '../store'; | ||
import AuthService from '../services/AuthService'; | ||
import { userGet } from '../store/actions/UserActions'; | ||
import Layout from '../components/shared/layout/Layout'; | ||
import UserContextProvider from '../context/UserContext'; | ||
|
||
class MyApp extends App { | ||
static async getInitialProps({ Component, ctx }) { | ||
let pageProps = {}; | ||
const queryClient = new QueryClient(); | ||
|
||
const auth = cookies(ctx).access_token; | ||
const MyApp = ({ Component, pageProps, hideHeader }) => ( | ||
<QueryClientProvider client={queryClient}> | ||
<UserContextProvider> | ||
<Layout hideHeader={hideHeader}> | ||
<Component {...pageProps} /> | ||
</Layout> | ||
</UserContextProvider> | ||
</QueryClientProvider> | ||
); | ||
|
||
MyApp.propTypes = { | ||
Component: PropTypes.node, | ||
pageProps: PropTypes.object, | ||
hideHeader: PropTypes.bool | ||
}; | ||
|
||
if (auth) { | ||
AuthService.attachAuthHeader(auth); | ||
ctx.store.dispatch(userGet()); | ||
} | ||
MyApp.getInitialProps = async ({ Component, ctx }) => { | ||
let pageProps = {}; | ||
|
||
if (Component.getInitialProps) { | ||
pageProps = await Component.getInitialProps({ ctx }); | ||
} | ||
const auth = cookies(ctx).access_token; | ||
|
||
return { pageProps, hideHeader: Component.hideHeader }; | ||
if (auth) { | ||
AuthService.attachAuthHeader(auth); | ||
} | ||
|
||
render() { | ||
const { Component, pageProps, hideHeader } = this.props; | ||
return ( | ||
<Layout hideHeader={hideHeader}> | ||
<Component {...pageProps} /> | ||
</Layout> | ||
); | ||
if (Component.getInitialProps) { | ||
pageProps = await Component.getInitialProps({ ctx }); | ||
} | ||
} | ||
|
||
export default wrapper.withRedux(appWithTranslation(MyApp)); | ||
return { pageProps, hideHeader: Component.hideHeader }; | ||
}; | ||
|
||
export default appWithTranslation(MyApp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export default (req, res) => { | ||
res.statusCode = 200; | ||
res.setHeader('Content-Type', 'application/json'); | ||
res.end(JSON.stringify({ first_name: 'David', last_name: 'Beckham' })); | ||
res.end(); | ||
}; |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.