refactor: add typescript support to project

This commit is contained in:
HD
2022-06-20 17:44:42 +08:00
parent 45419bbcf4
commit c2c051d94c
25 changed files with 407 additions and 222 deletions
+38
View File
@@ -0,0 +1,38 @@
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
name: "",
description: "",
logo: "",
inviteLink: {
link: "",
expire: 0
}
};
const serverSlice = createSlice({
name: "server",
initialState,
reducers: {
resetServer() {
return initialState;
},
fullfillServer(state, action) {
const {
inviteLink = {
link: "",
expire: 0
},
name = "",
description = ""
} = action.payload || {};
return { name, description, inviteLink };
},
updateInfo(state, action) {
const values = action.payload || {};
Object.keys(values).forEach((_key) => {
state[_key] = values[_key];
});
}
}
});
export const { updateInfo, resetServer, fullfillServer } = serverSlice.actions;
export default serverSlice.reducer;