Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
idatt2106_2024_02_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 - Gruppe 2
idatt2106_2024_02_frontend
Commits
ceb12723
Commit
ceb12723
authored
11 months ago
by
Eline Evje
Browse files
Options
Downloads
Patches
Plain Diff
chore: ran format
parent
25b3304b
No related branches found
No related tags found
3 merge requests
!66
Final merge
,
!47
Feat/implement genereated challenges modal
,
!4
Pipeline fix
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/ButtonAddGoalOrChallenge.vue
+6
-7
6 additions, 7 deletions
src/components/ButtonAddGoalOrChallenge.vue
src/components/GeneratedChallengesModal.vue
+54
-35
54 additions, 35 deletions
src/components/GeneratedChallengesModal.vue
src/views/HomeView.vue
+9
-9
9 additions, 9 deletions
src/views/HomeView.vue
with
69 additions
and
51 deletions
src/components/ButtonAddGoalOrChallenge.vue
+
6
−
7
View file @
ceb12723
...
...
@@ -29,9 +29,9 @@ const props = defineProps({
buttonText
:
String
,
type
:
String
,
showModal
:
Boolean
})
;
})
const
emit
=
defineEmits
([
'
update:showModal
'
])
;
const
emit
=
defineEmits
([
'
update:showModal
'
])
const
router
=
useRouter
()
...
...
@@ -39,12 +39,11 @@ const btnText = ref(props.buttonText)
const
routeToGoalOrChallenge
=
()
=>
{
if
(
props
.
type
===
'
goal
'
)
{
router
.
push
(
'
/sparemaal
'
)
;
router
.
push
(
'
/sparemaal
'
)
}
else
if
(
props
.
type
===
'
challenge
'
)
{
router
.
push
(
'
/spareutfordringer
'
)
;
router
.
push
(
'
/spareutfordringer
'
)
}
else
if
(
props
.
type
===
'
generatedChallenge
'
)
{
emit
(
'
update:showModal
'
,
true
)
;
emit
(
'
update:showModal
'
,
true
)
}
};
}
</
script
>
This diff is collapsed.
Click to expand it.
src/components/GeneratedChallengesModal.vue
+
54
−
35
View file @
ceb12723
...
...
@@ -25,9 +25,16 @@
Personlig tilpassede spareutfordringer:
</div>
<div
class=
"grid grid-cols-7 sm:grid-cols-11 gap-2 p-3 pb-1 border-b-2"
>
<span
class=
"font-bold col-span-2 md:col-span-3 sm:text-lg pt-1 mb-0"
>
Tittel
</span>
<span
class=
"font-bold col-span-2 md:col-span-2 sm:text-lg pt-1 mb-0"
>
Målsum
</span>
<span
class=
"font-bold col-span-2 md:col-span-1 sm:text-lg pt-1 pr-1 md:pr-3 mb-0"
>
Frist
</span>
<span
class=
"font-bold col-span-2 md:col-span-3 sm:text-lg pt-1 mb-0"
>
Tittel
</span
>
<span
class=
"font-bold col-span-2 md:col-span-2 sm:text-lg pt-1 mb-0"
>
Målsum
</span
>
<span
class=
"font-bold col-span-2 md:col-span-1 sm:text-lg pt-1 pr-1 md:pr-3 mb-0"
>
Frist
</span
>
<span
class=
"col-span-2"
></span>
</div>
<div
class=
"space-y-2"
>
...
...
@@ -37,13 +44,21 @@
:class=
"
{ 'bg-gray-100': index % 2 === 0 }"
class="grid grid-cols-7 md:grid-cols-7 sm:grid-cols-2 lg:grid-cols-7 gap-4 items-center border p-3 rounded mt-[-8px]"
>
<span
class=
"break-words col-span-2 md:col-span-1 lg:col-span-2 text-lg"
>
{{
challenge
.
title
}}
</span>
<span
class=
"col-span-2 md:col-span-2 lg:col-span-1 text-lg"
>
{{
challenge
.
target
}}
</span>
<span
class=
"col-span-2 md:col-span-1 lg:col-span-2 text-lg"
>
{{
challenge
.
due
}}
</span>
<span
class=
"break-words col-span-2 md:col-span-1 lg:col-span-2 text-lg"
>
{{
challenge
.
title
}}
</span>
<span
class=
"col-span-2 md:col-span-2 lg:col-span-1 text-lg"
>
{{
challenge
.
target
}}
</span>
<span
class=
"col-span-2 md:col-span-1 lg:col-span-2 text-lg"
>
{{
challenge
.
due
}}
</span>
<div
class=
"col-span-7 sm:col-start-3 sm:col-span-2 md:col-span-2 lg:col-span-2 flex items-center justify-end space-x-2"
>
<span
v-if=
"challenge.isAccepted"
class=
"font-bold text-lg"
>
Godtatt!
</span>
<span
v-if=
"challenge.isAccepted"
class=
"font-bold text-lg"
>
Godtatt!
</span
>
<button
@
click=
"acceptChallenge(challenge)"
class=
"text-white font-bold py-1 px-4 mt-[-14px] sm:mt-0"
...
...
@@ -61,43 +76,46 @@
</div>
</
template
>
<
script
setup
>
import
{
ref
,
reactive
,
onMounted
}
from
'
vue
'
import
authInterceptor
from
'
@/services/authInterceptor
'
const
showModal
=
ref
(
true
)
;
const
generatedChallenges
=
reactive
([])
;
const
showModal
=
ref
(
true
)
const
generatedChallenges
=
reactive
([])
async
function
fetchGeneratedChallenges
()
{
try
{
const
response
=
await
authInterceptor
.
get
(
'
/challenges/generate
'
)
;
const
response
=
await
authInterceptor
.
get
(
'
/challenges/generate
'
)
if
(
response
.
status
===
200
)
{
generatedChallenges
.
splice
(
0
,
generatedChallenges
.
length
,
...
response
.
data
.
map
(
ch
=>
({
...
ch
,
due
:
new
Date
(
ch
.
due
).
toISOString
().
split
(
'
T
'
)[
0
],
dueFull
:
ch
.
due
,
accepted
:
false
})));
console
.
log
(
'
Generated challenges:
'
,
generatedChallenges
);
generatedChallenges
.
splice
(
0
,
generatedChallenges
.
length
,
...
response
.
data
.
map
((
ch
)
=>
({
...
ch
,
due
:
new
Date
(
ch
.
due
).
toISOString
().
split
(
'
T
'
)[
0
],
dueFull
:
ch
.
due
,
accepted
:
false
}))
)
console
.
log
(
'
Generated challenges:
'
,
generatedChallenges
)
}
else
{
console
.
log
(
'
No challenges found for the user.
'
)
;
generatedChallenges
.
splice
(
0
,
generatedChallenges
.
length
)
;
console
.
log
(
'
No challenges found for the user.
'
)
generatedChallenges
.
splice
(
0
,
generatedChallenges
.
length
)
}
}
catch
(
error
)
{
console
.
error
(
'
Error fetching challenges:
'
,
error
)
;
console
.
error
(
'
Error fetching challenges:
'
,
error
)
}
}
onMounted
(()
=>
{
fetchGeneratedChallenges
()
;
localStorage
.
setItem
(
'
lastModalShow
'
,
Date
.
now
().
toString
())
;
})
;
fetchGeneratedChallenges
()
localStorage
.
setItem
(
'
lastModalShow
'
,
Date
.
now
().
toString
())
})
function
acceptChallenge
(
challenge
)
{
if
(
!
challenge
)
{
console
.
error
(
'
No challenge data provided to acceptChallenge function.
'
)
;
return
;
console
.
error
(
'
No challenge data provided to acceptChallenge function.
'
)
return
}
const
postData
=
{
title
:
challenge
.
title
,
...
...
@@ -107,18 +125,19 @@ function acceptChallenge(challenge) {
description
:
challenge
.
description
,
due
:
challenge
.
dueFull
,
type
:
challenge
.
type
};
authInterceptor
.
post
(
'
/challenges
'
,
postData
)
.
then
(
response
=>
{
console
.
log
(
'
Challenge accepted and saved:
'
,
response
.
data
);
challenge
.
isAccepted
=
true
;
}
authInterceptor
.
post
(
'
/challenges
'
,
postData
)
.
then
((
response
)
=>
{
console
.
log
(
'
Challenge accepted and saved:
'
,
response
.
data
)
challenge
.
isAccepted
=
true
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Failed to save challenge:
'
,
error
)
})
.
catch
(
error
=>
{
console
.
error
(
'
Failed to save challenge:
'
,
error
);
});
}
const
closeModal
=
()
=>
{
showModal
.
value
=
false
;
showModal
.
value
=
false
}
</
script
>
This diff is collapsed.
Click to expand it.
src/views/HomeView.vue
+
9
−
9
View file @
ceb12723
...
...
@@ -49,18 +49,18 @@ const goals = ref<Goal[]>([])
const
goal
=
ref
<
Goal
|
null
|
undefined
>
(
null
)
onMounted
(
async
()
=>
{
await
goalStore
.
getUserGoals
()
;
await
challengeStore
.
getUserChallenges
()
;
challenges
.
value
=
challengeStore
.
challenges
;
goals
.
value
=
goalStore
.
goals
;
goal
.
value
=
goals
.
value
[
0
]
;
console
.
log
(
'
Goals:
'
,
goals
.
value
)
;
await
goalStore
.
getUserGoals
()
await
challengeStore
.
getUserChallenges
()
challenges
.
value
=
challengeStore
.
challenges
goals
.
value
=
goalStore
.
goals
goal
.
value
=
goals
.
value
[
0
]
console
.
log
(
'
Goals:
'
,
goals
.
value
)
const
lastModalShow
=
localStorage
.
getItem
(
'
lastModalShow
'
)
;
const
lastModalShow
=
localStorage
.
getItem
(
'
lastModalShow
'
)
if
(
!
lastModalShow
||
Date
.
now
()
-
Number
(
lastModalShow
)
>=
24
*
60
*
60
*
1000
)
{
showModal
.
value
=
true
;
showModal
.
value
=
true
}
})
;
})
// Define your speech array
const
speechArray
=
[
...
...
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