Skip to content

Commit

Permalink
Merge pull request #57 from Sokilskill/diary-page
Browse files Browse the repository at this point in the history
fix 404
  • Loading branch information
Sokilskill committed Jan 21, 2024
2 parents f2d03c1 + afc87c8 commit 6ec8d5a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/redux/diary/diaryOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { createAsyncThunk } from '@reduxjs/toolkit';
import axios from 'axios';
import { messageNotification } from '../../components/alertMessages/alertMessages';

const getDiary = createAsyncThunk('/diary', async (credentials, thunkAPI) => {
const getDiary = createAsyncThunk('diary/getDiary', async (credentials, thunkAPI) => {
try {
const { data } = await axios.get(`/diary${credentials}`);
const { userId, date } = credentials;
const { data } = await axios.get(`${baseURL}/${userId}/date/${date}`);
return data;
} catch (error) {
messageNotification(error.response.status);
Expand All @@ -13,13 +14,14 @@ const getDiary = createAsyncThunk('/diary', async (credentials, thunkAPI) => {
});

const postDiaryProduct = createAsyncThunk(
'/diary/addProduct',
'diary/postDiaryProduct',
async (credentials, thunkAPI) => {
try {
const { data } = await axios.post('/diary/addproduct', credentials);
const { userId, date, productData } = credentials;
const { data } = await axios.post(`${baseURL}/${userId}/${date}/addproduct`, productData);
return data;
} catch (error) {
messageNotification(error.response.status);
messageNotification(error.response.status);
return thunkAPI.rejectWithValue(error.message);
}
},
Expand All @@ -41,10 +43,11 @@ const deleteDiaryProduct = createAsyncThunk(
);

const postDiaryExercise = createAsyncThunk(
'/diary/addExercise',
'diary/postDiaryExercise',
async (credentials, thunkAPI) => {
try {
const { data } = await axios.post('/diary/addexercise', credentials);
const { userId, date, exerciseData } = credentials;
const { data } = await axios.post(`${baseURL}/${userId}/${date}/addexercise`, exerciseData);
return data;
} catch (error) {
messageNotification(error.response.status);
Expand Down

0 comments on commit 6ec8d5a

Please sign in to comment.