Select Git revision
existingChannel.js
existingChannel.js 2.92 KiB
import React, {useState, useContext} from 'react';
import { useNavigate } from 'react-router-dom';
import existingStyles from './existingChannel.module.css'
import Channel from './channel';
import AddNotice from './addNotice';
import ChangeIcon from './iconModal';
import ChangePicture from './pictureModal';
import { AuthContext } from '../../App';
const ExistingChannel=({isOpen, onClose, data})=>{
const [IsModal, setIsModal]=useState(false);
const { userData } = useContext(AuthContext);
const [changePicture, setChangePicture]=useState('');
const [changeIcon, setChangeIcon]=useState('');
const openModal=()=>{
setIsModal(true);
}
const closeModal=()=>{
setIsModal(false);
}
const openChangePicture=()=>{
setChangePicture(true);
}
const closeChangePicture=()=>{
setChangePicture(false);
}
const openChangeIcon=()=>{
setChangeIcon(true);
}
const closeChangeIcon=()=>{
setChangeIcon(false);
}
const handleClick=()=>{
openModal();
}
const handlePictureClick=()=>{
openChangePicture();
}
const handleIconClick=()=>{
openChangeIcon();
}
const handleDeleteChannel = async () => {
try {
const response = await fetch(`api/channels/`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
// 여기에 필요한 경우 토큰 또는 다른 인증 정보를 추가합니다.
},
});
if (!response.ok) {
throw new Error(`Failed to delete channel. Status: ${response.status}`);
}
// 삭제가 성공한 경우에 추가적인 로직을 수행할 수 있습니다.
console.log('Channel deleted successfully');
alert("채널이 성공적으로 삭제되었습니다.")
} catch (error) {
console.error('Error deleting channel:', error.message);
}
};