Skip to content

Commit e44bd7c

Browse files
committed
refactor: update GraphQL types and improve type safety across components
1 parent 4479562 commit e44bd7c

File tree

24 files changed

+69
-43
lines changed

24 files changed

+69
-43
lines changed

src/components/DataTable.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface DataTableProps<TData, TValue> {
2121
isLoading?: boolean;
2222
}
2323

24-
export function DataTable<TData extends { destination: string }, TValue>({
24+
export function DataTable<TData, TValue>({
2525
columns,
2626
data,
2727
tableLength = 10,
@@ -59,7 +59,9 @@ export function DataTable<TData extends { destination: string }, TValue>({
5959
{row.getVisibleCells().map((cell) => (
6060
<TableCell key={cell.id}>
6161
<ChainLink
62-
to={cell.row.original.destination}
62+
to={
63+
(cell.row.original as { destination: string }).destination
64+
}
6365
className="w-full"
6466
>
6567
{flexRender(cell.column.columnDef.cell, cell.getContext())}

src/components/navbar/NavBar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Link } from '@tanstack/react-router';
21
import { LogOut } from 'lucide-react';
32
import { useState } from 'react';
43
import { useLoginLogout } from '@/hooks/useLoginLogout';

src/graphql/gql.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Documents = {
2727
"\n query AddressRequestedTasks(\n $length: Int = 20\n $skip: Int = 0\n $address: ID!\n ) {\n account(id: $address) {\n address: id\n taskRequester(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n taskid: id\n timestamp\n status\n finalDeadline\n deal {\n dealid: id\n app {\n address: id\n name\n }\n dataset {\n address: id\n name\n }\n workerpool {\n address: id\n description\n }\n }\n }\n }\n }\n": typeof types.AddressRequestedTasksDocument,
2828
"\n query NextAddressRequestedTasks(\n $length: Int = 20\n $skip: Int = 0\n $address: ID!\n ) {\n account(id: $address) {\n address: id\n taskRequester(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n taskid: id\n }\n }\n }\n": typeof types.NextAddressRequestedTasksDocument,
2929
"\n query AddressWorkerpools($length: Int = 20, $skip: Int = 0, $address: ID!) {\n account(id: $address) {\n address: id\n # workerpools\n workerpools(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n address: id\n description\n timestamp\n transfers(orderBy: timestamp, orderDirection: desc) {\n transaction {\n txHash: id\n }\n }\n }\n }\n }\n": typeof types.AddressWorkerpoolsDocument,
30-
"\n query NextAddressWorkerpools($length: Int = 20, $skip: Int = 0, $address: ID!) {\n account(id: $address) {\n address: id\n # workerpools\n workerpools(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n address: id\n }\n }\n }\n": typeof types.NextAddressWorkerpoolsDocument,
30+
"\n query NextAddressWorkerpools(\n $length: Int = 20\n $skip: Int = 0\n $address: ID!\n ) {\n account(id: $address) {\n address: id\n # workerpools\n workerpools(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n address: id\n }\n }\n }\n": typeof types.NextAddressWorkerpoolsDocument,
3131
"\n query AddressContribution($length: Int = 20, $skip: Int = 0, $address: ID!) {\n account(id: $address) {\n address: id\n # worker contributions\n contributions(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n id\n timestamp\n task {\n taskid: id\n }\n status\n }\n }\n }\n": typeof types.AddressContributionDocument,
3232
"\n query NextAddressContribution(\n $length: Int = 20\n $skip: Int = 0\n $address: ID!\n ) {\n account(id: $address) {\n address: id\n # worker contributions\n contributions(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n id\n }\n }\n }\n": typeof types.NextAddressContributionDocument,
3333
"\n query AppDeals($length: Int = 20, $skip: Int = 0, $appAddress: ID!) {\n app(id: $appAddress) {\n address: id\n deals: usages(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n dealid: id\n timestamp\n requester {\n address: id\n }\n beneficiary {\n address: id\n }\n callback {\n address: id\n }\n app {\n address: id\n name\n }\n dataset {\n address: id\n name\n }\n workerpool {\n address: id\n description\n }\n category {\n catid: id\n workClockTimeRef\n }\n startTime\n appPrice\n datasetPrice\n workerpoolPrice\n botSize\n trust\n completedTasksCount\n claimedTasksCount\n }\n }\n }\n": typeof types.AppDealsDocument,
@@ -68,7 +68,7 @@ const documents: Documents = {
6868
"\n query AddressRequestedTasks(\n $length: Int = 20\n $skip: Int = 0\n $address: ID!\n ) {\n account(id: $address) {\n address: id\n taskRequester(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n taskid: id\n timestamp\n status\n finalDeadline\n deal {\n dealid: id\n app {\n address: id\n name\n }\n dataset {\n address: id\n name\n }\n workerpool {\n address: id\n description\n }\n }\n }\n }\n }\n": types.AddressRequestedTasksDocument,
6969
"\n query NextAddressRequestedTasks(\n $length: Int = 20\n $skip: Int = 0\n $address: ID!\n ) {\n account(id: $address) {\n address: id\n taskRequester(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n taskid: id\n }\n }\n }\n": types.NextAddressRequestedTasksDocument,
7070
"\n query AddressWorkerpools($length: Int = 20, $skip: Int = 0, $address: ID!) {\n account(id: $address) {\n address: id\n # workerpools\n workerpools(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n address: id\n description\n timestamp\n transfers(orderBy: timestamp, orderDirection: desc) {\n transaction {\n txHash: id\n }\n }\n }\n }\n }\n": types.AddressWorkerpoolsDocument,
71-
"\n query NextAddressWorkerpools($length: Int = 20, $skip: Int = 0, $address: ID!) {\n account(id: $address) {\n address: id\n # workerpools\n workerpools(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n address: id\n }\n }\n }\n": types.NextAddressWorkerpoolsDocument,
71+
"\n query NextAddressWorkerpools(\n $length: Int = 20\n $skip: Int = 0\n $address: ID!\n ) {\n account(id: $address) {\n address: id\n # workerpools\n workerpools(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n address: id\n }\n }\n }\n": types.NextAddressWorkerpoolsDocument,
7272
"\n query AddressContribution($length: Int = 20, $skip: Int = 0, $address: ID!) {\n account(id: $address) {\n address: id\n # worker contributions\n contributions(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n id\n timestamp\n task {\n taskid: id\n }\n status\n }\n }\n }\n": types.AddressContributionDocument,
7373
"\n query NextAddressContribution(\n $length: Int = 20\n $skip: Int = 0\n $address: ID!\n ) {\n account(id: $address) {\n address: id\n # worker contributions\n contributions(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n id\n }\n }\n }\n": types.NextAddressContributionDocument,
7474
"\n query AppDeals($length: Int = 20, $skip: Int = 0, $appAddress: ID!) {\n app(id: $appAddress) {\n address: id\n deals: usages(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n dealid: id\n timestamp\n requester {\n address: id\n }\n beneficiary {\n address: id\n }\n callback {\n address: id\n }\n app {\n address: id\n name\n }\n dataset {\n address: id\n name\n }\n workerpool {\n address: id\n description\n }\n category {\n catid: id\n workClockTimeRef\n }\n startTime\n appPrice\n datasetPrice\n workerpoolPrice\n botSize\n trust\n completedTasksCount\n claimedTasksCount\n }\n }\n }\n": types.AppDealsDocument,
@@ -148,7 +148,7 @@ export function graphql(source: "\n query AddressWorkerpools($length: Int = 20,
148148
/**
149149
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
150150
*/
151-
export function graphql(source: "\n query NextAddressWorkerpools($length: Int = 20, $skip: Int = 0, $address: ID!) {\n account(id: $address) {\n address: id\n # workerpools\n workerpools(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n address: id\n }\n }\n }\n"): typeof import('./graphql').NextAddressWorkerpoolsDocument;
151+
export function graphql(source: "\n query NextAddressWorkerpools(\n $length: Int = 20\n $skip: Int = 0\n $address: ID!\n ) {\n account(id: $address) {\n address: id\n # workerpools\n workerpools(\n orderBy: timestamp\n orderDirection: desc\n first: $length\n skip: $skip\n ) {\n address: id\n }\n }\n }\n"): typeof import('./graphql').NextAddressWorkerpoolsDocument;
152152
/**
153153
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
154154
*/

src/modules/apps/app/buildAppDetails.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { App } from '@/graphql/graphql';
1+
import { AppQuery } from '@/graphql/graphql';
22
import CopyButton from '@/components/CopyButton';
33
import SmartLinkGroup from '@/components/SmartLinkGroup';
44
import TransferEvent from '@/modules/events/TransferEvent';
@@ -8,7 +8,10 @@ import {
88
formatElapsedTime,
99
} from '@/utils/formatElapsedTime';
1010

11-
export function buildAppDetails({ app }: { app: App }) {
11+
export function buildAppDetails({ app }: { app: AppQuery['app'] }) {
12+
if (!app) {
13+
return {};
14+
}
1215
const firstTransfer = Array.isArray(app?.transfers) && app?.transfers[0];
1316
const firstTimestamp = firstTransfer?.transaction?.timestamp;
1417

src/modules/apps/appsTable/columns.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const columns: ColumnDef<App>[] = [
1111
accessorKey: 'address',
1212
header: 'Address',
1313
cell: ({ row }) => {
14-
const appAddress = row.getValue('address');
14+
const appAddress = row.original.address;
1515
return (
1616
<CopyButton
1717
displayText={truncateAddress(appAddress, {
@@ -26,7 +26,7 @@ export const columns: ColumnDef<App>[] = [
2626
accessorKey: 'name',
2727
header: 'Name',
2828
cell: ({ row }) => {
29-
const name = row.getValue('name');
29+
const name = row.original.name;
3030
return (
3131
<div className="w-36">
3232
<CopyButton displayText={name} textToCopy={name} />

src/modules/datasets/dataset/DatasetDealsTable.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { DETAIL_TABLE_LENGTH, TABLE_REFETCH_INTERVAL } from '@/config';
22
import { execute } from '@/graphql/execute';
33
import { useQuery } from '@tanstack/react-query';
4-
import { LoaderCircle, Terminal } from 'lucide-react';
4+
import { LoaderCircle } from 'lucide-react';
55
import { useState } from 'react';
66
import { DataTable } from '@/components/DataTable';
77
import { PaginatedNavigation } from '@/components/PaginatedNavigation';
8-
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
98
import { ErrorAlert } from '@/modules/ErrorAlert';
109
import { columns } from '@/modules/deals/dealsTable/columns';
1110
import useUserStore from '@/stores/useUser.store';

src/modules/datasets/dataset/buildDatasetDetails.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dataset } from '@/graphql/graphql';
1+
import { DatasetQuery } from '@/graphql/graphql';
22
import CopyButton from '@/components/CopyButton';
33
import SmartLinkGroup from '@/components/SmartLinkGroup';
44
import TransferEvent from '@/modules/events/TransferEvent';
@@ -8,7 +8,14 @@ import {
88
formatElapsedTime,
99
} from '@/utils/formatElapsedTime';
1010

11-
export function buildDatasetDetails({ dataset }: { dataset: Dataset }) {
11+
export function buildDatasetDetails({
12+
dataset,
13+
}: {
14+
dataset: DatasetQuery['dataset'];
15+
}) {
16+
if (!dataset) {
17+
return {};
18+
}
1219
const firstTransfer =
1320
Array.isArray(dataset?.transfers) && dataset?.transfers[0];
1421
const firstTimestamp = firstTransfer?.transaction?.timestamp;

src/modules/deals/SuccessCell.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export function SuccessCell({ deal }: { deal: any }) {
1+
import { Deal } from '@/graphql/graphql';
2+
3+
export function SuccessCell({ deal }: { deal: Deal }) {
24
const timeoutTimestamp =
35
deal?.startTime &&
46
deal?.category?.workClockTimeRef &&

src/modules/deals/deal/buildDealDetails.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Deal } from '@/graphql/graphql';
1+
import { DealQuery } from '@/graphql/graphql';
22
import CopyButton from '@/components/CopyButton';
33
import SmartLinkGroup from '@/components/SmartLinkGroup';
44
import Bytes from '@/modules/Bytes';
@@ -15,9 +15,12 @@ export function buildDealDetails({
1515
deal,
1616
isConnected,
1717
}: {
18-
deal: Deal;
18+
deal: DealQuery['deal'];
1919
isConnected: boolean;
2020
}) {
21+
if (!deal) {
22+
return {};
23+
}
2124
const dealDeadline =
2225
deal?.startTime &&
2326
deal?.category.workClockTimeRef &&
@@ -159,7 +162,7 @@ export function buildDealDetails({
159162
<>
160163
CLAIMABLE
161164
<ClaimButton
162-
task={deal.tasks}
165+
tasks={deal.tasks}
163166
className="text-white underline"
164167
/>
165168
</>

src/modules/deals/dealsTable/columns.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const columns: ColumnDef<Deal>[] = [
1212
accessorKey: 'dealid',
1313
header: 'Deal',
1414
cell: ({ row }) => {
15-
const dealAddress = row.getValue('dealid');
15+
const dealAddress = row.original.dealid;
1616
return (
1717
<CopyButton
1818
displayText={truncateAddress(dealAddress, {

0 commit comments

Comments
 (0)