Skip to content

Commit

Permalink
first successful transaction complete
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen-Gordon committed Mar 14, 2024
1 parent 1d117a4 commit 216d1e5
Show file tree
Hide file tree
Showing 15 changed files with 420 additions and 200 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ yarn-error.log*
CHANGELOG.md

pnpm-lock.yaml

/src/app/@auth/(.)confirm/page.tsx
110 changes: 101 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@pushprotocol/restapi": "^1.6.8",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/themes": "^2.0.3",
"@reduxjs/toolkit": "^2.1.0",
Expand Down
17 changes: 17 additions & 0 deletions src/GlobalRedux/Features/pendingTx/pendingTxSlice.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use client';

import { createSlice } from '@reduxjs/toolkit';

export const pendingTxSlice = createSlice({
name: 'pendingTx',
initialState: {
value: {},
},
reducers: {
setPendingTxSlice: (state, action) => {
state.value = action.payload;
},
},
});
export const { setPendingTxSlice } = pendingTxSlice.actions;
export default pendingTxSlice.reducer;
7 changes: 6 additions & 1 deletion src/GlobalRedux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import kernalClientSliceReducer from './Features/kernalClient/kernalClientSlice'
import transactionsSliceReducer from './Features/transactions/transactionsSlice';
import sheetSliceReducer from './Features/sheet/sheetSlice';
import balanceSliceReducer from './Features/balance/balanceSlice';

import pendingTxSliceReducer from './Features/pendingTx/pendingTxSlice';
// Define RootState type
export type RootState = {
login: {
Expand All @@ -33,6 +33,10 @@ export type RootState = {
value: {};
}
];
pendingTx : {
value: {};

}
};

const persistConfig = {
Expand All @@ -49,6 +53,7 @@ const rootReducer = combineReducers<any>({
transactions: transactionsSliceReducer,
sheet: sheetSliceReducer,
balance: balanceSliceReducer,
pendingTx: pendingTxSliceReducer,
});

const persistedReducer = persistReducer(persistConfig, rootReducer);
Expand Down
16 changes: 15 additions & 1 deletion src/app/@auth/(.)confirm/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,34 @@ import { Avatar } from '@/app/components/ui/avatar';
// link
import Link from 'next/link';
import useSendUsdc from '@/app/hooks/useSendUsdc';
import Success from '@/app/components/Success/Success';
import { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { setPendingTxSlice } from '@/GlobalRedux/Features/pendingTx/pendingTxSlice';
interface ConfirmProps {
showConfirm: boolean;
}

export default function Page({ showConfirm }: ConfirmProps) {
const router = useRouter();

const dispatch = useDispatch();

// get search params
const searchParams = useSearchParams();
let payee = searchParams.get('payee');
let amount = searchParams.get('amount');
const { sendUsdc, transactionStatus, loading, transactionHash } =
useSendUsdc();



const handleSend = () => {
if (!payee || !amount) return;
console.log('calling hook');
sendUsdc(amount, payee);

};

return (
<>
<DrawerHeader>
Expand Down Expand Up @@ -89,6 +97,12 @@ export default function Page({ showConfirm }: ConfirmProps) {
{truncateEthAddress(payee)}
</div>
</div>
{ loading == true || transactionStatus == true ? (<>
<Success transactionStatus={transactionStatus} loading={loading} transactionHash={transactionHash}/>
</>) : (
<></>
)}

<DrawerFooter>
<Button
onClick={handleSend}
Expand Down
10 changes: 7 additions & 3 deletions src/app/@auth/(.)payee/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface Transaction {
}

export default function Page() {
// get search params
const searchParams = useSearchParams();
let payeeAddress = searchParams.get('payeeAddress');

Expand All @@ -57,6 +58,7 @@ export default function Page() {
const [transactions, setTransactions] = useState<Transaction[]>([]);
const [groupedTransactions, setGroupedTransactions] = useState<any[]>([]);

// refs
const end = useRef<any>(null);

// effect
Expand Down Expand Up @@ -108,6 +110,8 @@ export default function Page() {
fetchRecentTransactions();
}, [payeeAddress]);

useEffect(() => {}, []);

return (
<>
<DrawerHeader>
Expand Down Expand Up @@ -138,7 +142,7 @@ export default function Page() {
</div>
)}

{groupedTransactions && (
{/* {groupedTransactions && (
<>
<div className='overflow-auto p-4'>
{groupedTransactions.map((month, i) => (
Expand Down Expand Up @@ -183,7 +187,7 @@ export default function Page() {
</div>
<div className='overflow-auto p-4'>
{/* End Ref */}
<div ref={end}></div>
</div>
Expand All @@ -210,7 +214,7 @@ export default function Page() {
</div>
</DrawerFooter>
</>
)}
)} */}
</>
);
}
Loading

0 comments on commit 216d1e5

Please sign in to comment.