Skip to content

Commit

Permalink
Fix wrong notification imports
Browse files Browse the repository at this point in the history
Previous pull requests failed to adapt their notification imports.
This fixes that.
  • Loading branch information
Arnei committed Feb 28, 2024
1 parent 0335780 commit ce1ad18
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 42 deletions.
6 changes: 3 additions & 3 deletions app/src/slices/aclDetailsSlice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PayloadAction, SerializedError, createAsyncThunk, createSlice } from '@reduxjs/toolkit'
import axios from 'axios';
import { prepareAccessPolicyRulesForPost } from '../utils/resourceUtils';
import { addNotification } from '../thunks/notificationThunks';
import { addNotification } from '../slices/notificationSlice';

/**
* This file contains redux reducer for actions affecting the state of details of an ACL
Expand Down Expand Up @@ -134,11 +134,11 @@ export const updateAclDetails = createAsyncThunk('aclDetails/updateAclDetails',
.put(`/admin-ng/acl/${aclId}`, data)
.then((response) => {
console.info(response);
dispatch(addNotification("success", "ACL_UPDATED"));
dispatch(addNotification({type: "success", key: "ACL_UPDATED"}));
})
.catch((response) => {
console.error(response);
dispatch(addNotification("error", "ACL_NOT_SAVED"));
dispatch(addNotification({type: "error", key: "ACL_NOT_SAVED"}));
});
});

Expand Down
8 changes: 4 additions & 4 deletions app/src/slices/groupDetailsSlice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PayloadAction, SerializedError, createAsyncThunk, createSlice } from '@reduxjs/toolkit'
import axios from 'axios';
import { buildGroupBody } from '../utils/resourceUtils';
import { addNotification } from '../thunks/notificationThunks';
import { addNotification } from '../slices/notificationSlice';

/**
* This file contains redux reducer for actions affecting the state of details of a group
Expand Down Expand Up @@ -69,14 +69,14 @@ export const updateGroupDetails = createAsyncThunk('groupDetails/updateGroupDeta
.put(`/admin-ng/groups/${groupId}`, data)
.then((response) => {
console.info(response);
dispatch(addNotification("success", "GROUP_UPDATED"));
dispatch(addNotification({type: "success", key: "GROUP_UPDATED"}));
})
.catch((response) => {
console.error(response);
if (response.status === 409) {
dispatch(addNotification("error", "GROUP_CONFLICT"));
dispatch(addNotification({type: "error", key: "GROUP_CONFLICT"}));
} else {
dispatch(addNotification("error", "GROUP_NOT_SAVED"));
dispatch(addNotification({type: "error", key: "GROUP_NOT_SAVED"}));
}
});
});
Expand Down
12 changes: 6 additions & 6 deletions app/src/slices/groupSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PayloadAction, SerializedError, createAsyncThunk, createSlice } from '@
import { groupsTableConfig } from '../configs/tableConfigs/groupsTableConfig';
import axios from 'axios';
import { buildGroupBody, getURLParams } from '../utils/resourceUtils';
import { addNotification } from '../thunks/notificationThunks';
import { addNotification } from '../slices/notificationSlice';

/**
* This file contains redux reducer for actions affecting the state of groups
Expand Down Expand Up @@ -69,14 +69,14 @@ export const postNewGroup = createAsyncThunk('groups/postNewGroup', async (value
})
.then((response) => {
console.info(response);
dispatch(addNotification("success", "GROUP_ADDED"));
dispatch(addNotification({type: "success", key: "GROUP_ADDED"}));
})
.catch((response) => {
console.error(response);
if (response.status === 409) {
dispatch(addNotification("error", "GROUP_CONFLICT"));
dispatch(addNotification({type: "error", key: "GROUP_CONFLICT"}));
} else {
dispatch(addNotification("error", "GROUP_NOT_SAVED"));
dispatch(addNotification({type: "error", key: "GROUP_NOT_SAVED"}));
}
});
});
Expand All @@ -88,12 +88,12 @@ export const deleteGroup = createAsyncThunk('groups/deleteGroup', async (id: any
.then((res) => {
console.info(res);
// add success notification
dispatch(addNotification("success", "GROUP_DELETED"));
dispatch(addNotification({type: "success", key: "GROUP_DELETED"}));
})
.catch((res) => {
console.error(res);
// add error notification
dispatch(addNotification("error", "GROUP_NOT_DELETED"));
dispatch(addNotification({type: "error", key: "GROUP_NOT_DELETED"}));
});
});

Expand Down
8 changes: 4 additions & 4 deletions app/src/slices/recordingSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PayloadAction, SerializedError, createAsyncThunk, createSlice } from '@
import { recordingsTableConfig } from '../configs/tableConfigs/recordingsTableConfig';
import axios from 'axios';
import { getURLParams } from '../utils/resourceUtils';
import { addNotification } from '../thunks/notificationThunks';
import { addNotification } from '../slices/notificationSlice';

/**
* This file contains redux reducer for actions affecting the state of recordings
Expand Down Expand Up @@ -99,17 +99,17 @@ export const deleteRecording = createAsyncThunk('recordings/deleteRecording', as
.then((res) => {
console.info(res);
// add success notification
dispatch(addNotification("success", "LOCATION_DELETED"));
dispatch(addNotification({type: "success", key: "LOCATION_DELETED"}));
})
.catch((res) => {
console.error(res);
// add error notification depending on status code
if (res.status === 401) {
dispatch(
addNotification("error", "LOCATION_NOT_DELETED_NOT_AUTHORIZED")
addNotification({type: "error", key: "LOCATION_NOT_DELETED_NOT_AUTHORIZED"})
);
} else {
dispatch(addNotification("error", "LOCATION_NOT_DELETED"));
dispatch(addNotification({type: "error", key: "LOCATION_NOT_DELETED"}));
}
});
});
Expand Down
14 changes: 7 additions & 7 deletions app/src/slices/seriesSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
transformToIdValueArray,
transformToObjectArray,
} from "../utils/utils";
import { addNotification } from "../thunks/notificationThunks";
import { addNotification } from '../slices/notificationSlice';

/**
* This file contains redux reducer for actions affecting the state of series
Expand Down Expand Up @@ -205,11 +205,11 @@ export const postNewSeries = createAsyncThunk('series/postNewSeries', async (par
})
.then((response) => {
console.info(response);
dispatch(addNotification("success", "SERIES_ADDED"));
dispatch(addNotification({type: "success", key: "SERIES_ADDED"}));
})
.catch((response) => {
console.error(response);
dispatch(addNotification("error", "SERIES_NOT_SAVED"));
dispatch(addNotification({type: "error", key: "SERIES_NOT_SAVED"}));
});
});

Expand Down Expand Up @@ -241,12 +241,12 @@ export const deleteSeries = createAsyncThunk('series/deleteSeries', async (id: a
.then((res) => {
console.info(res);
// add success notification
dispatch(addNotification("success", "SERIES_DELETED"));
dispatch(addNotification({type: "success", key: "SERIES_DELETED"}));
})
.catch((res) => {
console.error(res);
// add error notification
dispatch(addNotification("error", "SERIES_NOT_DELETED"));
dispatch(addNotification({type: "error", key: "SERIES_NOT_DELETED"}));
});
});

Expand All @@ -265,12 +265,12 @@ export const deleteMultipleSeries = createAsyncThunk('series/deleteMultipleSerie
.then((res) => {
console.info(res);
//add success notification
dispatch(addNotification("success", "SERIES_DELETED"));
dispatch(addNotification({type: "success", key: "SERIES_DELETED"}));
})
.catch((res) => {
console.error(res);
//add error notification
dispatch(addNotification("error", "SERIES_NOT_DELETED"));
dispatch(addNotification({type: "error", key: "SERIES_NOT_DELETED"}));
});
});

Expand Down
6 changes: 3 additions & 3 deletions app/src/slices/themeDetailsSlice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PayloadAction, SerializedError, createAsyncThunk, createSlice } from '@reduxjs/toolkit'
import axios from 'axios';
import { buildThemeBody } from '../utils/resourceUtils';
import { addNotification } from '../thunks/notificationThunks';
import { addNotification } from '../slices/notificationSlice';

/**
* This file contains redux reducer for actions affecting the state of a theme
Expand Down Expand Up @@ -100,11 +100,11 @@ export const updateThemeDetails = createAsyncThunk('themeDetails/updateThemeDeta
})
.then((response) => {
console.info(response);
dispatch(addNotification("success", "THEME_CREATED"));
dispatch(addNotification({type: "success", key: "THEME_CREATED"}));
})
.catch((response) => {
console.error(response);
dispatch(addNotification("error", "THEME_NOT_CREATED"));
dispatch(addNotification({type: "error", key: "THEME_NOT_CREATED"}));
});
});

Expand Down
10 changes: 5 additions & 5 deletions app/src/slices/themeSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PayloadAction, SerializedError, createAsyncThunk, createSlice } from '@
import { themesTableConfig } from "../configs/tableConfigs/themesTableConfig";
import axios from 'axios';
import { buildThemeBody, getURLParams } from '../utils/resourceUtils';
import { addNotification } from '../thunks/notificationThunks';
import { addNotification } from '../slices/notificationSlice';

/**
* This file contains redux reducer for actions affecting the state of themes
Expand Down Expand Up @@ -86,11 +86,11 @@ export const postNewTheme = createAsyncThunk('theme/postNewTheme', async (values
// Since we want to dispatch, we have to handle responses in our thunk
.then((response) => {
console.info(response);
dispatch(addNotification("success", "THEME_CREATED"));
dispatch(addNotification({type: "success", key: "THEME_CREATED"}));
})
.catch((response) => {
console.error(response);
dispatch(addNotification("error", "THEME_NOT_CREATED"));
dispatch(addNotification({type: "error", key: "THEME_NOT_CREATED"}));
});
});

Expand All @@ -101,12 +101,12 @@ export const deleteTheme = createAsyncThunk('theme/deleteTheme', async (id: any,
.then((res) => {
console.info(res);
// add success notification
dispatch(addNotification("success", "THEME_DELETED"));
dispatch(addNotification({type: "success", key: "THEME_DELETED"}));
})
.catch((res) => {
console.error(res);
// add error notification
dispatch(addNotification("error", "THEME_NOT_DELETED"));
dispatch(addNotification({type: "error", key: "THEME_NOT_DELETED"}));
});
});

Expand Down
6 changes: 3 additions & 3 deletions app/src/slices/userDetailsSlice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PayloadAction, SerializedError, createAsyncThunk, createSlice } from '@reduxjs/toolkit'
import axios from 'axios';
import { addNotification } from "../thunks/notificationThunks";
import { addNotification } from '../slices/notificationSlice';
import { buildUserBody } from "../utils/resourceUtils";

/**
Expand Down Expand Up @@ -50,11 +50,11 @@ export const updateUserDetails = createAsyncThunk('userDetails/updateUserDetails
.put(`/admin-ng/users/${username}.json`, data)
.then((response) => {
console.info(response);
dispatch(addNotification("success", "USER_UPDATED"));
dispatch(addNotification({type: "success", key: "USER_UPDATED"}));
})
.catch((response) => {
console.error(response);
dispatch(addNotification("error", "USER_NOT_SAVED"));
dispatch(addNotification({type: "error", key: "USER_NOT_SAVED"}));
});
});

Expand Down
4 changes: 2 additions & 2 deletions app/src/slices/userInfoSlice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PayloadAction, SerializedError, createAsyncThunk, createSlice } from '@reduxjs/toolkit'
import axios from 'axios';
import { addNotification } from '../thunks/notificationThunks';
import { addNotification } from '../slices/notificationSlice';

/**
* This file contains redux reducer for actions affecting the state of information about current user
Expand Down Expand Up @@ -82,7 +82,7 @@ export const fetchUserInfo = createAsyncThunk('UserInfo/fetchUserInfo', async (_
})
.catch((response) => {
console.error(response);
dispatch(addNotification("error", "USER_NOT_SAVED"));
dispatch(addNotification({type: "error", key: "USER_NOT_SAVED"}));
});

return res;
Expand Down
10 changes: 5 additions & 5 deletions app/src/slices/userSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { usersTableConfig } from "../configs/tableConfigs/usersTableConfig";
import axios from 'axios';
import { transformToIdValueArray } from "../utils/utils";
import { buildUserBody, getURLParams } from "../utils/resourceUtils";
import { addNotification } from '../thunks/notificationThunks';
import { addNotification } from '../slices/notificationSlice';

/**
* This file contains redux reducer for actions affecting the state of users
Expand Down Expand Up @@ -73,11 +73,11 @@ export const postNewUser = createAsyncThunk('users/postNewUser', async (values:
// Since we want to dispatch, we have to handle responses in our thunk
.then((response) => {
console.info(response);
dispatch(addNotification("success", "USER_ADDED"));
dispatch(addNotification({type: "success", key: "USER_ADDED"}));
})
.catch((response) => {
console.error(response);
dispatch(addNotification("error", "USER_NOT_SAVED"));
dispatch(addNotification({type: "error", key: "USER_NOT_SAVED"}));
});
});

Expand All @@ -89,12 +89,12 @@ export const deleteUser = createAsyncThunk('users/deleteUser', async (id: any, {
.then((res) => {
console.info(res);
// add success notification
dispatch(addNotification("success", "USER_DELETED"));
dispatch(addNotification({type: "success", key: "USER_DELETED"}));
})
.catch((res) => {
console.error(res);
// add error notification
dispatch(addNotification("error", "USER_NOT_DELETED"));
dispatch(addNotification({type: "error", key: "USER_NOT_DELETED"}));
});
});

Expand Down

0 comments on commit ce1ad18

Please sign in to comment.