• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atlp-rwanda / vikings-ec-fe / 9b795d4f-58b8-48a5-a705-a5f3603c9241

pending completion
9b795d4f-58b8-48a5-a705-a5f3603c9241

push

circleci

GitHub
feat: implement create product (#20)

134 of 236 branches covered (56.78%)

Branch coverage included in aggregate %.

99 of 99 new or added lines in 11 files covered. (100.0%)

627 of 767 relevant lines covered (81.75%)

7.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/src/features/createProductSlice.js
1
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
2
import Endpoints from '../utils/endpoints';
3
import axios from './api/customAxios';
4

5
export const createProduct = createAsyncThunk(
24✔
6
  'createProduct',
7
  async (createProductData, { rejectWithValue }) => {
8
    try {
1✔
9
      const { data } = await axios.post(
1✔
10
        Endpoints.createProduct,
11
        createProductData
12
      );
13
      return data;
×
14
    } catch (error) {
15
      return rejectWithValue(error.response);
1✔
16
    }
17
  }
18
);
19

20
export const createProductSlice = createSlice({
24✔
21
  name: 'createProduct',
22
  initialState: {
23
    createdProduct: {},
24
    isLoading: false,
25
    error: null,
26
  },
27
  extraReducers: {
28
    [createProduct.pending]: (state) => {
29
      state.isLoading = true;
1✔
30
      state.createdProduct = {};
1✔
31
      state.error = null;
1✔
32
    },
33
    [createProduct.fulfilled]: (state, action) => {
34
      state.createdProduct = action.payload;
1✔
35
      state.isLoading = false;
1✔
36
      state.error = null;
1✔
37
    },
38
    [createProduct.rejected]: (state, action) => {
39
      state.createdProduct = {};
1✔
40
      state.isLoading = false;
1✔
41
      state.error = action.payload;
1✔
42
    },
43
  },
44
});
45

46
export const createProductActions = (state) => state.createProduct.data;
24✔
47

48
export default createProductSlice.reducer;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc