Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
15,920 changes: 10,495 additions & 5,425 deletions app/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-scripts": "^5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
Binary file added app/public/B.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/public/bilkaLogo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="B.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
Expand All @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Bilka Open Hours</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Binary file added app/public/sallingLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 68 additions & 27 deletions app/src/App.css
Original file line number Diff line number Diff line change
@@ -1,42 +1,83 @@
.App {
text-align: center;
}
/* body {
} */

.App-logo {
height: 40vmin;
pointer-events: none;
.header {
display: flex;
justify-content: space-around;
align-items: center;
width: 100%;
background-color: #0091cf;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
.Bilka-logo {
max-height: 50px;
}
.Salling-logo {
max-height: 50px;
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
h1 {
margin: 0;
text-align: center;
flex-grow: 1;
color: white;
font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
font-weight: 700;
}

.App-link {
color: #61dafb;
.App {
text-align: center;
display: flex;
flex-wrap: wrap;
margin: 0px;
justify-content: space-evenly;
}
.nav {
margin: 30px 0px 30px 0px;
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
}
.store {
width: 100%;
}
.store h3 {
color: #0091cf;
font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
font-weight: 700;
font-size: 20px;
}
.store p {
color: #0091cf;
font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
font-weight: 500;
font-size: 20px;
}

.button-wrapper {
margin:20px
.button-wrapper button {
background-color: #0091cf;
display: block;
padding: 10px 20px;
border: none;
border-radius: 5px;
color: white;
font-size: 15px;
font-weight: 600;
}
.button-wrapper button:hover {
background-color: #3fb4e6;
transition: all 0.5s ease;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
@media only screen and (max-width: 1024px) {
.button-wrapper {
width: 650px;
justify-content: center;
display: flex;
margin: 5px 0px 5px 0px;
}
to {
transform: rotate(360deg);
.button-wrapper button {
width: 230px;
}
}
157 changes: 97 additions & 60 deletions app/src/App.js
Original file line number Diff line number Diff line change
@@ -1,88 +1,125 @@
import './App.css';
import { useState } from 'react';
import "./App.css";
import { useState } from "react";

function App() {

const [data, setData] = useState(null);


const fetchStoreOpeningHours = () => {
fetch("/stores/").then( resp => resp.json()).then(data => {
setData(data)
});
}
fetch("/stores/")
.then((resp) => resp.json())
.then((data) => {
setData(data);
})
.catch(console.error());
};

const fetchStoreOpeningHoursBilkaTilts = () => {
fetch("/stores/efba0457-090e-4132-81ba-c72b4c8e7fee").then( resp => resp.json()).then(data => {
setData(data)
});
}
fetch("/stores/efba0457-090e-4132-81ba-c72b4c8e7fee")
.then((resp) => resp.json())
.then((data) => {
setData(data);
})
.catch(console.error());
};

const fetchStoreOpeningHoursByName = () => {
fetch("/sorted-stores/").then( resp => resp.json()).then(data => {
setData(data)
});
}
fetch("/sorted-stores/")
.then((resp) => resp.json())
.then((data) => {
setData(data);
})
.catch(console.error());
};

const showNearByStoreWithing10 = () => {
fetch("/find-nearby-stores/10").then( resp => resp.json()).then(data => {
if(!data.length) return;
setData(data)
});
}
fetch("/find-nearby-stores/10")
.then((resp) => resp.json())
.then((data) => {
if (!data.length) return;
setData(data);
})
.catch(console.error());
};

const showNearByStoreWithing50 = () => {
fetch("/find-nearby-stores/50").then( resp => resp.json()).then(data => {
if(!data.length) return;
setData(data)
});
}
fetch("/find-nearby-stores/50")
.then((resp) => resp.json())
.then((data) => {
if (!data.length) return;
setData(data);
})
.catch(console.error());
};

const renderOpeningHoursByStore = (store) => {
const openingHours = store.hours.filter((hour) => hour.type === 'store');

const weekdays = ["Sunday", "Monday", "Wednesday", "Thursday", "Friday", "Saturday"];

return (
<div>
const openingHours = store.hours.filter((hour) => hour.type === "store");

const weekdays = [
"Sunday",
"Monday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
];

return (
<div className="store">
<h3>{store.name} - Opening Hours</h3>
{openingHours.map((hours) => (
<p>{weekdays[new Date(hours.date).getDay()]} open from {new Date(hours.open).getHours()} to {new Date(hours.close).getHours()}</p>
<p>
{weekdays[new Date(hours.date).getDay()]} open from{" "}
{new Date(hours.open).getHours()} to{" "}
{new Date(hours.close).getHours()}
</p>
))}

</div>
)
}
);
};


return (
<div className="App">

<h1>Bilka stores - opening hours</h1>
<div className='button-wrapper'>
<button onClick={fetchStoreOpeningHours}>Fetch bilka opening hours</button>
</div>
<div className='button-wrapper'>
<button onClick={fetchStoreOpeningHoursBilkaTilts}>Fetch bilka Tilts</button>
</div>
<div className='button-wrapper'>
<button onClick={fetchStoreOpeningHoursByName}>Sorted by name asc</button>
</div>
<div className='button-wrapper'>
<button onClick={showNearByStoreWithing10}>Show stores within 10 Km</button>
</div>
<div className='button-wrapper'>
<button onClick={showNearByStoreWithing50}>Show stores within 50 Km</button>
</div>



<div className="header">
<img src="./bilkaLogo.jpg" className="Bilka-logo" alt="bilkalogo" />
<h1>Bilka stores - opening hours</h1>
<img
src="./sallingLogo.png"
className="Salling-logo"
alt="sallinglogo"
/>
</div>
<div className="nav">
<div className="button-wrapper">
<button onClick={fetchStoreOpeningHours}>
Fetch bilka opening hours
</button>
</div>
<div className="button-wrapper">
<button onClick={fetchStoreOpeningHoursBilkaTilts}>
Fetch bilka Tilts
</button>
</div>
<div className="button-wrapper">
<button onClick={fetchStoreOpeningHoursByName}>
Sorted by name asc
</button>
</div>
<div className="button-wrapper">
<button onClick={showNearByStoreWithing10}>
Show stores within 10 Km
</button>
</div>
<div className="button-wrapper">
<button onClick={showNearByStoreWithing50}>
Show stores within 50 Km
</button>
</div>
</div>

<div>
{data && data.map((store) => (<div>{renderOpeningHoursByStore(store)}</div>))}
{data &&
data.map((store) => <div>{renderOpeningHoursByStore(store)}</div>)}
</div>


</div>
);
}
Expand Down
3 changes: 3 additions & 0 deletions server/.env.expample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SERVER_PORT = SOME_PORT
API_TOKEN = YOUR_API_TOKEN
URL = example.com
Loading