Skip to content

Commit 6187f78

Browse files
authored
Merge pull request #767 from w3bdesign/dev
Refactor
2 parents b7ab0ad + 43f6614 commit 6187f78

File tree

10 files changed

+161
-185
lines changed

10 files changed

+161
-185
lines changed
Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,55 @@
11
/**
22
* The SVG that we display to close the cart or the mobile search
33
*/
4-
const SVGCloseX = ({ setisExpanded }) => {
5-
return (
6-
<>
7-
<svg
8-
width="80px"
9-
height="80px"
10-
xmlns="https://www.w3.org/2000/svg"
11-
viewBox="0 0 234.6 45.47"
12-
onClick={() => {
13-
setisExpanded(false);
14-
}}
15-
>
16-
<path
17-
d="M202.83,209.89H181v-42H186v37.56h16.87Z"
18-
transform="translate(-181.03 -167)"
19-
/>
20-
<path
21-
d="M239.16,192.9q0,17.7-16,17.7-15.28,0-15.29-17v-25.7h4.92v25.37q0,12.93,10.9,12.92,10.51,0,10.52-12.48V167.88h4.92Z"
22-
transform="translate(-181.03 -167)"
23-
/>
24-
<path
25-
d="M278.89,209.89H272L255.8,190.68a11.17,11.17,0,0,1-1.11-1.47h-.12v20.68h-4.92v-42h4.92v19.75h.12a11.26,11.26,0,0,1,1.11-1.44l15.7-18.31h6.13l-18,20.16Z"
26-
transform="translate(-181.03 -167)"
27-
/>
28-
<path
29-
d="M313.69,209.89h-6.86L290.6,190.68a13.49,13.49,0,0,1-1.11-1.47h-.12v20.68h-4.92v-42h4.92v19.75h.12a12.26,12.26,0,0,1,1.11-1.44l15.71-18.31h6.12l-18,20.16Z"
30-
transform="translate(-181.03 -167)"
31-
/>
32-
<line
33-
x1="232.6"
34-
y1="2"
35-
x2="188.6"
36-
y2="43.47"
37-
fill="none"
38-
stroke="#000"
39-
strokeLinecap="round"
40-
strokeLinejoin="round"
41-
strokeWidth="4"
42-
/>
43-
<line
44-
x1="188.6"
45-
y1="2"
46-
x2="232.6"
47-
y2="43.47"
48-
fill="none"
49-
stroke="#000"
50-
strokeLinecap="round"
51-
strokeLinejoin="round"
52-
strokeWidth="4"
53-
/>
54-
</svg>
55-
</>
56-
);
57-
};
4+
const SVGCloseX = ({ setisExpanded }) => (
5+
<svg
6+
width="80px"
7+
height="80px"
8+
xmlns="https://www.w3.org/2000/svg"
9+
viewBox="0 0 234.6 45.47"
10+
onClick={() => {
11+
setisExpanded(false);
12+
}}
13+
>
14+
<path
15+
d="M202.83,209.89H181v-42H186v37.56h16.87Z"
16+
transform="translate(-181.03 -167)"
17+
/>
18+
<path
19+
d="M239.16,192.9q0,17.7-16,17.7-15.28,0-15.29-17v-25.7h4.92v25.37q0,12.93,10.9,12.92,10.51,0,10.52-12.48V167.88h4.92Z"
20+
transform="translate(-181.03 -167)"
21+
/>
22+
<path
23+
d="M278.89,209.89H272L255.8,190.68a11.17,11.17,0,0,1-1.11-1.47h-.12v20.68h-4.92v-42h4.92v19.75h.12a11.26,11.26,0,0,1,1.11-1.44l15.7-18.31h6.13l-18,20.16Z"
24+
transform="translate(-181.03 -167)"
25+
/>
26+
<path
27+
d="M313.69,209.89h-6.86L290.6,190.68a13.49,13.49,0,0,1-1.11-1.47h-.12v20.68h-4.92v-42h4.92v19.75h.12a12.26,12.26,0,0,1,1.11-1.44l15.71-18.31h6.12l-18,20.16Z"
28+
transform="translate(-181.03 -167)"
29+
/>
30+
<line
31+
x1="232.6"
32+
y1="2"
33+
x2="188.6"
34+
y2="43.47"
35+
fill="none"
36+
stroke="#000"
37+
strokeLinecap="round"
38+
strokeLinejoin="round"
39+
strokeWidth="4"
40+
/>
41+
<line
42+
x1="188.6"
43+
y1="2"
44+
x2="232.6"
45+
y2="43.47"
46+
fill="none"
47+
stroke="#000"
48+
strokeLinecap="round"
49+
strokeLinejoin="round"
50+
strokeWidth="4"
51+
/>
52+
</svg>
53+
);
5854

