fix(TicketSaleMoreActions): hotFix isClaimable #1055

Merged
alexm merged 1 commits from hotFix_ticketSale_isClaimable into master 2024-12-09 07:00:59 +00:00
2 changed files with 7 additions and 5 deletions

View File

@ -20,7 +20,7 @@ export function useRole() {
function hasAny(roles) { function hasAny(roles) {
const roleStore = state.getRoles(); const roleStore = state.getRoles();
if (typeof roles === 'string') roles = [roles];
Review

Realmente fallaba por esto (solo aceptaba arrays y se le pasaba string)

Realmente fallaba por esto (solo aceptaba arrays y se le pasaba string)
for (const role of roles) { for (const role of roles) {
if (roleStore.value.indexOf(role) !== -1) return true; 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 useNotify from 'src/composables/useNotify.js';
import axios from 'axios'; import axios from 'axios';
import { toDateFormat } from 'src/filters/date'; import { toDateFormat } from 'src/filters/date';
import { useRole } from 'src/composables/useRole'; import { useAcl } from 'src/composables/useAcl';
import { useVnConfirm } from 'composables/useVnConfirm'; import { useVnConfirm } from 'composables/useVnConfirm';
const emit = defineEmits(['updateDiscounts', 'getMana', 'refreshTable']); const emit = defineEmits(['updateDiscounts', 'getMana', 'refreshTable']);
@ -48,7 +48,7 @@ const { push } = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const { dialog } = useQuasar(); const { dialog } = useQuasar();
const { notify } = useNotify(); const { notify } = useNotify();
const role = useRole(); const acl = useAcl();
const btnDropdownRef = ref(null); const btnDropdownRef = ref(null);
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
@ -58,8 +58,10 @@ const isClaimable = computed(() => {
if (ticket.value) { if (ticket.value) {
const landedPlusWeek = new Date(ticket.value.landed); const landedPlusWeek = new Date(ticket.value.landed);
landedPlusWeek.setDate(landedPlusWeek.getDate() + 7); landedPlusWeek.setDate(landedPlusWeek.getDate() + 7);
const hasClaimManagerRole = role.hasAny('claimManager'); const createAfterDeadline = acl.hasAny([
Review

Usar acl.hasAny es un mejor enfoque, que role.hasAny

Usar `acl.hasAny` es un mejor enfoque, que `role.hasAny`
return landedPlusWeek >= Date.vnNew() || hasClaimManagerRole; { model: 'Claim', props: 'createAfterDeadline', accessType: 'WRITE' },
]);
return landedPlusWeek >= Date.vnNew() || createAfterDeadline;
} }
return false; return false;
}); });