-
{{ entry.mission?.name || 'Unknown Mission'}} {{ index }}
+
{{ entry.mission?.name || 'Unknown Mission'}}
{{ entry.mission?.category }}
{{ entry.completed_at }}
@@ -114,7 +114,7 @@ export default{
const filteredHistory = computed(() => {
if (selectedCategory.value === "Semua") return pointHistory.value;
return pointHistory.value.filter(
- e => e.category.toLowerCase() === selectedCategory.value.toLowerCase()
+ e => e.mission?.category.toLowerCase() === selectedCategory.value.toLowerCase()
);
});
diff --git a/src/pages/Wordspells.vue b/src/pages/Wordspells.vue
index 5a407d1..5e10999 100644
--- a/src/pages/Wordspells.vue
+++ b/src/pages/Wordspells.vue
@@ -10,10 +10,10 @@
Kembali
- Entertainment
+
Temukan Kata
@@ -255,9 +255,9 @@
initGame();
}
- function goEntertainment(){
- window.history.back('/entertainment');
- }
+ // function goEntertainment(){
+ // window.history.back('/entertainment');
+ // }
function goBack(){
window.history.back('/entertainment/mini-games');
diff --git a/src/services/missions.js b/src/services/missions.js
index 1a63a00..4e00f2b 100644
--- a/src/services/missions.js
+++ b/src/services/missions.js
@@ -27,7 +27,6 @@ export const getMissionLogs = async () => {
export const createMissionLog = async (data = {}) => {
const timestp = new Date().toISOString();
- console.log(data);
return await api.post('mission/mission-logs',{
mission: data.mission,
user_id: data.user_id,
@@ -52,7 +51,9 @@ export const getUserPoint = async() =>{
const user = auth.user
const [missions, missionLogs] = await Promise.all([getMissions(), getMissionLogs()]);
const userLogs = missionLogs.results.filter((mlog) => mlog.user_id === user.id);
+ const activeTask = missions.results.filter((mission) => mission.date_time_from_valid <= timestp && timestp <= mission.date_time_to_valid);
+ console.log("active missions:" + activeTask.length)
const combine = userLogs.map(
log => {
const missionDetail = missions.allMissions.find((mission) => mission.id === log.mission);
@@ -63,16 +64,23 @@ export const getUserPoint = async() =>{
}
}
);
-
+ // all points
+ const timestp = new Date().toISOString();
const myPoints = combine.reduce((total, log) => total + log.point, 0);
- const activeMissions = missions.activeMissions || [];
- const taskCount = activeMissions.length;
+ const mytaskActiveComplete = combine.filter((c) =>{
+ const inRange = c.mission.date_time_from_valid <= timestp && timestp <= c.date_time_to_valid
+ return inRange && c.status === 'completed'
+ });
return {
- task: activeMissions,
- taskCount: taskCount,
+ task: missions, // all missions
+ taskCount: missions.allMissions.length, // count all
+ activeTask: activeTask, // task active ()
+ activeTaskCount: activeTask.length, // count active
myTask: combine,
myTaskCount: combine.length,
- myPoints,
+ myActiveTaskComplete: mytaskActiveComplete,// active mission
+ myActiveTaskCompleteCount: mytaskActiveComplete.length,
+ myPoints : myPoints,
};
}
\ No newline at end of file