[chore] Refactor settings panel routing (and other fixes) (#2864)

This commit is contained in:
tobi
2024-04-24 12:12:47 +02:00
committed by GitHub
parent 62788aa116
commit 7a1e639483
55 changed files with 1788 additions and 1445 deletions

View File

@ -21,6 +21,7 @@ import { replaceCacheOnMutation, removeFromCacheOnMutation } from "../query-modi
import { gtsApi } from "../gts-api";
import { listToKeyedObject } from "../transforms";
import { AdminAccount, HandleSignupParams, SearchAccountParams } from "../../types/account";
import { InstanceRule, MappedRules } from "../../types/rules";
const extended = gtsApi.injectEndpoints({
endpoints: (build) => ({
@ -120,14 +121,14 @@ const extended = gtsApi.injectEndpoints({
],
}),
instanceRules: build.query({
instanceRules: build.query<MappedRules, void>({
query: () => ({
url: `/api/v1/admin/instance/rules`
}),
transformResponse: listToKeyedObject<any>("id")
transformResponse: listToKeyedObject<InstanceRule>("id")
}),
addInstanceRule: build.mutation({
addInstanceRule: build.mutation<MappedRules, any>({
query: (formData) => ({
method: "POST",
url: `/api/v1/admin/instance/rules`,
@ -135,11 +136,7 @@ const extended = gtsApi.injectEndpoints({
body: formData,
discardEmpty: true
}),
transformResponse: (data) => {
return {
[data.id]: data
};
},
transformResponse: listToKeyedObject<InstanceRule>("id"),
...replaceCacheOnMutation("instanceRules"),
}),