Skip to content

Commit 5caf92e

Browse files
authored
Merge pull request #161 from w3bdesign/development
Implement UI feedback while placing order
2 parents 2dba0aa + 1bbf6d4 commit 5caf92e

File tree

6 files changed

+36
-12
lines changed

6 files changed

+36
-12
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Start the server with ```npm run dev ```
2929
- Apollo Client with GraphQL
3030
- Animations with React-Spring
3131
- Shows loading spinner created with Styled Components while loading data and error message if data can not be loaded
32-
- Mobile menu
32+
- Shows page load progress with Nprogress during navigation
33+
- Mobile menu and cart slide-out with animations
3334
- List all product categories on a separate page
3435
- Link to individual product
3536
- Pretty URLs with builtin Nextjs functionality

components/Checkout/CheckoutForm.component.jsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { useState, useContext, useEffect } from 'react';
22
import { useQuery, useMutation } from '@apollo/react-hooks';
33

44
import Billing from './Billing.component';
5-
import OrderDetails from "./OrderDetails.component";
5+
import OrderDetails from './OrderDetails.component';
6+
import LoadingSpinner from '../LoadingSpinner/LoadingSpinner.component';
67
//import Payment from './Payment.component';
78

89
import { GET_CART } from 'utils/const/GQL_QUERIES';
@@ -102,22 +103,31 @@ const CheckoutForm = () => {
102103
{cart ? (
103104
<form onSubmit={handleFormSubmit} className="">
104105
<div className="container mx-auto">
105-
{/* Order*/}
106-
106+
{/* Order*/}
107+
107108
<OrderDetails cart={cart} />
108-
{/*Payment Details*/}
109-
<div className="">
110-
<Billing input={input} handleOnChange={handleOnChange} />
109+
{/*Payment Details*/}
110+
<div className="">
111+
<Billing input={input} handleOnChange={handleOnChange} />
111112
</div>
112-
113113

114114
{/* Checkout Loading*/}
115-
{checkoutLoading}
115+
116+
{checkoutLoading && (
117+
<div className="text-xl text-center">
118+
Behandler ordre, vennligst vent ...
119+
<br />
120+
<LoadingSpinner />
121+
</div>
122+
)}
123+
116124
{requestError}
117125
</div>
118126
</form>
119127
) : (
120-
''
128+
<div className="container m-12 mx-auto text-xl text-center">
129+
Takk for din ordre!
130+
</div>
121131
)}
122132
</>
123133
);

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"graphql-request": "^2.0.0",
2525
"graphql-tag": "^2.10.3",
2626
"next": "^9.4.4",
27+
"nprogress": "^0.2.0",
2728
"react": "^16.13.1",
2829
"react-dom": "^16.13.1",
2930
"react-instantsearch-dom": "^6.6.0",

pages/_app.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
import { ApolloProvider } from '@apollo/react-hooks';
2-
32
import { AppProvider } from 'utils/context/AppContext';
43

4+
import Router from 'next/router';
5+
import NProgress from 'nprogress';
6+
57
import Header from '../components/Header/Header.component';
68
import Footer from '../components/Footer/Footer.component';
79

810
import '../styles/index.css';
911
import '../styles/algolia.min.css';
12+
import 'nprogress/nprogress.css';
1013

1114
import client from '../utils/apollo/ApolloClient';
1215

16+
Router.events.on('routeChangeStart', () => NProgress.start());
17+
Router.events.on('routeChangeComplete', () => NProgress.done());
18+
Router.events.on('routeChangeError', () => NProgress.done());
19+
1320
const App = ({ Component, pageProps }) => {
1421
return (
1522
<>

utils/const/INITIAL_STATE.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const INITIAL_STATE = {
1212
country: 'NO',
1313
postcode: '1525',
1414
phone: '90561212',
15-
email: 'test@gmail.com',
15+
email: 'test@testemailgmail.com',
1616
company: 'Tech',
1717
createAccount: false,
1818
orderNotes: '',

0 commit comments

Comments
 (0)