Untitled
unknown
plain_text
a year ago
3.2 kB
17
Indexable
// TransactionContext.tsx
import React, { createContext, useState, ReactNode } from "react";
export interface Transaction {
id: string;
sender: string;
receiver: string;
amount: number;
timestamp: string;
}
export const transactions: Transaction[] = [
{
id: "1",
sender: "Alice",
receiver: "Bob",
amount: 50,
timestamp: "2024-05-31T12:34:56Z",
},
{
id: "2",
sender: "Charlie",
receiver: "Dave",
amount: 75,
timestamp: "2024-05-30T09:22:45Z",
},
{
id: "3",
sender: "Eve",
receiver: "Frank",
amount: 100,
timestamp: "2024-05-29T14:12:01Z",
},
{
id: "4",
sender: "Grace",
receiver: "Heidi",
amount: 200,
timestamp: "2024-05-28T16:05:33Z",
},
{
id: "5",
sender: "Ivan",
receiver: "Judy",
amount: 150,
timestamp: "2024-05-27T11:50:22Z",
},
{
id: "6",
sender: "Mallory",
receiver: "Oscar",
amount: 250,
timestamp: "2024-05-26T13:45:56Z",
},
{
id: "7",
sender: "Peggy",
receiver: "Quentin",
amount: 300,
timestamp: "2024-05-25T15:38:29Z",
},
{
id: "8",
sender: "Rita",
receiver: "Steve",
amount: 350,
timestamp: "2024-05-24T17:22:14Z",
},
{
id: "9",
sender: "Trent",
receiver: "Uma",
amount: 400,
timestamp: "2024-05-23T19:07:42Z",
},
{
id: "10",
sender: "Victor",
receiver: "Wendy",
amount: 450,
timestamp: "2024-05-22T20:55:36Z",
},
{
id: "11",
sender: "Xander",
receiver: "Yolanda",
amount: 500,
timestamp: "2024-05-21T21:43:11Z",
},
{
id: "12",
sender: "Zara",
receiver: "Amy",
amount: 550,
timestamp: "2024-05-20T23:34:45Z",
},
{
id: "13",
sender: "Ben",
receiver: "Cara",
amount: 600,
timestamp: "2024-05-19T01:22:19Z",
},
{
id: "14",
sender: "Dan",
receiver: "Ella",
amount: 650,
timestamp: "2024-05-18T03:15:29Z",
},
{
id: "15",
sender: "Fred",
receiver: "Gina",
amount: 700,
timestamp: "2024-05-17T05:08:41Z",
},
{
id: "16",
sender: "Hank",
receiver: "Ivy",
amount: 750,
timestamp: "2024-05-16T07:01:55Z",
},
{
id: "17",
sender: "Jack",
receiver: "Kim",
amount: 800,
timestamp: "2024-05-15T09:56:12Z",
},
{
id: "18",
sender: "Liam",
receiver: "Nina",
amount: 850,
timestamp: "2024-05-14T11:49:28Z",
},
{
id: "19",
sender: "Owen",
receiver: "Paul",
amount: 900,
timestamp: "2024-05-13T13:42:36Z",
},
{
id: "20",
sender: "Quinn",
receiver: "Rose",
amount: 950,
timestamp: "2024-05-12T15:35:47Z",
},
];
interface TransactionContextValue {
transactions: Transaction[];
}
export const TransactionContext = createContext<TransactionContextValue>({
transactions: [],
});
interface TransactionProviderProps {
children: ReactNode;
}
export const TransactionProvider: React.FC<TransactionProviderProps> = ({
children,
}) => {
const [transactionsState] = useState(transactions);
return (
<TransactionContext.Provider value={{ transactions: transactionsState }}>
{children}
</TransactionContext.Provider>
);
};
Editor is loading...
Leave a Comment