newsletter recipients

This commit is contained in:
Julian Krauser 2024-12-27 13:25:37 +01:00
parent ec477b7d72
commit 81b7f533c7
6 changed files with 81 additions and 17 deletions

View file

@ -2,7 +2,6 @@ import { defineStore } from "pinia";
import { http } from "@/serverCom";
import type { TableMeta } from "@/viewmodels/admin/query.models";
import type { DynamicQueryStructure, FieldType } from "@/types/dynamicQueries";
import { flattenQueryResult } from "@/helpers/queryFormatter";
export const useQueryBuilderStore = defineStore("queryBuilder", {
state: () => {
@ -31,23 +30,21 @@ export const useQueryBuilderStore = defineStore("queryBuilder", {
this.loading = "failed";
});
},
sendQuery(offset = 0, count = 25) {
sendQuery(offset = 0, count = 25, query?: DynamicQueryStructure | string) {
this.queryError = "";
this.data = [];
this.totalLength = 0;
if (this.query == undefined || this.query == "" || (typeof this.query != "string" && this.query.table == ""))
let queryToSend = query ?? this.query;
if (queryToSend == undefined || queryToSend == "" || (typeof queryToSend != "string" && queryToSend.table == ""))
return;
this.loadingData = "loading";
http
.post(`/admin/querybuilder/query?offset=${offset}&count=${count}`, {
query: this.query,
query: queryToSend,
})
.then((result) => {
if (result.data.stats == "success") {
this.data = flattenQueryResult(result.data.rows).map((row) => ({
id: row.id ?? "", // Ensure id is present
...row,
}));
this.data = result.data.rows;
this.totalLength = result.data.total;
this.loadingData = "fetched";
} else {