5955
export default SVGCloseX;

components/SVG/SVGX.component.jsx

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,26 @@
22
* The SVG that we display inside of the cart to remove items
33
*/
44

5-
const SVGX = ({ cartKey, products, handleRemoveProductClick }) => {
6-
return (
7-
<>
8-
<svg
9-
id="xsvg"
10-
xmlns="https://www.w3.org/2000/svg"
11-
width="20"
12-
height="20"
13-
viewBox="0 0 20 20"
14-
fill="none"
15-
stroke="currentColor"
16-
strokeWidth="2"
17-
strokeLinecap="round"
18-
strokeLinejoin="round"
19-
className="cursor-pointer feather feather-x"
20-
onClick={(event) => {
21-
handleRemoveProductClick(event, cartKey, products);
22-
}}
23-
>
24-
<line x1="18" y1="6" x2="6" y2="18"></line>
25-
<line x1="6" y1="6" x2="18" y2="18"></line>
26-
</svg>
27-
</>
28-
);
29-
};
5+
const SVGX = ({ cartKey, products, handleRemoveProductClick }) => (
6+
<svg
7+
id="xsvg"
8+
xmlns="https://www.w3.org/2000/svg"
9+
width="20"
10+
height="20"
11+
viewBox="0 0 20 20"
12+
fill="none"
13+
stroke="currentColor"
14+
strokeWidth="2"
15+
strokeLinecap="round"
16+
strokeLinejoin="round"
17+
className="cursor-pointer feather feather-x"
18+
onClick={(event) => {
19+
handleRemoveProductClick(event, cartKey, products);
20+
}}
21+
>
22+
<line x1="18" y1="6" x2="6" y2="18" />
23+
<line x1="6" y1="6" x2="18" y2="18" />
24+
</svg>
25+
);
3026

3127
export default SVGX;

pages/_app.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,13 @@ Router.events.on('routeChangeStart', () => NProgress.start());
1616
Router.events.on('routeChangeComplete', () => NProgress.done());
1717
Router.events.on('routeChangeError', () => NProgress.done());
1818

19-
const App = ({ Component, pageProps }) => {
20-
return (
21-
<>
22-
<ApolloProvider client={client}>
23-
<AppProvider>
24-
<Component {...pageProps} />
25-
<Footer />
26-
</AppProvider>
27-
</ApolloProvider>
28-
</>
29-
);
30-
};
19+
const App = ({ Component, pageProps }) => (
20+
<ApolloProvider client={client}>
21+
<AppProvider>
22+
<Component {...pageProps} />
23+
<Footer />
24+
</AppProvider>
25+
</ApolloProvider>
26+
);
3127

3228
export default App;

pages/handlekurv.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import Header from 'components/Header/Header.component';
22
import CartItemsContainer from 'components/Cart/CartPage/CartItemsContainer.component';
33
import PageTitle from 'components/Title/PageTitle.component';
44

