Skip to content
Snippets Groups Projects
Select Git revision
  • 263916155e0b7a4593d45083c3a154607e85e64b
  • master default protected
2 results

gltfTutorial_005_BuffersBufferViewsAccessors.md

Blame
  • 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);
          
        }
      };
    
      
      return(
        <div>
        <div className={`${existingStyles.channelModal} ${isOpen ? existingStyles.open : ''}`}>
          
            <div className={existingStyles.channelContent}>
              
            <button className={existingStyles.addcommunity} onClick={handleClick}>공지 추가</button>
            <button className={existingStyles.uploadPicture} onClick={handlePictureClick}>배경 사진 변경</button>
            <button className={existingStyles.uploadicon} onClick={handleIconClick}>아이콘 사진 변경</button>
            <button className={existingStyles.deleteBtn} onClick={handleDeleteChannel}>채널 삭제</button>
            
            <button className={existingStyles.closeBtn} onClick={onClose}>X</button>
            
            <div className={existingStyles.bringModal}>
            <Channel data={data} ></Channel>
            </div>
            </div>
          
        </div>
        <AddNotice isOpen={IsModal} onClose={closeModal}/>
        <ChangeIcon isOpen={changeIcon} onClose={closeChangeIcon}/>
        <ChangePicture isOpen={changePicture} onClose={closeChangePicture}/>
        </div>
    
      )
    }
    export default ExistingChannel;