-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding RTK Query, updating social links functionality.
Adding prop-types and recfactoring project
- Loading branch information
1 parent
eae2935
commit cbd49df
Showing
39 changed files
with
1,241 additions
and
971 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
// https://redux-toolkit.js.org/rtk-query/overview | ||
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; | ||
// Config | ||
import { gitHubUsername } from "../data"; | ||
import { githubUsername } from "../config"; | ||
|
||
export const apiSlice = createApi({ | ||
reducerPath: "api", | ||
baseQuery: fetchBaseQuery({ baseUrl: "https://api.github.com" }), | ||
endpoints: (builder) => ({ | ||
// https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-a-user | ||
getUsers: builder.query({ | ||
query: () => `/users/${gitHubUsername}`, | ||
query: () => `/users/${githubUsername}`, | ||
}), | ||
// https://docs.github.com/en/rest/users/social-accounts?apiVersion=2022-11-28#list-social-accounts-for-a-user | ||
getSocials: builder.query({ | ||
query: () => `/users/${githubUsername}/social_accounts`, | ||
}), | ||
// https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-repositories-for-a-user | ||
getProjects: builder.query({ | ||
query: () => `/users/${githubUsername}/repos`, | ||
}), | ||
}), | ||
}); | ||
|
||
export const { useGetUsersQuery } = apiSlice; | ||
export const { useGetUsersQuery, useGetSocialsQuery, useGetProjectsQuery } = | ||
apiSlice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// https://redux-toolkit.js.org/usage/usage-guide#simplifying-slices-with-createslice | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
|
||
const initialState = { | ||
projects: [], | ||
mainProjects: [], | ||
}; | ||
|
||
export const projectsSlice = createSlice({ | ||
name: "projects", | ||
initialState, | ||
reducers: { | ||
setProjects: (state, action) => { | ||
state.projects = action.payload; | ||
}, | ||
setMainProjects: (state, action) => { | ||
state.mainProjects = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const selectProjects = (state) => state.projects.projects; | ||
export const selectMainProjects = (state) => state.projects.mainProjects; | ||
export const { setProjects, setMainProjects } = projectsSlice.actions; | ||
|
||
export default projectsSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.