Skip to content

Commit

Permalink
ensure domains provided to the requests page are used
Browse files Browse the repository at this point in the history
  • Loading branch information
keplervital committed Nov 22, 2024
1 parent c53e1bc commit c5182de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion apps/wallet/src/composables/request.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export type AvailableDomain = {
types: ListRequestsOperationType[];
};

export const useAvailableDomains = (): Ref<AvailableDomain[]> => {
export const useAvailableDomains = (
opts: { filterBy?: RequestDomains[] } = {},
): Ref<AvailableDomain[]> => {
const domains: Ref<AvailableDomain[]> = ref([]);
domains.value.push({
id: RequestDomains.All,
Expand Down Expand Up @@ -86,6 +88,11 @@ export const useAvailableDomains = (): Ref<AvailableDomain[]> => {
],
});

const filterBy = opts?.filterBy ?? [];
if (filterBy.length) {
domains.value = domains.value.filter(domain => filterBy.includes(domain.id));
}

return domains;
};

Expand Down
6 changes: 4 additions & 2 deletions apps/wallet/src/pages/RequestsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const props = withDefaults(defineProps<RequestsPageProps>(), {
const i18n = useI18n();
const pageTitle = computed(() => props.title || i18n.t('pages.requests.title'));
const station = useStationStore();
const availableDomains = useAvailableDomains();
const availableDomains = useAvailableDomains({ filterBy: props.domains });
const statuses = useRequestStatusItems();
const filterUtils = useFilterUtils();
const disableRefresh = ref(false);
Expand All @@ -200,7 +200,9 @@ const slideGroupIdIndex = ref<number>(
watch(
slideGroupIdIndex,
index => {
filters.value.groupBy = availableDomains.value[index].id ?? RequestDomains.All;
const fallbackDomain = props.domains.length ? props.domains[0] : RequestDomains.All;
filters.value.groupBy = availableDomains.value?.[index]?.id ?? fallbackDomain;
},
{ immediate: true },
);
Expand Down

0 comments on commit c5182de

Please sign in to comment.