5-
const Handlekurv = () => {
6-
return (
7-
<>
8-
<Header title="- Handlekurv" />
9-
<PageTitle title="Handlekurv" />
10-
<CartItemsContainer />
11-
</>
12-
);
13-
};
5+
const Handlekurv = () => (
6+
<>
7+
<Header title="- Handlekurv" />
8+
<PageTitle title="Handlekurv" />
9+
<CartItemsContainer />
10+
</>
11+
);
1412

1513
export default Handlekurv;

pages/index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ import { FETCH_ALL_PRODUCTS_QUERY } from 'utils/gql/GQL_QUERIES';
1212
* @param {Object} products
1313
* Initial static data is sent as props from getStaticProps and loaded through 'utils/gql/INITIAL_PRODUCTS'
1414
*/
15-
const HomePage = ({ products }) => {
16-
return (
17-
<>
18-
<Header title="- Forside" />
19-
<Hero />
20-
<PageTitle title="Produkter" />
21-
{products && <IndexProducts products={products} />}
22-
</>
23-
);
24-
};
15+
const HomePage = ({ products }) => (
16+
<>
17+
<Header title="- Forside" />
18+
<Hero />
19+
<PageTitle title="Produkter" />
20+
{products && <IndexProducts products={products} />}
21+
</>
22+
);
2523

2624
export default HomePage;
2725

pages/kategori/[slug].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { GET_PRODUCTS_FROM_CATEGORY } from 'utils/gql/GQL_QUERIES';
1212
* Display a single product with dynamic pretty urls
1313
*/
1414
const Produkt = ({ categoryName, products }) => {
15-
let error = false;
15+
const error = false;
1616

1717
return (
1818
<>

pages/produkt/[slug].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { GET_SINGLE_PRODUCT } from 'utils/gql/GQL_QUERIES';
1111
* Display a single product with dynamic pretty urls
1212
*/
1313
const Produkt = ({ product }) => {
14-
let error = false;
14+
const error = false;
1515

1616
return (
1717
<>

utils/apollo/ApolloClient.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,29 @@ export const middleware = new ApolloLink((operation, forward) => {
4545
*
4646
* This catches the incoming session token and stores it in localStorage, for future GraphQL requests.
4747
*/
48-
export const afterware = new ApolloLink((operation, forward) => {
49-
return forward(operation).map((response) => {
50-
/**
51-
* Check for session header and update session in local storage accordingly.
52-
*/
53-
const context = operation.getContext();
54-
const {
55-
response: { headers },
56-
} = context;
48+
export const afterware = new ApolloLink((operation, forward) => forward(operation).map((response) => {
49+
/**
50+
* Check for session header and update session in local storage accordingly.
51+
*/
52+
const context = operation.getContext();
53+
const {
54+
response: { headers },
55+
} = context;
5756

58-
const session = headers.get('woocommerce-session');
57+
const session = headers.get('woocommerce-session');
5958

60-
if (session && process.browser) {
61-
// Remove session data if session destroyed.
62-
if ('false' === session) {
63-
localStorage.removeItem('woo-session');
64-
// Update session new data if changed.
65-
} else if (localStorage.getItem('woo-session') !== session) {
66-
localStorage.setItem('woo-session', headers.get('woocommerce-session'));
67-
localStorage.setItem('woo-session-expiry', new Date());
68-
}
59+
if (session && process.browser) {
60+
// Remove session data if session destroyed.
61+
if ('false' === session) {
62+
localStorage.removeItem('woo-session');
63+
// Update session new data if changed.
64+
} else if (localStorage.getItem('woo-session') !== session) {
65+
localStorage.setItem('woo-session', headers.get('woocommerce-session'));
66+
localStorage.setItem('woo-session-expiry', new Date());
6967
}
70-
return response;
71-
});
72-
});
68+
}
69+
return response;
70+
}));
7371

7472
const clientSide = typeof window === 'undefined';
7573

utils/constants/LINKS.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//exports.default = [
21
const LINKS = [
32
{
43
id: 0,

0 commit comments

Comments
 (0)