diff --git a/src/app/techrecord/(pages)/redux-example/page.tsx b/src/app/techrecord/(pages)/redux-example/page.tsx
index 429a02d..697bd01 100644
--- a/src/app/techrecord/(pages)/redux-example/page.tsx
+++ b/src/app/techrecord/(pages)/redux-example/page.tsx
@@ -1,14 +1,12 @@
'use client';
-import { decrement, getCatFacts, increment } from '@/libs/features';
+import { decrement, increment } from '@/libs/features';
import { useAppDispatch, useAppSelector } from '@/libs/hooks';
-import type { CatFact } from '@/types';
import styles from './page.module.css';
export default function ReduxExample() {
const count = useAppSelector((state) => state.counter.data);
- const catFacts = useAppSelector((state) => state.catFacts.data);
const dispatch = useAppDispatch();
return (
@@ -23,31 +21,6 @@ export default function ReduxExample() {
Increase
-
API Example (Cat Facts)
-
-
-
- {catFacts &&
- catFacts.map((catFact: CatFact) => (
-
-
---------------------------
-
- status: [ verified: {catFact.status.verified}, sentCount:{' '}
- {catFact.status.sentCount} ]
-
-
- type: {catFact.type}, id: {catFact._id}
-
-
text: {catFact.text}
-
created date: {catFact.createdAt}
-
updated date: {catFact.updatedAt}
-
user: {catFact.user}
-
- ))}
-
-
>
);
}
diff --git a/src/libs/api/AsyncReducers.ts b/src/libs/api/AsyncReducers.ts
deleted file mode 100644
index e903c95..0000000
--- a/src/libs/api/AsyncReducers.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-/* eslint-disable no-param-reassign */
-import type {
- ActionReducerMapBuilder,
- AsyncThunk,
- CaseReducer,
- PayloadAction,
-} from '@reduxjs/toolkit';
-import type { AsyncThunkConfig } from '@reduxjs/toolkit/dist/createAsyncThunk';
-
-import type { AsyncState } from '@/types';
-
-export class AsyncReducers {
- /**
- * @author Juun
- * @param builder
- * @example
- * ```ts
- * const asyncThunk = AsyncThunk.create(...);
- * const slice = createSlice({
- * ...,
- * reducers: {},
- * extraReducers: (builder) => {
- * // use default reducers:
- * AsyncReducers.create(builder)(asyncThunk);
- * // customize reducers:
- * AsyncReducers.create(builder)(asyncThunk, {
- * onFulfilled: (state, action) => {
- * // Your reducer action here
- * },
- * onPending: (state, action) => {
- * // Your reducer action here
- * },
- * ...,
- * })
- * }
- * })
- * ```
- */
- static create = >(
- builder: ActionReducerMapBuilder,
- ) => {
- return (
- asyncThunk: AsyncThunk,
- options: {
- onFulfilled?: CaseReducer>;
- onPending?: CaseReducer>;
- onRejected?: CaseReducer>;
- } = {},
- ) => {
- const { onFulfilled, onPending, onRejected } = {
- onFulfilled: (state: any, action: PayloadAction) => {
- state.data = action.payload;
- state.status = 'fulfilled';
- },
- onPending: (state: any) => {
- state.status = 'pending';
- },
- onRejected: (state: any) => {
- state.status = 'rejected';
- },
- ...options,
- };
-
- builder
- .addCase(asyncThunk.fulfilled, (state, action) =>
- onFulfilled(state, action),
- )
- .addCase(asyncThunk.pending, (state, action) =>
- onPending(state, action),
- )
- .addCase(asyncThunk.rejected, (state, action) =>
- onRejected(state, action),
- );
- };
- };
-}
diff --git a/src/libs/api/index.ts b/src/libs/api/index.ts
index 875e6f7..b7e5f2c 100644
--- a/src/libs/api/index.ts
+++ b/src/libs/api/index.ts
@@ -1,2 +1 @@
-export * from './AsyncReducers';
export * from './AsyncThunk';
diff --git a/src/libs/features/catFacts/catFactsSlice.ts b/src/libs/features/catFacts/catFactsSlice.ts
deleted file mode 100644
index 45dcf29..0000000
--- a/src/libs/features/catFacts/catFactsSlice.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/* eslint-disable no-param-reassign */
-import { createSlice } from '@reduxjs/toolkit';
-
-import { AsyncReducers, AsyncThunk } from '@/libs/api';
-import type { AsyncState } from '@/types';
-
-const initialState: AsyncState = {
- data: null,
- status: 'fulfilled',
-};
-
-export const getCatFacts = AsyncThunk.create('CatFacts')({
- url: 'https://cat-fact.herokuapp.com/facts',
- method: 'GET',
-});
-
-const slice = createSlice({
- name: 'catFacts',
- initialState,
- reducers: {},
- extraReducers: (builder) => AsyncReducers.create(builder)(getCatFacts),
-});
-
-export const catFactsReducer = slice.reducer;
diff --git a/src/libs/features/index.ts b/src/libs/features/index.ts
index 13ee889..6b58f60 100644
--- a/src/libs/features/index.ts
+++ b/src/libs/features/index.ts
@@ -1,4 +1,3 @@
export * from './apiSlice';
export * from './auth/authSlice';
-export * from './catFacts/catFactsSlice';
export * from './counter/counterSlice';
diff --git a/src/libs/store.ts b/src/libs/store.ts
index 5f92c56..4442335 100644
--- a/src/libs/store.ts
+++ b/src/libs/store.ts
@@ -1,17 +1,11 @@
import { configureStore } from '@reduxjs/toolkit';
-import {
- apiSlice,
- authReducer,
- catFactsReducer,
- counterReducer,
-} from '@/libs/features';
+import { apiSlice, authReducer, counterReducer } from '@/libs/features';
export const makeStore = () => {
return configureStore({
reducer: {
counter: counterReducer,
- catFacts: catFactsReducer,
auth: authReducer,
[apiSlice.reducerPath]: apiSlice.reducer,
},