Skip to content

Commit

Permalink
feat(fe-notifiche): updates 20240229
Browse files Browse the repository at this point in the history
  • Loading branch information
a-buono committed Feb 29, 2024
1 parent 325e5fd commit fe434c0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clsx from 'clsx';
import { Icon } from 'design-react-kit';
import React, { useState } from 'react';
import React, { useCallback, useState } from 'react';
import { useDispatch } from 'react-redux';
import { useParams } from 'react-router-dom';
import GenericModal from '../../../../../components/Modals/GenericModal/genericModal';
Expand Down Expand Up @@ -39,15 +39,30 @@ const ManageReport: React.FC<ManageReportI> = ({
const { id } = useParams();
const userId = useAppSelector(selectUser)?.id;

const saveReportBoardCommunityDocument = useCallback(
async (
id: string,
userId: string,
entity: 'board' | 'community' | 'document' | 'forum'
) => {
if (entity === 'forum') {
entity = 'community';
}
await dispatch(CreateItemReport(id, newReport));
dispatch(GetItemDetail(id, userId, entity));
},
[dispatch, newReport]
);

const handleSaveReport = async () => {
if (newReport.trim() !== '' && payload) {
switch (payload.entity) {
case 'board':
case 'community':
case 'document':
case 'forum':
if (id && userId) {
await dispatch(CreateItemReport(id, newReport));
dispatch(GetItemDetail(id, userId, payload.entity));
await saveReportBoardCommunityDocument(id, userId, payload.entity);
}
break;
case 'comment':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const GetUsersAnagrapic =
} = select((state: RootState) => state);
if (idsToGet?.length) {
const res = await API.post(
`/utente/listaUtenti?richiediImmagine=${richiediImmagine}`,
`${process?.env?.GESTIONE_UTENTE}utente/listaUtenti?richiediImmagine=${richiediImmagine}`,
{
idsUtenti: idsToGet,
}
Expand Down
20 changes: 15 additions & 5 deletions fe-piattaforma/src/redux/features/forum/forumThunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ export const GetTopicsFilters =
),
};
const queryParameters = transformFiltersToQueryParams(body);
const res = await proxyCall(`/community/filters${queryParameters}`, 'GET');
const res = await proxyCall(
`/community/filters${queryParameters}`,
'GET'
);
if (res?.data?.data) {
dispatch(
setForumFilterOptions(
Expand Down Expand Up @@ -278,7 +281,10 @@ export const GetTopicsList =
...forcedFilters,
}).replace('sort', 'sort_by');
//.replace('categories', 'category')
const res = await proxyCall(`/community/items${queryParamFilters}`, 'GET');
const res = await proxyCall(
`/community/items${queryParamFilters}`,
'GET'
);
if (updateStore) {
if (res?.data?.data) {
dispatch(setTopicsList(res.data.data.items || []));
Expand Down Expand Up @@ -598,7 +604,8 @@ export const GetItemsByUser = () => async (dispatch: Dispatch) => {
dispatch(
setTopicsList(
(res[1]?.data.data.items || []).filter(
({ item_type }: { item_type: string }) => item_type === 'community_item'
({ item_type }: { item_type: string }) =>
item_type === 'community_item'
)
)
);
Expand All @@ -623,12 +630,15 @@ const GetItemDetailsAction = {
};

export const GetItemDetail =
(itemId: string, userId: string, entity: 'board' | 'community' | 'document') =>
(
itemId: string,
userId: string,
entity: 'board' | 'community' | 'document'
) =>
async (dispatch: Dispatch) => {
try {
dispatch(showLoader());
dispatch({ ...GetItemDetailsAction });

const res = await proxyCall(
`/${entity}/item/${itemId}/user/${userId}`,
'GET'
Expand Down
6 changes: 3 additions & 3 deletions fe-piattaforma/src/redux/features/user/userSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ export const userSlice = createSlice({
initialState,
reducers: {
setUserContext: (state, action: PayloadAction<any>) => {
const {payload} = action;
const { payload } = action;
state.user = {
...payload
...payload,
};
state.ruoli = payload.ruoli;
setSessionValues('user', state.user);
Expand Down Expand Up @@ -151,7 +151,7 @@ export const userSlice = createSlice({
});
},
login: (state) => {
if(state.user){
if (state.user) {
state.user['cfUtenteLoggato'] = state?.user?.codiceFiscale;
}
setSessionValues('user', state.user);
Expand Down
4 changes: 2 additions & 2 deletions fe-piattaforma/src/redux/features/user/userThunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ export const GetNotificationsByUser =
data: {
items: [],
pager: {
total_items: 1,
total_pages: 1
total_items: 0,
total_pages: 0
}
}
}
Expand Down

0 comments on commit fe434c0

Please sign in to comment.