refactor: server StoredServer interface

This commit is contained in:
Tristan Yang
2022-06-27 09:24:29 +08:00
parent 212284cd9b
commit 4618afc2ed
3 changed files with 7 additions and 13 deletions
+1 -2
View File
@@ -1,6 +1,6 @@
import { createApi } from "@reduxjs/toolkit/query/react"; import { createApi } from "@reduxjs/toolkit/query/react";
import BASE_URL from "../config"; import BASE_URL from "../config";
import { updateInfo } from "../slices/server"; import { updateInfo, StoredServer } from "../slices/server";
import baseQuery from "./base.query"; import baseQuery from "./base.query";
import { RootState } from "../store"; import { RootState } from "../store";
import { User } from "../../types/auth"; import { User } from "../../types/auth";
@@ -9,7 +9,6 @@ import {
GoogleAuthConfig, GoogleAuthConfig,
LoginConfig, LoginConfig,
Server, Server,
StoredServer,
TestEmailDTO, TestEmailDTO,
NewAdminDTO, NewAdminDTO,
SMTPConfig, SMTPConfig,
+6 -8
View File
@@ -1,16 +1,14 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { Server } from "../../types/server";
interface State { export interface StoredServer extends Server {
name: string;
description: string;
logo: string; logo: string;
inviteLink: { inviteLink?: {
link: string; link: string;
expire: number; expire: number;
}; };
} }
const initialState: StoredServer = {
const initialState: State = {
name: "", name: "",
description: "", description: "",
logo: "", logo: "",
@@ -27,7 +25,7 @@ const serverSlice = createSlice({
resetServer() { resetServer() {
return initialState; return initialState;
}, },
fullfillServer(state, action: PayloadAction<State>) { fullfillServer(state, action: PayloadAction<StoredServer>) {
const { const {
inviteLink = { inviteLink = {
link: "", link: "",
@@ -39,7 +37,7 @@ const serverSlice = createSlice({
} = action.payload || {}; } = action.payload || {};
return { name, logo, description, inviteLink }; return { name, logo, description, inviteLink };
}, },
updateInfo(state, action: PayloadAction<Partial<State>>) { updateInfo(state, action: PayloadAction<Partial<StoredServer>>) {
const values = action.payload || {}; const values = action.payload || {};
// todo: check and remove old logic // todo: check and remove old logic
// Object.keys(values).forEach((_key) => { // Object.keys(values).forEach((_key) => {
-3
View File
@@ -3,9 +3,6 @@ export interface Server {
name: string; name: string;
description: string; description: string;
} }
export interface StoredServer extends Server {
logo: string;
}
export interface GithubAuthConfig { export interface GithubAuthConfig {
client_id: string; client_id: string;
client_secret: string; client_secret: string;