-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Redux | Course Slice #16: Update routing constants * Remove unused imports in dashboard.tsx * Redux | Course Slice #16: Add COURSE route to ServerPath class * renamed authActionSlice to authSlice * Update bootcamp endpoint in store/slice/bootcamp/endpoint.ts * Redux | Course Slice #16: Add courseSlice endpoint and export it * Add course endpoint to store slice * Add coursePersistConfig to root-reducer.ts * Add invalidatesTags property to EndpointBuilder interface * set interface to EndpointBuilder * fixed the url for deleteCourse endpoint --------- Co-authored-by: triple iii <[email protected]>
- Loading branch information
1 parent
1592634
commit 07c8d4f
Showing
10 changed files
with
100 additions
and
17 deletions.
There are no files selected for viewing
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
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,20 +1,48 @@ | ||
import { apiSlice } from '../api' | ||
import { apiSlice } from 'store/slice/api' | ||
import { ServerPath } from 'route/path' | ||
import { METHOD } from 'constant' | ||
|
||
export const bootcampApiSlice = apiSlice.injectEndpoints({ | ||
endpoints: (builder) => ({ | ||
getAllBootcamp: builder.query<any, void>({ | ||
const { GET, POST, PUT, DELETE } = METHOD | ||
|
||
export const bootcampSlice = apiSlice.injectEndpoints({ | ||
endpoints: (builder: EndpointBuilder) => ({ | ||
getAllBootcamp: builder.query({ | ||
query: () => ({ | ||
url: ServerPath.BOOTCAMP | ||
url: ServerPath.BOOTCAMP, | ||
method: GET | ||
}), | ||
keepUnusedDataFor: 5 | ||
}), | ||
getBootcamp: builder.query<any, string>({ | ||
getBootcamp: builder.query({ | ||
query: (id) => ({ | ||
url: ServerPath.BOOTCAMP_ID(id) | ||
url: ServerPath.BOOTCAMP_ID(id), | ||
method: GET | ||
}) | ||
}), | ||
createBootcamp: builder.mutation({ | ||
query: (data: any) => ({ | ||
url: ServerPath.BOOTCAMP, | ||
method: POST, | ||
body: data | ||
}), | ||
invalidatesTags: ['Bootcamp'] | ||
}), | ||
updateBootcamp: builder.mutation({ | ||
query: (data: any) => ({ | ||
url: ServerPath.BOOTCAMP_ID(data.id), | ||
method: PUT, | ||
body: data | ||
}), | ||
invalidatesTags: ['Bootcamp'] | ||
}), | ||
deleteBootcamp: builder.mutation({ | ||
query: (id: string) => ({ | ||
url: ServerPath.BOOTCAMP_ID(id), | ||
method: DELETE | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
export const { useGetAllBootcampQuery, useGetBootcampQuery } = bootcampApiSlice | ||
export const { useGetAllBootcampQuery, useGetBootcampQuery, useCreateBootcampMutation, useUpdateBootcampMutation, useDeleteBootcampMutation } = | ||
bootcampSlice |
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,45 @@ | ||
import { apiSlice } from 'store/slice/api' | ||
import { ServerPath } from 'route/path' | ||
import { METHOD } from 'constant' | ||
|
||
const { GET, POST, PUT, DELETE } = METHOD | ||
|
||
export const courseSlice = apiSlice.injectEndpoints({ | ||
endpoints: (builder: EndpointBuilder) => ({ | ||
getAllCourse: builder.query({ | ||
query: () => ({ | ||
url: ServerPath.COURSE, | ||
method: GET | ||
}), | ||
keepUnusedDataFor: 5 | ||
}), | ||
getCourse: builder.query({ | ||
query: (id) => ({ | ||
url: ServerPath.COURSE_ID(id), | ||
method: GET | ||
}) | ||
}), | ||
createCourse: builder.mutation({ | ||
query: (data: any) => ({ | ||
url: ServerPath.COURSE, | ||
method: POST, | ||
body: data | ||
}) | ||
}), | ||
updateCourse: builder.mutation({ | ||
query: (data: any) => ({ | ||
url: ServerPath.COURSE_ID(data.id), | ||
method: PUT, | ||
body: data | ||
}) | ||
}), | ||
deleteCourse: builder.mutation({ | ||
query: (id: string) => ({ | ||
url: ServerPath.COURSE_ID(id), | ||
method: DELETE | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
export const { useGetAllCourseMutation, useGetCourseQuery, useCreateCourseMutation, useUpdateCourseMutation, useDeleteCourseMutation } = courseSlice |
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 @@ | ||
export * from './endpoint' |
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