diff --git a/apps/tenant-management-webapp/src/app/pages/admin/services/comment/comments/commentsTable.tsx b/apps/tenant-management-webapp/src/app/pages/admin/services/comment/comments/commentsTable.tsx index f32976fb68..3dad343de8 100644 --- a/apps/tenant-management-webapp/src/app/pages/admin/services/comment/comments/commentsTable.tsx +++ b/apps/tenant-management-webapp/src/app/pages/admin/services/comment/comments/commentsTable.tsx @@ -45,13 +45,15 @@ export const CommentListTable: FunctionComponent = ({ topic, {Object.keys(comments).map((comment) => { - - - {comment} - {comment} - - {comment} - ; + return ( + + + {comment} + {comment} + + {comment} + + ); })} {showAddComment && ( { const [openAddTopic, setOpenAddTopic] = useState(false); const [modalType, setModalType] = useState(''); const [selectedType, setSelectedType] = useState(''); - const [spinner, setSpinner] = useState(false); + const indicator = useSelector((state: RootState) => { return state?.session?.indicator; }); @@ -81,7 +81,6 @@ export const TopicsList = (): JSX.Element => { name="TopicTypes" value={selectedType} onChange={(name: string, selectedType: string) => { - setSpinner(true); setSelectedType(selectedType); }} aria-label="select-comment-topictype-dropdown" @@ -122,13 +121,14 @@ export const TopicsList = (): JSX.Element => { )} {!indicator.show && selectedType !== '' && topics && Object.keys(topics).length === 0 && renderNoItem('topics')} - {!indicator.show && selectedType !== '' && topics && Object.keys(topics).length !== 0 && ( + {selectedType !== '' && topics && Object.keys(topics).length !== 0 && ( { { dispatch(deleteTopicRequest(topicSelected.id)); + dispatch(fetchTopicsRequest(topicTypes[selectedType])); }} /> } diff --git a/apps/tenant-management-webapp/src/app/pages/admin/services/comment/topics/topicsTable.tsx b/apps/tenant-management-webapp/src/app/pages/admin/services/comment/topics/topicsTable.tsx index b3ab278d2e..025d883333 100644 --- a/apps/tenant-management-webapp/src/app/pages/admin/services/comment/topics/topicsTable.tsx +++ b/apps/tenant-management-webapp/src/app/pages/admin/services/comment/topics/topicsTable.tsx @@ -22,9 +22,9 @@ export const TopicListTable = ({ topics, onDeleteTopic }: TopicTableProps): JSX. - Topic name - Resource ID - Action + Topic name + Resource ID + Action diff --git a/apps/tenant-management-webapp/src/app/store/comment/action.ts b/apps/tenant-management-webapp/src/app/store/comment/action.ts index fc3782b31b..43fdb8be35 100644 --- a/apps/tenant-management-webapp/src/app/store/comment/action.ts +++ b/apps/tenant-management-webapp/src/app/store/comment/action.ts @@ -61,7 +61,7 @@ export interface AddTopicRequestAction { export interface AddTopicSuccessAction { type: typeof CREATE_COMMENT_TOPIC_SUCCESS_ACTION; - payload: TopicItem[]; + payload: TopicItem; } export interface FetchTopicsRequestAction { @@ -184,7 +184,7 @@ export const addTopicRequest = (topic: TopicItem[]): AddTopicRequestAction => ({ payload: topic, }); -export const addTopicSuccess = (topic: TopicItem[]): AddTopicSuccessAction => ({ +export const addTopicSuccess = (topic: TopicItem): AddTopicSuccessAction => ({ type: CREATE_COMMENT_TOPIC_SUCCESS_ACTION, payload: topic, }); diff --git a/apps/tenant-management-webapp/src/app/store/comment/reducers.ts b/apps/tenant-management-webapp/src/app/store/comment/reducers.ts index 1885f6d9fd..ee40abd3ee 100644 --- a/apps/tenant-management-webapp/src/app/store/comment/reducers.ts +++ b/apps/tenant-management-webapp/src/app/store/comment/reducers.ts @@ -45,7 +45,7 @@ export default function (state: CommentState = defaultState, action: CommentActi case CREATE_COMMENT_TOPIC_SUCCESS_ACTION: return { ...state, - topics: { ...state.topics, ...action.payload }, + topics: [...state.topics, action.payload], }; case SET_COMMENT_TOPICS_ACTION: diff --git a/apps/tenant-management-webapp/src/app/store/comment/sagas.ts b/apps/tenant-management-webapp/src/app/store/comment/sagas.ts index a62aa1b2c9..40982b4e29 100644 --- a/apps/tenant-management-webapp/src/app/store/comment/sagas.ts +++ b/apps/tenant-management-webapp/src/app/store/comment/sagas.ts @@ -122,6 +122,12 @@ export function* deleteCommentTopicTypes({ topicTypeId }: DeleteCommentTopicType } function* addTopicSaga({ payload }: AddTopicRequestAction): SagaIterator { + yield put( + UpdateIndicator({ + show: true, + message: 'Creating Topic...', + }) + ); const baseUrl: string = yield select((state: RootState) => state.config.serviceUrls?.commentServiceApiUrl); const token = yield call(getAccessToken); @@ -129,8 +135,12 @@ function* addTopicSaga({ payload }: AddTopicRequestAction): SagaIterator { const url = `${baseUrl}/comment/v1/topics`; const newTopic = yield call(addTopicApi, token, url, payload); yield put(addTopicSuccess(newTopic)); + + yield put(UpdateIndicator({ show: false })); } catch (error) { yield put(ErrorNotification(error.toString())); + + yield put(UpdateIndicator({ show: false })); } }