fix: refactoring errors (#359)

* #352 - require one date to be set to save

* fix many type regressions
This commit is contained in:
Hayden 2023-03-20 21:48:22 -08:00 committed by GitHub
parent 4a8ba6231d
commit 97fb94d231
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 164 additions and 289 deletions

View file

@ -15,12 +15,10 @@
</template>
<script setup lang="ts">
const api = useUserApi();
function getQRCodeUrl(): string {
const currentURL = window.location.href;
return `/api/v1/qrcode?data=${encodeURIComponent(currentURL)}&access_token=${api.items.attachmentToken}`;
return `/api/v1/qrcode?data=${encodeURIComponent(currentURL)}`;
}
</script>

View file

@ -14,6 +14,10 @@ export function flatTree(tree: TreeItem[]): Ref<FlatTreeItem[]> {
// the display is a string of the tree hierarchy separated by breadcrumbs
function flatten(items: TreeItem[], display: string) {
if (!items) {
return;
}
for (const item of items) {
v.value.push({
id: item.id,
@ -40,5 +44,5 @@ export async function useFlatLocations(): Promise<Ref<FlatTreeItem[]>> {
return ref([]);
}
return flatTree(locations.data.items);
return flatTree(locations.data);
}

View file

@ -1,10 +1,9 @@
import { BaseAPI, route } from "../base";
import { LabelCreate, LabelOut } from "../types/data-contracts";
import { Results } from "../types/non-generated";
export class LabelsApi extends BaseAPI {
getAll() {
return this.http.get<Results<LabelOut>>({ url: route("/labels") });
return this.http.get<LabelOut[]>({ url: route("/labels") });
}
create(body: LabelCreate) {

View file

@ -1,6 +1,5 @@
import { BaseAPI, route } from "../base";
import { LocationOutCount, LocationCreate, LocationOut, LocationUpdate, TreeItem } from "../types/data-contracts";
import { Results } from "../types/non-generated";
export type LocationsQuery = {
filterChildren: boolean;
@ -12,11 +11,11 @@ export type TreeQuery = {
export class LocationsApi extends BaseAPI {
getAll(q: LocationsQuery = { filterChildren: false }) {
return this.http.get<Results<LocationOutCount>>({ url: route("/locations", q) });
return this.http.get<LocationOutCount[]>({ url: route("/locations", q) });
}
getTree(tq = { withItems: false }) {
return this.http.get<Results<TreeItem>>({ url: route("/locations/tree", tq) });
return this.http.get<TreeItem[]>({ url: route("/locations/tree", tq) });
}
create(body: LocationCreate) {

View file

@ -57,10 +57,7 @@ export interface ItemAttachmentUpdate {
}
export interface ItemCreate {
/**
* @minLength 1
* @maxLength 1000
*/
/** @maxLength 1000 */
description: string;
labelIds: string[];
/** Edges */

View file

@ -10,10 +10,6 @@ export type Result<T> = {
item: T;
};
export type Results<T> = {
items: T[];
};
export interface PaginationResult<T> {
items: T[];
page: number;

View file

@ -20,7 +20,7 @@
return [];
}
return data.items;
return data;
});
const locationTreeId = "locationTree";

View file

@ -19,7 +19,7 @@ export const useLabelStore = defineStore("labels", {
console.error(result.error);
}
this.allLabels = result.data.items;
this.allLabels = result.data;
});
}
return state.allLabels ?? [];
@ -32,7 +32,7 @@ export const useLabelStore = defineStore("labels", {
return result;
}
this.allLabels = result.data.items;
this.allLabels = result.data;
return result;
},
},

View file

@ -22,7 +22,7 @@ export const useLocationStore = defineStore("locations", {
return;
}
this.parents = result.data.items;
this.parents = result.data;
});
}
return state.parents ?? [];
@ -35,7 +35,7 @@ export const useLocationStore = defineStore("locations", {
return;
}
this.Locations = result.data.items;
this.Locations = result.data;
});
}
return state.Locations ?? [];
@ -48,7 +48,7 @@ export const useLocationStore = defineStore("locations", {
return result;
}
this.parents = result.data.items;
this.parents = result.data;
return result;
},
async refreshChildren(): ReturnType<LocationsApi["getAll"]> {
@ -57,7 +57,7 @@ export const useLocationStore = defineStore("locations", {
return result;
}
this.Locations = result.data.items;
this.Locations = result.data;
return result;
},
},