Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IDATT2106 Scrum Team 02
Frontend
Commits
bacc868a
Commit
bacc868a
authored
1 year ago
by
Katarzyna Szlejter
Browse files
Options
Downloads
Plain Diff
Merge branch 'recipe-view' into 'main'
Recipe view. Needs tests. See merge request
!18
parents
7b8db049
4f292785
No related branches found
Branches containing commit
No related tags found
1 merge request
!18
Recipe view. Needs tests.
Pipeline
#224925
passed
1 year ago
Stage: build
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/router/index.js
+6
-0
6 additions, 0 deletions
src/router/index.js
src/util/API.js
+16
-0
16 additions, 0 deletions
src/util/API.js
src/views/RecipeView.vue
+86
-0
86 additions, 0 deletions
src/views/RecipeView.vue
with
108 additions
and
0 deletions
src/router/index.js
+
6
−
0
View file @
bacc868a
...
@@ -6,6 +6,7 @@ import ProfileCreationView from '../views/ProfileCreationView.vue'
...
@@ -6,6 +6,7 @@ import ProfileCreationView from '../views/ProfileCreationView.vue'
import
RegisterAccountView
from
'
../views/RegisterAccountView.vue
'
import
RegisterAccountView
from
'
../views/RegisterAccountView.vue
'
import
PinCodeView
from
"
@/views/PinCodeView.vue
"
;
import
PinCodeView
from
"
@/views/PinCodeView.vue
"
;
import
FridgeView
from
"
@/views/FridgeView.vue
"
;
import
FridgeView
from
"
@/views/FridgeView.vue
"
;
import
RecipeView
from
"
@/views/RecipeView.vue
"
;
const
router
=
createRouter
({
const
router
=
createRouter
({
...
@@ -45,6 +46,11 @@ const router = createRouter({
...
@@ -45,6 +46,11 @@ const router = createRouter({
path
:
'
/myFridge
'
,
path
:
'
/myFridge
'
,
name
:
'
myFridge
'
,
name
:
'
myFridge
'
,
component
:
FridgeView
component
:
FridgeView
},
{
path
:
'
/recipe/:id
'
,
name
:
'
recipe
'
,
component
:
RecipeView
}
}
]
]
})
})
...
...
This diff is collapsed.
Click to expand it.
src/util/API.js
+
16
−
0
View file @
bacc868a
...
@@ -263,4 +263,20 @@ export const API = {
...
@@ -263,4 +263,20 @@ export const API = {
throw
new
Error
(
"
Could not fetch fridge item
"
);
throw
new
Error
(
"
Could not fetch fridge item
"
);
});
});
},
},
/**
* Get recipe based on id
* @param id
* @returns {Promise<*>}
*/
getRecipe
:
async
(
id
)
=>
{
return
axios
.
get
(
`
${
import
.
meta
.
env
.
VITE_BACKEND_URL
}
/recipe/
${
id
}
`
)
.
then
((
response
)
=>
{
console
.
log
(
response
.
data
);
return
response
.
data
;
})
.
catch
((
error
)
=>
{
throw
new
Error
(
error
);
})
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/views/RecipeView.vue
0 → 100644
+
86
−
0
View file @
bacc868a
<
script
>
import
{
API
}
from
"
@/util/API
"
;
export
default
{
name
:
"
RecipeView
"
,
data
()
{
return
{
recipe
:
{},
id
:
this
.
$route
.
params
.
id
,
title
:
""
,
description
:
""
,
time
:
""
,
ingredients
:
[],
instructions
:
""
,
}
},
methods
:
{
async
loadData
()
{
await
API
.
getRecipe
(
this
.
id
)
.
then
((
recipe
)
=>
{
this
.
title
=
recipe
.
title
;
this
.
description
=
recipe
.
description
;
this
.
time
=
recipe
.
time
;
this
.
ingredients
=
recipe
.
ingredient
;
this
.
instructions
=
recipe
.
instructions
;
})
},
addIngredientsShoppingList
()
{
//TODO add ingredients to shopping list
},
removeIngredientsFromFridge
()
{
//TODO remove used ingredients from fridge
}
},
async
mounted
()
{
await
this
.
loadData
();
}
}
</
script
>
<
template
>
<main>
<h1>
{{
this
.
title
}}
</h1><br>
<p>
{{
this
.
description
}}
</p><br>
<div
class=
"ingredients"
>
<h2>
Ingredienser
</h2>
<ul>
<li
v-for=
"ingredient in this.ingredients"
>
{{
ingredient
.
item
.
name
}}
{{
ingredient
.
amount
.
quantity
}}
{{
ingredient
.
amount
.
unit
}}
</li>
</ul>
<button
@
click=
"addIngredientsShoppingList"
>
Legg til ingrediensene i handlekurven
</button>
</div>
<div
class=
"instructions"
>
<h2>
Instruksjoner
</h2>
{{
this
.
instructions
}}
</div>
<button
@
click=
"removeIngredientsFromFridge"
>
Fjern varene fra kjøleskapet
</button>
</main>
</
template
>
<
style
scoped
lang=
"scss"
>
@media
(
min-width
:
base
.
$desktop-min
)
{
main
{
padding-top
:
45px
!
important
;
}
}
main
{
padding
:
20px
10px
;
.ingredients
{
margin-bottom
:
20px
;
}
button
{
min-height
:
40px
;
border-radius
:
0
;
border
:
1px
solid
;
cursor
:
pointer
;
padding
:
5px
;
}
}
</
style
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment