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

chore: Update main from develop #471

Merged
merged 16 commits into from
Dec 18, 2024
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
9 changes: 1 addition & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
app: [ dashboard, point-of-sale, point-of-sale-ab]
app: [ dashboard, point-of-sale ]
include:
- app: dashboard
env_file_main: ${{ vars.ENV_FILE_PRODUCTION }}
Expand All @@ -30,13 +30,6 @@ jobs:
docker_tag: ${{ vars.DOCKER_TAG_POS }}
dockerfile_path: "apps/point-of-sale/Dockerfile"
dir: "point-of-sale"
- app: point-of-sale-ab
env_file_main: ${{ vars.ENV_FILE_PRODUCTION }}
env_file_develop: ${{ vars.ENV_FILE_PRODUCTION }}
docker_tag: ${{ vars.DOCKER_TAG_POS }}-ab
dockerfile_path: "apps/point-of-sale/Dockerfile"
dir: "point-of-sale"

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"format": "prettier --write src/"
},
"dependencies": {
"@stripe/stripe-js": "^4.8.0",
"@stripe/stripe-js": "^5.2.0",
"@sudosos/sudosos-frontend-common": "workspace:^",
"@vee-validate/rules": "^4.14.1",
"@vee-validate/yup": "^4.14.1",
"marked": "^11.2.0",
"marked": "^15.0.1",
"vee-validate": "^4.14.1",
"vue-i18n": "^9.14.1",
"vue3-pdf-app": "^1.0.3",
Expand Down
56 changes: 48 additions & 8 deletions apps/dashboard/src/components/FindUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
class="w-full md:w-15rem"
@filter="filterUsers"
>
<template #option="slotProps">
{{ slotProps.option.fullName }} {{ slotProps.option.gewisId ? `(${slotProps.option.gewisId})` : '' }}
<template #option="slotProps" >
<span :class="{'text-gray-500': !isNegative(slotProps.option)}">
{{ slotProps.option.fullName }} {{ slotProps.option.gewisId ? `(${slotProps.option.gewisId})` : '' }}
</span>
</template>
</Dropdown>
</template>
Expand All @@ -23,13 +25,18 @@ import type { Ref } from "vue";
import apiService from "@/services/ApiService";
import { debounce } from "lodash";
import { type BaseUserResponse, GetAllUsersTypeEnum, type UserResponse } from "@sudosos/sudosos-client";
import { useUserStore } from "@sudosos/sudosos-frontend-common";

const emits = defineEmits(['update:value']);
const emits = defineEmits(['update:user']);

const props = defineProps({
value: {
user: {
type: Object as PropType<UserResponse>,
},
default: {
type: Object as PropType<BaseUserResponse>,
required: false,
},
placeholder: {
type: String,
required: false,
Expand All @@ -44,20 +51,42 @@ const props = defineProps({
type: Number,
required: false,
default: 10,
},
showPositive: {
type: Boolean,
required: false,
default: true
}
});

const lastQuery = ref("");
const selectedUser = ref(null);
const selectedUser: Ref<BaseUserResponse | undefined> = ref(undefined);
const userStore = useUserStore();

const loading = ref(false);
const users: Ref<(BaseUserResponse & { fullName: string })[]> = ref([]);

const transformUsers = (userData: BaseUserResponse[]) => {
return userData.map((user: BaseUserResponse) => ({
const usersData: (BaseUserResponse & { fullName: string})[]
= userData.map((user) => ({
...user,
fullName: `${user.firstName} ${user.lastName}`
}));

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

if (isANegative && !isBNegative) {
return -1;
}
if (!isANegative && isBNegative) {
return 1;
}
return a.fullName.localeCompare(b.fullName);
});

return usersData;
};

const debouncedSearch = debounce((e: any) => {
Expand All @@ -77,15 +106,26 @@ const filterUsers = (e: any) => {
}
};

function isNegative(user: BaseUserResponse) {
return userStore.getBalanceById(user.id).amount.amount < 0;
}

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

watch(selectedUser, () => {
emits('update:value', selectedUser.value);
emits('update:user', selectedUser.value);
});

</script>

<style scoped lang="scss">
Expand Down
9 changes: 7 additions & 2 deletions apps/dashboard/src/components/FormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@
<slot name="form" :form="form" />
<div class="flex flex-row gap-2 justify-content-between w-full mt-3">
<Button
v-if="deletable"
v-if="isEditable && deletable"
type="button"
icon="pi pi-trash"
:label="deleteLabel || t('common.delete')"
outlined
@click="emits('delete')"/>
<div class="flex flex-row justify-content-end gap-2 flex-1">
<Button
v-if="isEditable"
type="button"
outlined
icon="pi pi-times"
:label="t('common.close')"
@click="visible = false; emits('close')"
/>
<Button
v-if="isEditable"
type="submit"
icon="pi pi-check"
:disabled="!props.form.context.meta.value.valid"
Expand Down Expand Up @@ -59,6 +61,10 @@ const props = defineProps({
required: false,
default: '',
},
isEditable: {
type: Boolean,
required: true
},
deletable: {
type: Boolean,
required: false,
Expand All @@ -70,7 +76,6 @@ const props = defineProps({
}
});


const emits = defineEmits(['update:modelValue', 'show', 'close', 'delete']);

const dialog = ref();
Expand Down
16 changes: 14 additions & 2 deletions apps/dashboard/src/components/InputUserSpan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
column ? 'flex-column gap-1' : 'flex-row align-items-center gap-3']">
<span class="my-0">{{ label }}</span>
<FindUser :placeholder="placeholder"
v-model="internalValue"
v-model:user="internalValue"
:disabled="disabled"
:type="type"/>
:type="type"
:showPositive="props.showPositive"
:default="props.default"
/>
</span>
<div class="flex justify-content-end">
<ErrorSpan :error="errors"/>
Expand All @@ -27,6 +30,10 @@ const props = defineProps({
type: String,
required: true
},
default: {
type: Object as PropType<BaseUserResponse>,
required: false,
},
value: {
type: Object as PropType<BaseUserResponse>,
},
Expand All @@ -53,6 +60,11 @@ const props = defineProps({
type: String as PropType<GetAllUsersTypeEnum>,
required: false,
default: undefined
},
showPositive: {
type: Boolean,
required: false,
default: true
}
});

Expand Down
67 changes: 34 additions & 33 deletions apps/dashboard/src/components/TopNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@
import { computed, onBeforeMount, ref, type Ref } from "vue";
import { useAuthStore, useUserStore } from "@sudosos/sudosos-frontend-common";
import { useRouter } from "vue-router";
import { UserRole } from "@/utils/rbacUtils";
import { useI18n } from "vue-i18n";
import { usePendingPayouts } from "@/mixins/pendingPayoutsMixin";
import apiService from "@/services/ApiService";
import { GetAllUsersTypeEnum } from "@sudosos/sudosos-client";

import { useOpenInvoiceAccounts } from "@/mixins/openInvoiceAccountsMixin";
import { isAllowed } from "@/utils/permissionUtils";
const userStore = useUserStore();
const authStore = useAuthStore();
const router = useRouter();
Expand All @@ -100,20 +101,11 @@ const handleLogout = () => {
router.push('/');
};

const isBoard = () => {
return userStore.current.rolesWithPermissions.findIndex(r => r.name == UserRole.BOARD) != -1;
};

const isSeller = () => {
return userStore.current.rolesWithPermissions.findIndex(r => r.name == UserRole.SELLER) != -1;
};
const { pendingPayouts } = usePendingPayouts();

const isBACPM = () => {
return userStore.current.rolesWithPermissions.findIndex(r => r.name == UserRole.BAC_PM) != -1;
};
const { openInvoiceAccounts } = useOpenInvoiceAccounts();
const getFinancialNotifications = () => isAllowed('update', ['all'], 'SellerPayout', ['any']) && pendingPayouts?.value + openInvoiceAccounts?.value;

const { pendingPayouts } = usePendingPayouts();
const getFinancialNotifications = () => pendingPayouts?.value;

const organs: Ref<any[]> = ref([]);

Expand Down Expand Up @@ -160,63 +152,72 @@ onBeforeMount(async () => {
const navItems = computed(() => [
{
label: t('common.navigation.transactions'),
route: '/transactions'
route: '/transaction'
},
{
label: t('common.navigation.admin'),
visible: isBoard(),
visible: isAllowed('update', ['all'], 'User', ['any'])
|| isAllowed('get', ['all'], 'Banner', ['any']),
items: [
{
label: t('common.navigation.userOverview'),
route: '/user-overview'
label: t('common.navigation.users'),
route: '/user',
visible: isAllowed('update', ['all'], 'User', ['any']),
},
{
label: t('common.navigation.banners'),
route: '/banners'
route: '/banner',
visible: isAllowed('get', ['own'], 'Banner', ['any']),
},
],
},
{
label: t('common.navigation.financial'),
visible: isBACPM(),
notifications: getFinancialNotifications(),
visible: isAllowed('update', ['all'], 'User', ['any'])
|| isAllowed('get', ['all'], 'Invoice', ['any'])
|| isAllowed('get', ['all'], 'Fine', ['any'])
|| isAllowed('get', ['all'], 'SellerPayout', ['any']),
items: [
{
label: t('common.navigation.userOverview'),
route: '/user-overview',
},
{
label: t('common.navigation.flaggedTransactions'),
},
{
label: t('common.navigation.socialDrinkCards'),
label: t('common.navigation.users'),
route: '/user',
// TODO: Change to `action: get` after https://github.com/GEWIS/sudosos-backend/issues/62 is fully finished
visible: isAllowed('update', ['all'], 'User', ['any']),
},
{
label: t('common.navigation.invoices'),
route: '/invoice',
notifications: openInvoiceAccounts?.value,
visible: isAllowed('get', ['all'], 'Invoice', ['any'])
},
{
label: t('common.navigation.fineOverview'),
route: '/fine',
visible: isAllowed('get', ['all'], 'Fine', ['any']),
},
{
label: t('common.navigation.payouts'),
route: '/payouts',
route: '/payout',
visible: isAllowed('get', ['all'], 'SellerPayout', ['any']),
notifications: pendingPayouts?.value
}
]
},
{
label: t('common.navigation.seller'),
visible: isSeller(),
items: [
{
label: t('common.navigation.manageProducts'),
route: '/manage-products',
label: t('common.navigation.productsContainers'),
route: '/product',
// TODO: Change to `action: get` after https://github.com/GEWIS/sudosos-backend/issues/62 is fully finished
visible: isAllowed('get', ['own', 'organ'], 'Product', ['any']),
},
{
label: t('common.navigation.posOverview'),
route: '/point-of-sale/overview',
label: t('common.navigation.pos'),
route: '/point-of-sale',
// TODO: Change to `action: get` after https://github.com/GEWIS/sudosos-backend/issues/62 is fully finished
visible: isAllowed('update', ['own', 'organ'], 'PointOfSale', ['any']),
},
...organs.value,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
@close="closeDialog()"
@delete="deleteProduct()"
:deletable="state.edit"
:is-editable="state.edit || state.create"
>
<template #form>
<ContainerActionsForm
:is-editable="state.edit || state.create"
:is-organ-editable="state.create"
:form="form"/>
<ConfirmDialog group="containerDelete"/>
Expand Down Expand Up @@ -44,6 +46,10 @@ const props = defineProps({
associatedPos: {
type: Object as PropType<PointOfSaleWithContainersResponse>,
required: false
},
isEditAllowed: {
type: Boolean,
required: false
}
});

Expand All @@ -56,13 +62,13 @@ const toast = useToast();
const state = computed(() => {
return {
create: props.container == undefined,
edit: props.container != undefined,
edit: props.container != undefined && props.isEditAllowed
};
});
const header = computed(() => {
if (state.value.create) return t('modules.seller.productContainers.containers.create');
if (state.value.edit) return t('modules.seller.productContainers.containers.edit');
return '';
return t('modules.seller.productContainers.containers.view');
});

const form = schemaToForm(containerActionSchema);
Expand Down
Loading
Loading