0
0
Fork 0

Merge pull request 'fix(TicketSaleMoreActions): hotFix isClaimable' (!1055) from hotFix_ticketSale_isClaimable into master

Reviewed-on: verdnatura/salix-front#1055
Reviewed-by: Carlos Satorres <carlossa@verdnatura.es>
This commit is contained in:
Alex Moreno 2024-12-09 07:00:59 +00:00
commit 8a1812dbb0
2 changed files with 7 additions and 5 deletions

View File

@ -20,7 +20,7 @@ export function useRole() {
function hasAny(roles) {
const roleStore = state.getRoles();
if (typeof roles === 'string') roles = [roles];
for (const role of roles) {
if (roleStore.value.indexOf(role) !== -1) return true;
}

View File

@ -11,7 +11,7 @@ import VnInput from 'src/components/common/VnInput.vue';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios';
import { toDateFormat } from 'src/filters/date';
import { useRole } from 'src/composables/useRole';
import { useAcl } from 'src/composables/useAcl';
import { useVnConfirm } from 'composables/useVnConfirm';
const emit = defineEmits(['updateDiscounts', 'getMana', 'refreshTable']);
@ -48,7 +48,7 @@ const { push } = useRouter();
const { t } = useI18n();
const { dialog } = useQuasar();
const { notify } = useNotify();
const role = useRole();
const acl = useAcl();
const btnDropdownRef = ref(null);
const { openConfirmationModal } = useVnConfirm();
@ -58,8 +58,10 @@ const isClaimable = computed(() => {
if (ticket.value) {
const landedPlusWeek = new Date(ticket.value.landed);
landedPlusWeek.setDate(landedPlusWeek.getDate() + 7);
const hasClaimManagerRole = role.hasAny('claimManager');
return landedPlusWeek >= Date.vnNew() || hasClaimManagerRole;
const createAfterDeadline = acl.hasAny([
{ model: 'Claim', props: 'createAfterDeadline', accessType: 'WRITE' },
]);
return landedPlusWeek >= Date.vnNew() || createAfterDeadline;
}
return false;
});