Skip to content

Commit

Permalink
fix: route query
Browse files Browse the repository at this point in the history
Signed-off-by: Hristiyan <hristiyan.valkov@limechain.tech>
  • Loading branch information
icoxxx committed Feb 14, 2025
1 parent c496751 commit 3b9d331
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Transaction } from '@prisma/client';
import type { ITransactionFull } from '@main/shared/interfaces';
import { computed, onBeforeMount, ref, watch } from 'vue';
import { onBeforeRouteLeave, useRouter } from 'vue-router';
import { onBeforeRouteLeave, useRoute, useRouter } from 'vue-router';
import { Transaction as SDKTransaction } from '@hashgraph/sdk';
Expand Down Expand Up @@ -63,6 +63,7 @@ const nextTransaction = useNextTransactionStore();
const router = useRouter();
const ws = useDisposableWs();
useSetDynamicLayout(LOGGED_IN_LAYOUT);
const route = useRoute();
/* State */
const orgTransaction = ref<ITransactionFull | null>(null);
Expand Down Expand Up @@ -195,7 +196,11 @@ onBeforeMount(async () => {
onBeforeRouteLeave(to => {
if (to.name === 'transactionGroupDetails') {
to.query = { ...to.query, previousTab: 'transactionDetails' };
if (route.query.fromInProgress) {
to.query = { ...to.query, previousTab: 'inProgress' };
} else {
to.query = { ...to.query, previousTab: 'transactionDetails' };
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const thresholdMetTransactions = ref<Record<string, boolean>>({});
const tooltipText = computed(() => {
if (route.query.previousTab) {
const previousTab = route.query.previousTab;
//const fromTable = route.query.fromTable
if (
previousTab === 'readyToSign' ||
previousTab === 'transactionDetails' ||
Expand Down Expand Up @@ -175,7 +176,11 @@ const handleSign = async (id: number) => {
.map(t => t.transaction.id);
nextTransaction.setPreviousTransactionsIds(previousTransactionIds);
redirectToDetails(router, id, true);
if (route.query.previousTab && route.query.previousTab === 'inProgress') {
redirectToDetails(router, id, true, false, true);
} else {
redirectToDetails(router, id, true);
}
};
const handleSignGroup = async () => {
Expand Down Expand Up @@ -335,12 +340,6 @@ watchEffect(() => {
createTooltips();
}
});
watchEffect(() => {
if (route.query) {
console.log(route.query.previousTab);
}
});
</script>
<template>
<div class="p-5">
Expand Down
5 changes: 5 additions & 0 deletions front-end/src/renderer/utils/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ export const redirectToDetails = (
id: string | number,
keepNextQueryKey = false,
replace = false,
fromInProgressTab?: boolean,
) => {
const query: any = {};

if (keepNextQueryKey) {
query[KEEP_NEXT_QUERY_KEY] = 'true';
}

if (fromInProgressTab) {
query['fromInProgress'] = 'true';
}

router.push({
name: 'transactionDetails',
params: { id },
Expand Down

0 comments on commit 3b9d331

Please sign in to comment.