Skip to content
Snippets Groups Projects
Commit 8a151c8c authored by Henrik Teksle Sandok's avatar Henrik Teksle Sandok
Browse files

Merge branch 'feat/regenerate_challenge' into 'main'

Feat/regenerate challenge

See merge request !92
parents 4374ea5d 10ee11be
No related branches found
No related tags found
1 merge request!92Feat/regenerate challenge
Pipeline #284212 passed with warnings
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
/* eslint-disable */ /* eslint-disable */
export type ChallengeTemplateDTO = { export type ChallengeTemplateDTO = {
id?: number; id?: number;
templateName?: string;
text?: string; text?: string;
amount?: number; amount?: number;
type?: ChallengeTemplateDTO.type; type?: ChallengeTemplateDTO.type;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* istanbul ignore file */ /* istanbul ignore file */
/* tslint:disable */ /* tslint:disable */
/* eslint-disable */ /* eslint-disable */
import type { ChallengeDTO } from '../models/ChallengeDTO';
import type { CreateGoalDTO } from '../models/CreateGoalDTO'; import type { CreateGoalDTO } from '../models/CreateGoalDTO';
import type { GoalDTO } from '../models/GoalDTO'; import type { GoalDTO } from '../models/GoalDTO';
import type { MarkChallengeDTO } from '../models/MarkChallengeDTO'; import type { MarkChallengeDTO } from '../models/MarkChallengeDTO';
...@@ -78,6 +79,23 @@ export class GoalService { ...@@ -78,6 +79,23 @@ export class GoalService {
mediaType: 'application/json', mediaType: 'application/json',
}); });
} }
/**
* @returns ChallengeDTO OK
* @throws ApiError
*/
public static regenerateChallenge({
id,
}: {
id: number,
}): CancelablePromise<ChallengeDTO> {
return __request(OpenAPI, {
method: 'PATCH',
url: '/api/goals/challenge/{id}',
path: {
'id': id,
},
});
}
/** /**
* @returns GoalDTO OK * @returns GoalDTO OK
* @throws ApiError * @throws ApiError
......
...@@ -60,6 +60,15 @@ export default { ...@@ -60,6 +60,15 @@ export default {
this.savingGoalClicked = true; this.savingGoalClicked = true;
this.keyForList++ this.keyForList++
}, 100); }, 100);
},
async refreshSpareSti() {
try {
this.selectedGoal = await GoalService.getGoal({id: this.selectedGoal.id as number})
console.log("yessir")
this.key++;
} catch (error) {
console.log(error)
}
} }
}, },
}; };
...@@ -82,7 +91,7 @@ export default { ...@@ -82,7 +91,7 @@ export default {
</div> </div>
</div> </div>
<saving-goal-create @createGoalClicked="handleCreateGoalClicked" v-if="createClicked"></saving-goal-create> <saving-goal-create @createGoalClicked="handleCreateGoalClicked" v-if="createClicked"></saving-goal-create>
<saving-goal-roadmap :key="key" :selected-goal="selectedGoal" v-else-if="savingGoalClicked"></saving-goal-roadmap> <saving-goal-roadmap @refreshSavingGoal="refreshSpareSti" :key="key" :selected-goal="selectedGoal" v-else-if="savingGoalClicked"></saving-goal-roadmap>
<saving-goal-default v-else></saving-goal-default> <saving-goal-default v-else></saving-goal-default>
</div> </div>
</div> </div>
......
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
UserService UserService
} from "@/api"; } from "@/api";
import {GoalService} from '@/api' import {GoalService} from '@/api'
import {useUserInfoStore} from "@/stores/UserStore"; import handleUnknownError from '@/components/Exceptions/unkownErrorHandler'
ChartJS.register( ChartJS.register(
CategoryScale, CategoryScale,
...@@ -181,6 +181,7 @@ export default { ...@@ -181,6 +181,7 @@ export default {
await this.transferMoney(amount) await this.transferMoney(amount)
this.calculateSavedSoFar(); this.calculateSavedSoFar();
} catch (error: any) { } catch (error: any) {
handleUnknownError(error)
console.log(error.message); console.log(error.message);
} }
}, },
...@@ -306,7 +307,9 @@ export default { ...@@ -306,7 +307,9 @@ export default {
}; };
try { try {
await GoalService.updateChallengeAmount({requestBody: createGoalPayload}) await GoalService.updateChallengeAmount({requestBody: createGoalPayload})
this.$emit('refreshSavingGoal');
} catch (e: any) { } catch (e: any) {
handleUnknownError(e)
console.log(e.message) console.log(e.message)
} }
}, },
...@@ -355,6 +358,17 @@ export default { ...@@ -355,6 +358,17 @@ export default {
await TransactionControllerService.transferToSelf({requestBody: transactionPayload}) await TransactionControllerService.transferToSelf({requestBody: transactionPayload})
}, },
async regenerateChallenge(challenge: ChallengeDTO) {
let challengeId = challenge.id as number
try {
let response = await GoalService.regenerateChallenge({id: challengeId})
console.log(response)
this.$emit('refreshSavingGoal');
} catch (e) {
handleUnknownError(e)
}
},
}, },
}; };
</script> </script>
...@@ -383,8 +397,15 @@ export default { ...@@ -383,8 +397,15 @@ export default {
</div> </div>
<div class="timeline-panel z-3" :id="'panel-' + index" v-show="challenge.showPanel"> <div class="timeline-panel z-3" :id="'panel-' + index" v-show="challenge.showPanel">
<div class="timeline-heading"> <div class="timeline-heading">
<h5 style="margin-top: 12px">{{challenge.points}}<img src="../../assets/items/pigcoin.png" alt="pig coint" style="width: 2rem"></h5> <div class="coinAndRegen">
<h4>Utfordring {{ index +1 }}</h4> <div class="coinCoin">
<h5 style="margin-top: 12px">{{challenge.points}}<img src="../../assets/items/pigcoin.png" alt="pig coin" style="width: 2rem"></h5>
</div>
<div class="coinButton">
<a @click="regenerateChallenge(challenge)" style="cursor: pointer"><img src="../../assets/icons/refresh.svg"/> Regenerer</a>
</div>
</div>
<h4>{{ challenge.challengeTemplate.templateName}}</h4>
<p style="font-size: 12px">{{formatDate(challenge.startDate)}} til {{formatDate(challenge.endDate)}}</p> <p style="font-size: 12px">{{formatDate(challenge.startDate)}} til {{formatDate(challenge.endDate)}}</p>
<h4 class="subheading">{{convertTemplateTextToChallengeText(challenge)}}</h4> <h4 class="subheading">{{convertTemplateTextToChallengeText(challenge)}}</h4>
</div> </div>
...@@ -800,4 +821,28 @@ export default { ...@@ -800,4 +821,28 @@ export default {
margin-top: 10px; margin-top: 10px;
padding: 12px; padding: 12px;
} }
.timeline .coinAndRegen {
margin-top: 8px;
display: flex;
flex-direction: row-reverse;
}
.timeline-inverted .coinAndRegen {
margin-top: 8px;
display: flex;
flex-direction: row;
}
.coinCoin {
width: 40%;
}
.coinButton {
width: 60%;
color: white;
align-content: center;
align-items: center;
text-align: center;
}
</style> </style>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment