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
40b47b86
Commit
40b47b86
authored
1 year ago
by
Ingrid Martinsheimen Egge
Browse files
Options
Downloads
Patches
Plain Diff
Beskjed til bruker på ingredienser som har gått ut på dato. Datoen kan forlenges med 5 dager
parent
0193bab7
No related branches found
No related tags found
1 merge request
!13
Fridge view
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/EatFridgeItemModal.vue
+42
-8
42 additions, 8 deletions
src/components/EatFridgeItemModal.vue
src/util/API.js
+1
-1
1 addition, 1 deletion
src/util/API.js
with
43 additions
and
9 deletions
src/components/EatFridgeItemModal.vue
+
42
−
8
View file @
40b47b86
...
...
@@ -12,6 +12,11 @@
<button
@
click=
"logFoodAsDiscarded"
>
Ble kastet 🗑️
</button>
<button
id=
"eatenBtn"
@
click=
"logFoodAsEaten"
>
Ble spist 😋
</button>
</div>
<div
v-if=
"isExpired"
id =
"itemHasExpiredMessage"
>
<h2>
Varen har gått ut på dato
</h2>
<p>
Se, lukt, smak : Hvis varen fortsatt ser fin ut, kan du forlenge utløpsdatoen med 5 dager
</p>
<button
id=
"eatenBtn"
@
click=
"extendExpiration"
>
Utsett utløpsdato med 5 dager
</button>
</div>
</div>
</
template
>
...
...
@@ -40,13 +45,8 @@ export default {
this
.
$emit
(
'
closeModal
'
,
this
);
},
logFoodAsEaten
(){
const
fridgeAction
=
"
CONSUMED
"
;
const
ingredientId
=
this
.
fridgeItem
.
ingredient_id
;
const
amountEaten
=
{
"
quantity
"
:
this
.
sliderValue
,
"
unit
"
:
this
.
fridgeItem
.
amount
.
unit
};
const
request
=
{
action
:
fridgeAction
,
...
...
@@ -64,6 +64,17 @@ export default {
logFoodAsDiscarded
(){
this
.
close
();
},
extendExpiration
(){
const
id
=
this
.
fridgeItem
.
ingredient_id
;
const
today
=
new
Date
();
const
fiveDays
=
new
Date
();
fiveDays
.
setDate
(
today
.
getDate
()
+
5
);
API
.
changeExpirationOfIngredient
({
"
ingredientId
"
:
id
,
"
newExpDate
"
:
fiveDays
}).
catch
((
error
)
=>
{
console
.
log
(
"
could not change date
"
)
})
this
.
close
();
}
},
computed
:{
redIconColor
()
{
...
...
@@ -74,11 +85,22 @@ export default {
},
maxValue
(){
return
this
.
fridgeItem
.
amount
.
quantity
;
}
},
isExpired
(){
let
date
=
this
.
fridgeItem
.
exp_date
;
const
epDate
=
new
Date
(
date
);
const
parsedDate
=
Date
.
parse
(
epDate
)
const
today
=
new
Date
();
const
ms
=
parsedDate
-
today
;
const
numOfDays
=
Math
.
ceil
(
ms
/
(
86400000
))
return
numOfDays
<
1
;
},
}
}
</
script
>
<
style
scoped
lang=
"scss"
>
#popup
{
background-color
:
base
.
$white
;
...
...
@@ -119,13 +141,13 @@ export default {
}
button
{
qpadding
:
.2em
2
.4em
;
margin
:
.1em
;
font-weight
:
bolder
;
width
:
40%
;
padding
:
1em
;
background-color
:
base
.
$red
;
color
:white
;
border
:none
;
}
button
:hover
,
#eatenBtn
:hover
{
...
...
@@ -134,4 +156,16 @@ button:hover, #eatenBtn:hover {
#eatenBtn
{
background-color
:
base
.
$green
;
}
#itemHasExpiredMessage
{
border
:
3px
dashed
base
.
$red
;
padding
:
1em
;
}
#itemHasExpiredMessage
button
{
padding
:
1em
;
width
:
100%
;
border
:none
;
border-radius
:
5px
;
}
</
style
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/util/API.js
+
1
−
1
View file @
40b47b86
...
...
@@ -205,7 +205,7 @@ export const API = {
/**
* Changes the expiration date of an ingredient.
* @param request ingredientId
, newExpDate (Tip: )
* @param request ingredientId
: id of the ingredient, newExpDate: the new expiration date of the ingredient
* @returns {Promise<void>}
*/
changeExpirationOfIngredient
:
async
(
request
)
=>
{
...
...
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