Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main from develop #504

Merged
merged 4 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions apps/dashboard/src/components/FindUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@filter="filterUsers"
>
<template #option="slotProps" >
<span :class="{'text-gray-500': !isNegative(slotProps.option)}">
<span :class="{'text-gray-500': isNegative(slotProps.option) === true}">
{{ slotProps.option.fullName }} {{ slotProps.option.gewisId ? `(${slotProps.option.gewisId})` : '' }}
</span>
</template>
Expand Down Expand Up @@ -66,6 +66,19 @@ const userStore = useUserStore();
const loading = ref(false);
const users: Ref<(BaseUserResponse & { fullName: string })[]> = ref([]);

const compareBalance = (a: BaseUserResponse, b: BaseUserResponse) => {
const isANegative = isNegative(a);
const isBNegative = isNegative(b);

if (isANegative && !isBNegative) {
return -1;
}
if (!isANegative && isBNegative) {
return 1;
}
return 0;
};

const transformUsers = (userData: BaseUserResponse[]) => {
const usersData: (BaseUserResponse & { fullName: string})[]
= userData.map((user) => ({
Expand All @@ -74,18 +87,12 @@ const transformUsers = (userData: BaseUserResponse[]) => {
}));

usersData.sort((a, b) => {
const isANegative = isNegative(a);
const isBNegative = isNegative(b);

if (isANegative && !isBNegative) {
return -1;
}
if (!isANegative && isBNegative) {
return 1;
if (!props.showPositive) {
const res = compareBalance(a, b);
if (res !== 0) return res;
}
return a.fullName.localeCompare(b.fullName);
});

return usersData;
};

Expand All @@ -107,18 +114,27 @@ const filterUsers = (e: any) => {
};

function isNegative(user: BaseUserResponse) {
return userStore.getBalanceById(user.id).amount.amount < 0;
const balance = userStore.getBalanceById(user.id);
if (!balance) return undefined;
else return balance.amount.amount < 0;
}

onMounted(async () => {
apiService.user.getAllUsers(props.take, 0, undefined, undefined, undefined, undefined, props.type).then((res) => {
userStore.addUsers(res.data.records);
userStore.fetchUserBalances(res.data.records, apiService).then(() => {
users.value = transformUsers(res.data.records);
});
let selected = undefined;
if (props.default) {
selectedUser.value = transformUsers([props.default])[0];
selected = transformUsers([props.default])[0];
}
userStore.fetchUserBalances(res.data.records, apiService).then(() => {
const transformed = transformUsers(res.data.records);
if (selected) {
users.value = [...transformed, selected];
selectedUser.value = selected;
} else {
users.value = transformed;
}
});
});
});

Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/locales/en/modules/financial.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"title": "Payout overview",
"create": "Create payout",
"requestedBy": "Requested by",
"details": "Payout details",
"approvedBy": "Approved by",
"details": "Payout details #{payoutId}",
"approvedBy": "Approved by {approvedBy}",
"approve": "Approve",
"deny": "Deny"
},
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/locales/nl/modules/financial.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"title": "Uitbetalingsoverzicht",
"create": "Uitbetaling aanmaken",
"requestedBy": "Aangevraagd door",
"details": "Uitbetalingsdetails",
"approvedBy": "Goedgekeurd door",
"details": "Uitbetalingsdetails #{payoutId}",
"approvedBy": "Goedgekeurd door {approvedBy}",
"approve": "Goedkeuren",
"deny": "Afwijzen"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
<div class="flex flex-column">
<span>{{ t('common.createdAt') + ': ' }}{{ formatDateFromString(payout.createdAt) }}</span>
<span>{{ t('common.updatedAt') + ': ' }}{{ formatDateFromString(payout.updatedAt) }}</span>
<span>{{ t('common.id') + ': ' }}{{ payout.id }}</span>
</div>
</div>
<div v-if="isApproved && payout.approvedBy" class="mt-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
v-model:visible="showModal"
:draggable="false"
class="w-auto flex w-9 md:w-4"
:header="t('modules.financial.payout.details')">
:header="t('modules.financial.payout.details', { payoutId })">
<PayoutInfo :payoutId="payoutId" @close="showModal = false"/>
</Dialog>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:value="form.model.user.value.value"
@update:value="form.context.setFieldValue('user', $event)"
:errors="form.context.errors.value.user"
:show-positive="true"
id="name" placeholder="John Doe"/>

<!-- TODO think about turning this into a component? -->
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/styles/primevue-base/_colors.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@use "sass:meta";
@use "sass:list";
@use "../themes/sudosos-light/variables_light";
@use "mixins";

:root {
@if meta.variable-exists(colors) {
@if list.length(variables_light.$colors) > 0 {
@each $name, $color in variables_light.$colors {
@for $i from 0 through 5 {
@if ($i == 0) {
Expand Down
Loading