frontend converted to ts

This commit is contained in:
QkoSad
2023-07-25 20:40:02 +03:00
parent 1e64a910cc
commit 3bf4e9fc56
60 changed files with 3584 additions and 7 deletions
+84
View File
@@ -0,0 +1,84 @@
import { createSlice } from "@reduxjs/toolkit";
import { Repo, ProfileType } from "../types";
type ProfileState = {
profile: ProfileType | null
profiles: ProfileType[]
repos: Repo[]
loading: boolean
error: {}
}
const initialState: ProfileState = {
profile: null,
profiles: [],
repos: [],
loading: true,
error: {},
};
const profileSlice = createSlice({
name: "profile",
initialState,
reducers: {
getProfile(state, action) {
return {
...state,
profile: action.payload,
loading: false,
};
},
updateProfile(state, action) {
return {
...state,
profile: action.payload,
loading: false,
};
},
getProfilesType(state, action) {
return {
...state,
profiles: action.payload,
loading: false,
};
},
profileError(state, action) {
return {
...state,
error: action.payload,
loading: false,
profile: null,
};
},
clearProfile(state) {
return {
...state,
profile: null,
repos: [],
};
},
getRepos(state, action) {
return {
...state,
repos: action.payload,
loading: false,
};
},
noRepos(state) {
return {
...state,
repos: [],
};
},
},
});
export const {
noRepos,
getRepos,
clearProfile,
profileError,
getProfilesType,
updateProfile,
getProfile,
} = profileSlice.actions;
export default profileSlice.reducer;