Skip to content
Snippets Groups Projects
Commit 9e2c929c authored by Eline Evje's avatar Eline Evje
Browse files

chore: ran format

parent 2ca26ec1
No related branches found
No related tags found
3 merge requests!66Final merge,!44Configuration validation,!4Pipeline fix
Pipeline #281061 failed
......@@ -39,9 +39,9 @@
:class="{ 'bg-gray-100': index % 2 === 0 }"
class="grid grid-cols-7 gap-4 items-center border p-3 rounded"
>
<span class="break-words col-span-2 font-bold">{{ challenge.title }}</span>
<span class="col-span-1 font-bold">{{ challenge.target }}</span>
<span class="col-span-2 font-bold">{{ challenge.due }}</span>
<span class="break-words col-span-2 font-bold">{{ challenge.title }}</span>
<span class="col-span-1 font-bold">{{ challenge.target }}</span>
<span class="col-span-2 font-bold">{{ challenge.due }}</span>
<div class="flex items-center justify-end space-x-2 col-span-2">
<button
@click="declineChallenge(challenge.id)"
......@@ -51,7 +51,7 @@
</button>
<button
@click="acceptChallenge(challenge.id)"
class=" text-white font-bold py-1 px-4"
class="text-white font-bold py-1 px-4"
>
Godta
</button>
......
import { ref } from 'vue';
import { defineStore } from 'pinia';
import authInterceptor from '@/services/authInterceptor';
import { AxiosError } from 'axios';
import { ref } from 'vue'
import { defineStore } from 'pinia'
import authInterceptor from '@/services/authInterceptor'
import { AxiosError } from 'axios'
export const useUserConfigStore = defineStore('userConfig', () => {
const role = ref('USER');
const experience = ref('');
const motivation = ref('');
const challengeTypeConfigs = ref([] as {
type: string;
specificAmount: number;
generalAmount: number;
}[]);
const role = ref('USER')
const experience = ref('')
const motivation = ref('')
const challengeTypeConfigs = ref(
[] as {
type: string
specificAmount: number
generalAmount: number
}[]
)
const accounts = ref({
savings: '',
spending: ''
});
const errorMessage = ref<string>('');
})
const errorMessage = ref<string>('')
const setExperience = (value: string) => {
experience.value = value;
};
experience.value = value
}
const setMotivation = (value: string) => {
motivation.value = value;
};
motivation.value = value
}
const addChallengeTypeConfig = (type: string, specificAmount: number, generalAmount: number) => {
challengeTypeConfigs.value.push({ type, specificAmount, generalAmount });
};
const addChallengeTypeConfig = (
type: string,
specificAmount: number,
generalAmount: number
) => {
challengeTypeConfigs.value.push({ type, specificAmount, generalAmount })
}
const postAccount = async (accountType: 'SAVING' | 'SPENDING', accNumber: string, balance: number) => {
const postAccount = async (
accountType: 'SAVING' | 'SPENDING',
accNumber: string,
balance: number
) => {
const payload = {
accountType,
accNumber,
balance
};
await authInterceptor.post('/accounts', payload)
.then(response => {
console.log('Success:', response.data);
}
await authInterceptor
.post('/accounts', payload)
.then((response) => {
console.log('Success:', response.data)
})
.catch(error => {
const axiosError = error as AxiosError;
errorMessage.value = (axiosError.response?.data as string) || 'An error occurred while posting account'
console.error('Error posting account:', errorMessage.value);
});
};
.catch((error) => {
const axiosError = error as AxiosError
errorMessage.value =
(axiosError.response?.data as string) ||
'An error occurred while posting account'
console.error('Error posting account:', errorMessage.value)
})
}
const postUserConfig = () => {
const payload = {
experience: experience.value,
motivation: motivation.value,
challengeTypeConfigs: Array.from(challengeTypeConfigs.value)
};
authInterceptor.post('/config/challenge', payload)
.then(response => {
console.log('Success:', response.data);
}
authInterceptor
.post('/config/challenge', payload)
.then((response) => {
console.log('Success:', response.data)
})
.catch((error) => {
const axiosError = error as AxiosError
errorMessage.value =
(axiosError.response?.data as string) ||
'An error occurred while updating configuration'
console.error('Error updating configuration:', errorMessage.value)
})
.catch(error => {
const axiosError = error as AxiosError;
errorMessage.value = (axiosError.response?.data as string) || 'An error occurred while updating configuration'
console.error('Error updating configuration:', errorMessage.value);
});
};
}
return {
role,
......@@ -76,5 +92,5 @@ export const useUserConfigStore = defineStore('userConfig', () => {
addChallengeTypeConfig,
postAccount,
postUserConfig
};
});
}
})
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