diff --git a/src/App.vue b/src/App.vue index c55ec16..6a69bdc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,7 +13,8 @@ :typesOfGarnish="typesOfGarnish" @newGarnish="addGarnish" @newGarnishType="addGarnishType" - @newTonicType="addTonicType" /> + @newTonicType="addTonicType" + @newGinType="addGinType" /> @@ -40,23 +41,52 @@ export default { this.getGarnish() }, async getGin() { - const headers = { "X-Master-Key": process.env.VUE_APP_MASTERKEY } + const headers = { "X-Master-Key": process.env.VUE_APP_MASTERKEY, "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" } let request = await fetch(`https://api.jsonbin.io/v3/b/${process.env.VUE_APP_ENDPOINT_GIN}/latest`, { headers }) - .then(response =>response.json()) + .then(response => response.json()) - this.gins = request.record.gins; - this.typesOfGin = request.record.types; + this.gins = request.record.gins + this.typesOfGin = request.record.types }, addGin(gin) { console.log("Add the gin: ", gin) }, - addGinType(typeName) { - console.log("Add the type: ", typeName) + async addGinType(typeName) { + let newId = null; + if(this.typesOfGin.length > 0) { + let lastIdInArray = this.typesOfGin.at(-1).id; + newId = lastIdInArray + 1; + } else { + newId = 1; + } + + const newData = { + types: this.typesOfGin, + gins: this.gins + } + + newData.types.push({ + id: newId, + name: typeName + }) + + const options = { + method: "PUT", + headers: { "X-Master-Key": process.env.VUE_APP_MASTERKEY, "Content-Type": "application/json" }, + body: JSON.stringify(newData) + } + + await fetch(`https://api.jsonbin.io/v3/b/${process.env.VUE_APP_ENDPOINT_GIN}`, options) + .then(response => { + if(response.ok) { + this.getGin() + } + }) }, async getTonic() { const headers = { "X-Master-Key": process.env.VUE_APP_MASTERKEY } let request = await fetch(`https://api.jsonbin.io/v3/b/${process.env.VUE_APP_ENDPOINT_TONIC}/latest`, { headers }) - .then(response =>response.json()) + .then(response => response.json()) this.tonics = request.record.tonics; this.typesOfTonic = request.record.types; @@ -100,7 +130,7 @@ export default { async getGarnish() { const headers = { "X-Master-Key": process.env.VUE_APP_MASTERKEY } let request = await fetch(`https://api.jsonbin.io/v3/b/${process.env.VUE_APP_ENDPOINT_GARNISH}/latest`, { headers }) - .then(response =>response.json()) + .then(response => response.json()) this.garnish = request.record.garnish this.typesOfGarnish = request.record.types @@ -191,9 +221,6 @@ export default { margin: 0; height: 100%; font-size: 16px; - font-family: "Poppins", sans-serif; - background-color: $color--chalky; - overflow: hidden; } h1 { @@ -273,8 +300,10 @@ export default { } textarea { + margin-top: 12px; padding: 12px; width: 100%; + min-height: 125px; font-family: "Poppins", sans-serif; font-size: 16px; border-radius: 3px; diff --git a/src/assets/_variables.scss b/src/assets/_variables.scss index ab983b2..2dcb46a 100644 --- a/src/assets/_variables.scss +++ b/src/assets/_variables.scss @@ -4,4 +4,5 @@ $color--white: #fff; $color--swan-white: #f7f1e3; $color--crocodile-tooth: #d1ccc0; $color--chalky: #e2d78a; -$color--black: #000000; \ No newline at end of file +$color--black: #000000; +$color--ocean-green: #4CA886; \ No newline at end of file diff --git a/src/assets/hand.gif b/src/assets/hand.gif new file mode 100644 index 0000000..3c10076 Binary files /dev/null and b/src/assets/hand.gif differ diff --git a/src/assets/logo.png b/src/assets/logo.png deleted file mode 100644 index f3d2503..0000000 Binary files a/src/assets/logo.png and /dev/null differ diff --git a/src/components/GinForm.vue b/src/components/GinForm.vue index 96da1b6..d4a9fc3 100644 --- a/src/components/GinForm.vue +++ b/src/components/GinForm.vue @@ -9,6 +9,20 @@ +
+ Gin type +
+ + +
+ +
@@ -31,13 +45,28 @@ typesOfTonic: { type: Array, default: Array.empty + }, + typesOfGin: { + type: Array, + default: Array.empty, } }, data() { return { + showNewType: false, + newType: "", + pickedGinType: "", ginName: "", ginDescription: "" } + }, + methods: { + addType() { + this.$emit("newType", this.newType); + + this.newType = ""; + this.showNewType = false; + } } } \ No newline at end of file diff --git a/src/components/Panel.vue b/src/components/Panel.vue index 0beaab8..6d8560c 100644 --- a/src/components/Panel.vue +++ b/src/components/Panel.vue @@ -34,9 +34,12 @@