Skip to content

Commit

Permalink
fix: Remove the SortOrderContracts enum and used the SortOrder import…
Browse files Browse the repository at this point in the history
…ed from the nodes file.
  • Loading branch information
Mahmoud-Emad committed Jul 29, 2024
1 parent 75c8645 commit a3be963
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
10 changes: 3 additions & 7 deletions packages/gridproxy_client/src/builders/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assertBoolean, assertId, assertIn, assertNatural, assertString } from "../utils";
import { AbstractBuilder, BuilderMapper, BuilderMethods, BuilderValidator } from "./abstract_builder";
import { SortOrder } from "./nodes";

export enum ContractType {
Node = "node",
Expand All @@ -21,11 +22,6 @@ export enum SortByContracts {
State = "state",
}

export enum SortOrderContracts {
DESC = "desc",
ASC = "asc",
}

export interface ContractsQuery {
page: number;
size: number;
Expand All @@ -40,7 +36,7 @@ export interface ContractsQuery {
deploymentHash: string;
numberOfPublicIps: number;
sortBy: SortByContracts;
sortOrder: SortOrderContracts;
sortOrder: SortOrder;
}

const CONTRACTS_MAPPER: BuilderMapper<ContractsQuery> = {
Expand Down Expand Up @@ -90,7 +86,7 @@ const CONTRACTS_VALIDATOR: BuilderValidator<ContractsQuery> = {
},
sortOrder(value) {
assertString(value);
assertIn(value, Object.values(SortOrderContracts));
assertIn(value, Object.values(SortOrder));
},
};

Expand Down
10 changes: 2 additions & 8 deletions packages/playground/src/weblets/tf_contracts_list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,7 @@

<script lang="ts" setup>
import type { GridClient, LockContracts } from "@threefold/grid_client";
import {
type Contract,
ContractState,
NodeStatus,
SortByContracts,
SortOrderContracts,
} from "@threefold/gridproxy_client";
import { type Contract, ContractState, NodeStatus, SortByContracts, SortOrder } from "@threefold/gridproxy_client";
import { Decimal } from "decimal.js";
import { computed, defineComponent, onMounted, type Ref, ref } from "vue";
Expand Down Expand Up @@ -305,7 +299,7 @@ async function loadContractsByType(
type: contractType,
retCount: true,
sortBy: options && options.sort.length ? (options?.sort[0].key as SortByContracts) : undefined,
sortOrder: options && options.sort.length ? (options?.sort[0].order as SortOrderContracts) : undefined,
sortOrder: options && options.sort.length ? (options?.sort[0].order as SortOrder) : undefined,
});
table.count.value = response.count ?? 0;
Expand Down

0 comments on commit a3be963

Please sign in to comment.