add token and some styling
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ public/index.html
|
|||||||
public/sw/
|
public/sw/
|
||||||
config/env/lottery.config.js
|
config/env/lottery.config.js
|
||||||
config/env/push.config.js
|
config/env/push.config.js
|
||||||
|
config/env/vinmonopolet.config.js
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const express = require("express");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const fetch = require('node-fetch')
|
const fetch = require('node-fetch')
|
||||||
|
const config = require(path.join(__dirname + "/../config/env/vinmonopolet.config"));
|
||||||
|
|
||||||
const mustBeAuthenticated = require(path.join(__dirname + "/../middleware/mustBeAuthenticated"))
|
const mustBeAuthenticated = require(path.join(__dirname + "/../middleware/mustBeAuthenticated"))
|
||||||
|
|
||||||
@@ -10,7 +11,7 @@ router.use((req, res, next) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const convertToOurWineObject = wine => {
|
const convertToOurWineObject = wine => {
|
||||||
console.log("traff her", wine)
|
if(wine.basic.ageLimit === "18"){
|
||||||
return {
|
return {
|
||||||
name: wine.basic.productShortName,
|
name: wine.basic.productShortName,
|
||||||
image: `https://bilder.vinmonopolet.no/cache/300x300-0/${wine.basic.productId}-1.jpg`,
|
image: `https://bilder.vinmonopolet.no/cache/300x300-0/${wine.basic.productId}-1.jpg`,
|
||||||
@@ -20,23 +21,21 @@ const convertToOurWineObject = wine => {
|
|||||||
vivinoLink: undefined
|
vivinoLink: undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
router.route("/wineinfo/search").get(async (req, res) => {
|
router.route("/wineinfo/search").get(async (req, res) => {
|
||||||
console.log("h")
|
|
||||||
console.log(req)
|
|
||||||
const {query} = req.query
|
const {query} = req.query
|
||||||
let url = new URL(`https://apis.vinmonopolet.no/products/v0/details-normal?productShortNameContains=test&maxResults=5`)
|
let url = new URL(`https://apis.vinmonopolet.no/products/v0/details-normal?productShortNameContains=test&maxResults=5`)
|
||||||
url.searchParams.set('productShortNameContains', query)
|
url.searchParams.set('productShortNameContains', query)
|
||||||
|
|
||||||
const vinmonopoletResponse = await fetch(url, {
|
const vinmonopoletResponse = await fetch(url, {
|
||||||
headers: {
|
headers: {
|
||||||
"Ocp-Apim-Subscription-Key": ""
|
"Ocp-Apim-Subscription-Key": `${config.gatewayToken}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
|
|
||||||
const winesConverted = vinmonopoletResponse.map(convertToOurWineObject)
|
const winesConverted = vinmonopoletResponse.map(convertToOurWineObject).filter(Boolean)
|
||||||
console.log(winesConverted)
|
|
||||||
|
|
||||||
if (vinmonopoletResponse.errors != null) {
|
if (vinmonopoletResponse.errors != null) {
|
||||||
return vinmonopoletResponse.errors.map(error => {
|
return vinmonopoletResponse.errors.map(error => {
|
||||||
|
|||||||
@@ -1,16 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<main>
|
<main>
|
||||||
<h1>
|
<h1>
|
||||||
Anbefal en vin!
|
Foreslå en vin!
|
||||||
</h1>
|
</h1>
|
||||||
<section>
|
<section>
|
||||||
<input type="text" v-model="searchString" >
|
<input type="text" v-model="searchString" >
|
||||||
<button @click=(fetchWineFromVin())>knapp</button>
|
<button @click=(fetchWineFromVin()) class="vin-button">Søk</button>
|
||||||
<div v-for="(wine, index) in this.wines" :key="index">
|
<section v-for="(wine, index) in this.wines" :key="index" class="search-results-container">
|
||||||
<Wine :wine=wine >
|
<img
|
||||||
<button>Pick</button>
|
v-if="wine.image"
|
||||||
</Wine>
|
:src="wine.image"
|
||||||
</div>
|
class="wine-image"
|
||||||
|
:class="{ 'fullscreen': fullscreen }"
|
||||||
|
/>
|
||||||
|
<img v-else class="wine-placeholder" alt="Wine image" />
|
||||||
|
<section class="wine-info">
|
||||||
|
<h2 v-if="wine.name">{{ wine.name }}</h2>
|
||||||
|
<h2 v-else>(no name)</h2>
|
||||||
|
<span v-if="wine.price">{{ wine.price }} NOK</span>
|
||||||
|
<span v-if="wine.country">{{ wine.country }}</span>
|
||||||
|
</section>
|
||||||
|
<section class="buttons">
|
||||||
|
<button class="vin-button">Send inn denne som ønske</button>
|
||||||
|
<button class="vin-button">Les mer på polet</button>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
</template>
|
</template>
|
||||||
@@ -39,6 +53,48 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style lang="scss" scoped>
|
||||||
|
@import "./src/styles/media-queries";
|
||||||
|
@import "./src/styles/global";
|
||||||
|
@import "./src/styles/variables";
|
||||||
|
|
||||||
|
main{
|
||||||
|
margin: auto;
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"] {
|
||||||
|
width: 100%;
|
||||||
|
color: black;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
border: 1px solid black;
|
||||||
|
max-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-results-container{
|
||||||
|
display: flex;
|
||||||
|
border: 1px solid black;
|
||||||
|
|
||||||
|
.buttons{
|
||||||
|
margin-left: auto;
|
||||||
|
order: 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.wine-image {
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wine-placeholder {
|
||||||
|
height: 100px;
|
||||||
|
width: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wine-info{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user