Skip to content

Commit

Permalink
add .
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatyana-js committed Jan 27, 2025
1 parent 85a8f06 commit e0516f1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion frontend/src/components/AddModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const AddChannel = ({ onHide }) => {
const response = await addChannel({name: values.channelName});
dispatch(selectActiveTab(response.data));
onHide();
console.log(modals);
} catch (error) {
console.log(error);
}
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/components/RemoveModel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ import { Modal, Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { useRemoveChannelMutation } from '../api/chatApi';
import { useSelector } from 'react-redux';
import { selectActiveTab, defaultChannel } from '../slices/activeChannelSlice.js';

const RemoveChannel = ({ onHide }) => {
const { t } = useTranslation();
const [ removeChannel ] = useRemoveChannelMutation();
const channel = useSelector((state) => state.modals.channel);
console.log(channel)
// const activeChannel = useSelector(activeChannelSelector);

const handleRemove = async (id) => {
try {
await removeChannel(id);
onHide();
onHide();
selectActiveTab(defaultChannel);
console.log(defaultChannel);

} catch (err) {
console.log(err);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Сhannels.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ return (
<span className="visually-hidden">{t('channels.setupChannel')}</span>
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item role="button" onClick={() => showModal('removing', activeChannel)}>{t('channels.dropdownButtonRemove')}</Dropdown.Item>
<Dropdown.Item role="button" onClick={() => showModal('removing', channel)}>{t('channels.dropdownButtonRemove')}</Dropdown.Item>
<Dropdown.Item role="button">{t('channels.dropdownButtonRename')}</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>)}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/init.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const init = async () => {
}));
});
socket.on('removeChannel', ({ payload } ) => {
store.dispatch(chatApi.util.updateQueryData('getChannels', undefined, (draft) => {
draft.filter((channel) => channel.id !== payload.id);
store.dispatch(chatApi.util.updateQueryData('getChannels', undefined, (draft, id) => {
draft.filter((channel) => channel.id !== payload);
}));
});
// socket.on('renameMessage', (payload) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/slices/activeChannelSlice.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSlice } from '@reduxjs/toolkit';

const defaultChannel = {
export const defaultChannel = {
id: '1',
name: 'general',
removable: false,
Expand Down

0 comments on commit e0516f1

Please sign in to comment.