import React, {  useEffect, useState } from 'react';
import {Spin } from 'antd';
import axios from 'axios';
import GroupFrom from './GroupForm'

function SettingCommon(props){
  const OIdentifier = props.match.params.OIdentifier;
  const groupId = props.match.params.groupId;

  const [ detail , setDetail ] = useState(undefined);
  const [isSpin, setIsSpin] = useState(true);

  useEffect(()=>{
    if(groupId){
      getDetail();
    }
  },[groupId]);

  function getDetail() {
    const url = `/organizations/${OIdentifier}/teams/${groupId}.json`;
    axios.get(url).then((result) => {
      setDetail(result.data)
    }).catch((error) => { });
    setIsSpin(false)
  }
  return(
    <Spin spinning={isSpin}>
      <GroupFrom {...props} GroupDetail={detail}></GroupFrom>
    </Spin>
  )
}
export default SettingCommon;