Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
feat(redux): add API query for /api/queries/overtime using Redux To…
Browse files Browse the repository at this point in the history
…olkit Query

  ## what
  - add API query for `/api/queries/overtime` using Redux Toolkit Query
  - Query
    - GET queries/overtime
      - fetch data from NextJS API url `/api/queries/overtime`
  - export prebuilt React hook `useGetQueriesOvertimeRawQuery `

  ## how
  - https://redux-toolkit.js.org/rtk-query/overview
  - https://redux-toolkit.js.org/rtk-query/usage/queries
  - https://redux-toolkit.js.org/rtk-query/usage/code-splitting

  ## why
  - Easy way to manage fetching data from API, etc
  - Less overhead to manage the code to handle these operations
  - most of the work is done for you

  ## where
  - ./src/redux/Queries/Overtime/index.ts

  ## usage
  • Loading branch information
Clumsy-Coder committed Aug 20, 2023
1 parent 4f0bd12 commit 680a361
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/redux/Queries/Overtime/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import apiSlice, { TagTypes, HttpQueryType } from '@redux/apiSlice';
import { getQueriesOvertimeUrl } from '@utils/url/api';
import { IOverTimeData10minutes } from '@utils/url/upstream.types';

const clientsApi = apiSlice.injectEndpoints({
endpoints: (build) => ({
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
getQueriesOvertimeRaw: build.query<IOverTimeData10minutes, void>({
query: () => ({
url: `${getQueriesOvertimeUrl}`,
method: HttpQueryType.GET,
}),
providesTags: () => [{ type: TagTypes.QUERY_OVERTIME_RAW }],
}),
}),
});

// eslint-disable-next-line import/prefer-default-export
export const { useGetQueriesOvertimeRawQuery } = clientsApi;

0 comments on commit 680a361

Please sign in to comment.