refactor(types): PSA types

move to shared types (#4774)
add types to ape client (#4786)
This commit is contained in:
Miodec 2024-02-07 19:05:47 +01:00
parent f456e1e615
commit 65120db1f0
6 changed files with 15 additions and 19 deletions

View file

@ -1,5 +1,7 @@
import * as db from "../init/db";
export async function get(): Promise<MonkeyTypes.PSA[]> {
return await db.collection<MonkeyTypes.PSA>("psa").find().toArray();
type PSA = MonkeyTypes.WithObjectId<SharedTypes.PSA>;
export async function get(): Promise<PSA[]> {
return await db.collection<PSA>("psa").find().toArray();
}

View file

@ -185,12 +185,6 @@ declare namespace MonkeyTypes {
approved: boolean;
}
interface PSA {
sticky?: boolean;
message: string;
level?: number;
}
type ReportTypes = "quote" | "user";
interface Report {

View file

@ -5,7 +5,7 @@ export default class Psas {
this.httpClient = httpClient;
}
async get(): Ape.EndpointResponse {
async get(): Ape.EndpointResponse<SharedTypes.PSA[]> {
return await this.httpClient.get(BASE_PATH);
}
}

View file

@ -18,7 +18,7 @@ function setMemory(id: string): void {
window.localStorage.setItem("confirmedPSAs", JSON.stringify(list));
}
async function getLatest(): Promise<MonkeyTypes.PSA[] | null> {
async function getLatest(): Promise<SharedTypes.PSA[] | null> {
const response = await Ape.psas.get();
if (response.status === 500) {
@ -54,7 +54,7 @@ async function getLatest(): Promise<MonkeyTypes.PSA[] | null> {
} else if (response.status !== 200) {
return null;
}
return response.data as MonkeyTypes.PSA[];
return response.data;
}
export async function show(): Promise<void> {

View file

@ -647,14 +647,6 @@ declare namespace MonkeyTypes {
textSplit?: string[];
}
interface PSA {
sticky?: boolean;
message: string;
_id: string;
level?: number;
date?: number;
}
interface ThemeColors {
bg: string;
main: string;

View file

@ -318,4 +318,12 @@ declare namespace SharedTypes {
none?: boolean;
} & Record<string, boolean>;
}
interface PSA {
_id: string;
message: string;
sticky?: boolean;
level?: number;
date?: number;
}
}