-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added several endpoints and actions to the costs sheet
- Loading branch information
Felix Ruf
committed
Aug 10, 2023
1 parent
2d9ec1b
commit f137333
Showing
14 changed files
with
273 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { IMessage } from "@/interfaces/IMessage"; | ||
import useApi from "./api"; | ||
|
||
export default async function postHideUser(username: string) { | ||
const { error, request, response } = useApi<IMessage | null>( | ||
'POST', | ||
`api/costs/hideuser/${username}` | ||
); | ||
|
||
await request(); | ||
|
||
return { error, response }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import useApi from '@/api/api'; | ||
import { IMessage } from '@/interfaces/IMessage'; | ||
|
||
export default async function postSettlement(username: string) { | ||
const { error, request, response } = useApi<IMessage | number>( | ||
'POST', | ||
`api/costs/settlement/${username}` | ||
); | ||
|
||
await request(); | ||
|
||
return { error, response }; | ||
} |
55 changes: 55 additions & 0 deletions
55
src/Resources/src/components/costs/CostsActionSettlement.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<template> | ||
<Dialog | ||
:open="open" | ||
:initial-focus="initialFocus" | ||
class="relative z-50" | ||
@close="emit('confirm', false)" | ||
> | ||
<div | ||
class="fixed inset-0 flex items-center justify-center p-4" | ||
> | ||
<DialogPanel | ||
class="relative overflow-hidden rounded-lg bg-white p-4 text-left shadow-xl sm:my-8 sm:p-6" | ||
> | ||
<DialogTitle class="text-[18px]"> | ||
{{ t('costs.settlement').replace('#name#', getFullNameByUser(username)) }} | ||
</DialogTitle> | ||
<div class="flex flex-row"> | ||
<CreateButton | ||
ref="initialFocus" | ||
:managed="true" | ||
:btn-text="t('costs.settle')" | ||
class="flex-1 cursor-pointer" | ||
@click="emit('confirm', true)" | ||
/> | ||
<CancelButton | ||
:btn-text="t('costs.cancel')" | ||
class="flex-1 cursor-pointer" | ||
@click="emit('confirm', false)" | ||
/> | ||
</div> | ||
</DialogPanel> | ||
</div> | ||
</Dialog> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Dialog, DialogPanel, DialogTitle } from '@headlessui/vue'; | ||
import { useI18n } from 'vue-i18n'; | ||
import { useCosts } from '@/stores/costsStore'; | ||
import CancelButton from '../misc/CancelButton.vue'; | ||
import CreateButton from '@/components/misc/CreateButton.vue'; | ||
import { ref } from 'vue'; | ||
const { t } = useI18n(); | ||
const { getFullNameByUser } = useCosts(); | ||
defineProps<{ | ||
open: boolean, | ||
username: string | ||
}>(); | ||
const emit = defineEmits(['confirm']); | ||
const initialFocus = ref<HTMLElement | null>(null); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<template> | ||
<div class="ml-auto grid h-full w-fit grid-cols-3 justify-end gap-2"> | ||
<ActionButton | ||
:action="Action.HIDE" | ||
:btn-text="''" | ||
@click="hideUser(username)" | ||
/> | ||
<ActionButton | ||
:action="Action.CREATE" | ||
:btn-text="''" | ||
/> | ||
<ActionButton | ||
v-if="balance > 0" | ||
:action="Action.BALANCE" | ||
:btn-text="''" | ||
@click="settlementOpen = true" | ||
/> | ||
</div> | ||
<CostsActionSettlement | ||
:open="settlementOpen" | ||
:username="username" | ||
@confirm="(value) => handleSettlement(value)" | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import ActionButton from '../misc/ActionButton.vue'; | ||
import { Action } from '@/enums/Actions'; | ||
import { useCosts } from '@/stores/costsStore'; | ||
import CostsActionSettlement from './CostsActionSettlement.vue'; | ||
import { ref } from 'vue'; | ||
const { hideUser, sendSettlement } = useCosts(); | ||
const settlementOpen = ref(false); | ||
const props = defineProps<{ | ||
username: string, | ||
balance: number | ||
}>(); | ||
async function handleSettlement(confirm: boolean) { | ||
settlementOpen.value = false; | ||
if (confirm === true) { | ||
await sendSettlement(props.username); | ||
} | ||
} | ||
</script> |
Oops, something went wrong.