Skip to content

Commit

Permalink
feat(SPV-1046): Fixed actions edit dialog (#1031)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazarii-4chain authored Sep 20, 2024
1 parent 1e04eca commit c7e7b9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
20 changes: 12 additions & 8 deletions src/components/TransactionEditDialog/TransactionEditDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
import { Metadata, Tx } from '@bsv/spv-wallet-js-client';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { Row } from '@tanstack/react-table';
import React, { useState } from 'react';

import { toast } from 'sonner';

import {
Button,
Dialog,
Expand All @@ -19,6 +12,12 @@ import {

import { useSpvWalletClient } from '@/contexts';
import { errorWrapper } from '@/utils';
import { Metadata, Tx } from '@bsv/spv-wallet-js-client';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { Row } from '@tanstack/react-table';
import React, { useState } from 'react';

import { toast } from 'sonner';

export interface TransactionEditDialogProps {
row: Row<Tx>;
Expand All @@ -42,18 +41,23 @@ export const TransactionEditDialog = ({ row }: TransactionEditDialogProps) => {
return await spvWalletClient!.UpdateTransactionMetadata(row.original.id, metadata);
},
onSuccess: () => {
toast.success('Transaction edited');

return queryClient.invalidateQueries({
queryKey: ['transactions'],
});
},
onError: (error) => {
errorWrapper(error);
toast.error('Failed to edit transaction');
},
});

const handleEdit = async () => {
try {
const metadataParsed = JSON.parse(metadata) as Metadata;
mutation.mutate(metadataParsed);

toast.success('Transaction edited');
setMetadata(JSON.stringify({}));
setIsEditDialogOpen(false);
} catch (err) {
Expand Down
1 change: 0 additions & 1 deletion src/routes/admin/_admin.transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export function Transactions() {
<TransactionsTabContent
transactions={transactions}
hasRecordTransaction={hasRecordTransaction}
hasTransactionEditDialog
TxDialog={RecordTxDialogAdmin}
/>
</TabsContent>
Expand Down

0 comments on commit c7e7b9d

Please sign in to comment.