Skip to content

Commit

Permalink
Merge pull request #767 from w3bdesign/dev
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
w3bdesign authored Feb 2, 2022
2 parents b7ab0ad + 43f6614 commit 6187f78
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 185 deletions.
104 changes: 50 additions & 54 deletions components/SVG/SVGCloseX.component.jsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,55 @@
/**
* The SVG that we display to close the cart or the mobile search
*/
const SVGCloseX = ({ setisExpanded }) => {
return (
<>
<svg
width="80px"
height="80px"
xmlns="https://www.w3.org/2000/svg"
viewBox="0 0 234.6 45.47"
onClick={() => {
setisExpanded(false);
}}
>
<path
d="M202.83,209.89H181v-42H186v37.56h16.87Z"
transform="translate(-181.03 -167)"
/>
<path
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"
transform="translate(-181.03 -167)"
/>
<path
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"
transform="translate(-181.03 -167)"
/>
<path
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"
transform="translate(-181.03 -167)"
/>
<line
x1="232.6"
y1="2"
x2="188.6"
y2="43.47"
fill="none"
stroke="#000"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="4"
/>
<line
x1="188.6"
y1="2"
x2="232.6"
y2="43.47"
fill="none"
stroke="#000"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="4"
/>
</svg>
</>
);
};
const SVGCloseX = ({ setisExpanded }) => (
<svg
width="80px"
height="80px"
xmlns="https://www.w3.org/2000/svg"
viewBox="0 0 234.6 45.47"
onClick={() => {
setisExpanded(false);
}}
>
<path
d="M202.83,209.89H181v-42H186v37.56h16.87Z"
transform="translate(-181.03 -167)"
/>
<path
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"
transform="translate(-181.03 -167)"
/>
<path
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"
transform="translate(-181.03 -167)"
/>
<path
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"
transform="translate(-181.03 -167)"
/>
<line
x1="232.6"
y1="2"
x2="188.6"
y2="43.47"
fill="none"
stroke="#000"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="4"
/>
<line
x1="188.6"
y1="2"
x2="232.6"
y2="43.47"
fill="none"
stroke="#000"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="4"
/>
</svg>
);

export default SVGCloseX;
46 changes: 21 additions & 25 deletions components/SVG/SVGX.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,26 @@
* The SVG that we display inside of the cart to remove items
*/

const SVGX = ({ cartKey, products, handleRemoveProductClick }) => {
return (
<>
<svg
id="xsvg"
xmlns="https://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 20 20"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="cursor-pointer feather feather-x"
onClick={(event) => {
handleRemoveProductClick(event, cartKey, products);
}}
>
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</>
);
};
const SVGX = ({ cartKey, products, handleRemoveProductClick }) => (
<svg
id="xsvg"
xmlns="https://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 20 20"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="cursor-pointer feather feather-x"
onClick={(event) => {
handleRemoveProductClick(event, cartKey, products);
}}
>
<line x1="18" y1="6" x2="6" y2="18" />
<line x1="6" y1="6" x2="18" y2="18" />
</svg>
);

export default SVGX;
20 changes: 8 additions & 12 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ Router.events.on('routeChangeStart', () => NProgress.start());
Router.events.on('routeChangeComplete', () => NProgress.done());
Router.events.on('routeChangeError', () => NProgress.done());

const App = ({ Component, pageProps }) => {
return (
<>
<ApolloProvider client={client}>
<AppProvider>
<Component {...pageProps} />
<Footer />
</AppProvider>
</ApolloProvider>
</>
);
};
const App = ({ Component, pageProps }) => (
<ApolloProvider client={client}>
<AppProvider>
<Component {...pageProps} />
<Footer />
</AppProvider>
</ApolloProvider>
);

export default App;
16 changes: 7 additions & 9 deletions pages/handlekurv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import Header from 'components/Header/Header.component';
import CartItemsContainer from 'components/Cart/CartPage/CartItemsContainer.component';
import PageTitle from 'components/Title/PageTitle.component';

const Handlekurv = () => {
return (
<>
<Header title="- Handlekurv" />
<PageTitle title="Handlekurv" />
<CartItemsContainer />
</>
);
};
const Handlekurv = () => (
<>
<Header title="- Handlekurv" />
<PageTitle title="Handlekurv" />
<CartItemsContainer />
</>
);

export default Handlekurv;
18 changes: 8 additions & 10 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ import { FETCH_ALL_PRODUCTS_QUERY } from 'utils/gql/GQL_QUERIES';
* @param {Object} products
* Initial static data is sent as props from getStaticProps and loaded through 'utils/gql/INITIAL_PRODUCTS'
*/
const HomePage = ({ products }) => {
return (
<>
<Header title="- Forside" />
<Hero />
<PageTitle title="Produkter" />
{products && <IndexProducts products={products} />}
</>
);
};
const HomePage = ({ products }) => (
<>
<Header title="- Forside" />
<Hero />
<PageTitle title="Produkter" />
{products && <IndexProducts products={products} />}
</>
);

export default HomePage;

Expand Down
2 changes: 1 addition & 1 deletion pages/kategori/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { GET_PRODUCTS_FROM_CATEGORY } from 'utils/gql/GQL_QUERIES';
* Display a single product with dynamic pretty urls
*/
const Produkt = ({ categoryName, products }) => {
let error = false;
const error = false;

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion pages/produkt/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { GET_SINGLE_PRODUCT } from 'utils/gql/GQL_QUERIES';
* Display a single product with dynamic pretty urls
*/
const Produkt = ({ product }) => {
let error = false;
const error = false;

return (
<>
Expand Down
42 changes: 20 additions & 22 deletions utils/apollo/ApolloClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,29 @@ export const middleware = new ApolloLink((operation, forward) => {
*
* This catches the incoming session token and stores it in localStorage, for future GraphQL requests.
*/
export const afterware = new ApolloLink((operation, forward) => {
return forward(operation).map((response) => {
/**
* Check for session header and update session in local storage accordingly.
*/
const context = operation.getContext();
const {
response: { headers },
} = context;
export const afterware = new ApolloLink((operation, forward) => forward(operation).map((response) => {
/**
* Check for session header and update session in local storage accordingly.
*/
const context = operation.getContext();
const {
response: { headers },
} = context;

const session = headers.get('woocommerce-session');
const session = headers.get('woocommerce-session');

if (session && process.browser) {
// Remove session data if session destroyed.
if ('false' === session) {
localStorage.removeItem('woo-session');
// Update session new data if changed.
} else if (localStorage.getItem('woo-session') !== session) {
localStorage.setItem('woo-session', headers.get('woocommerce-session'));
localStorage.setItem('woo-session-expiry', new Date());
}
if (session && process.browser) {
// Remove session data if session destroyed.
if ('false' === session) {
localStorage.removeItem('woo-session');
// Update session new data if changed.
} else if (localStorage.getItem('woo-session') !== session) {
localStorage.setItem('woo-session', headers.get('woocommerce-session'));
localStorage.setItem('woo-session-expiry', new Date());
}
return response;
});
});
}
return response;
}));

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

Expand Down
1 change: 0 additions & 1 deletion utils/constants/LINKS.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//exports.default = [
const LINKS = [
{
id: 0,
Expand Down
Loading

0 comments on commit 6187f78

Please sign in to comment.