Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Fix some farms filters #529

Merged
merged 2 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/explorer/graphql/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ export interface IFetchPaginatedData<T> {
items: T[];
}

export const getPricingPolicies = gql`
query getPricingPolicies {
pricingPolicies {
pricingPolicyID
}
}
`;

export const getFarmsQuery = gql`
query getFarms(
$limit: Int!
Expand Down
7 changes: 1 addition & 6 deletions src/explorer/utils/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ export function inputValidation(value: string, key: string): string {
"free_mru",
"free_sru",
"free_hru",
];
const textualFields: string[] = [
"farmingPolicyName",
"certificationType",
"farmName",
"farm_name",
"pricingPolicyId",
];
const textualFields: string[] = ["farmingPolicyName", "certificationType", "farmName", "farm_name"];

const countryFields: string[] = ["countryFullName", "country"];
const specialChars = /[ `!@#$%^&*()+\-=[\]{};':"\\|,.<>/?~]/;
Expand Down
15 changes: 10 additions & 5 deletions src/explorer/views/Farms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
import DetailsV2 from "../components/DetailsV2.vue";
import { getFarmsQuery, IFarm, IFetchPaginatedData } from "../graphql/api";
import { getFarmsQuery, getPricingPolicies, IFarm, IFetchPaginatedData } from "../graphql/api";
import Layout from "../components/Layout.vue";
import { IPaginationData } from "../store/state";
import { PAGE_LIMIT } from "../json/constants";
Expand Down Expand Up @@ -182,6 +182,14 @@ export default class Farms extends Vue {
.finally(() => {
this.loading = false;
});
this.$apollo
.query({
query: getPricingPolicies,
})
.then(({ data }) => {
const ids = data.pricingPolicies.map((policy: any) => policy.pricingPolicyID);
this.$store.state.explorer.pricingPoliciesIds = ids;
});
}
public getKeyByValue(value: string): number | null {
const map = this._pricingPolicy;
Expand Down Expand Up @@ -269,15 +277,12 @@ export default class Farms extends Vue {
multiple: false,
symbol: "certificationType_in",
key: "certificationType",
getValue: f => {
return +f.value;
},
},
{
component: InFilterV2,
chip_label: "Pricing Policy",
label: "Filter By Pricing policy",
items: _ => Promise.resolve([...this._pricingPolicy.values()]),
items: _ => Promise.resolve(this.$store.state.explorer.pricingPoliciesIds),
value: [],
init: true,
multiple: true,
Expand Down