95 lines
4.9 KiB
JavaScript
95 lines
4.9 KiB
JavaScript
import React , { useEffect , useState } from 'react';
|
||
import { Breadcrumb, message } from 'antd';
|
||
import {getUserApplyInfo} from '../api';
|
||
import axios from 'axios';
|
||
import RepoInfo from './repoInfo';
|
||
import EditInfo from './editInfo';
|
||
import banner from "../img/banner.png";
|
||
import apply1 from "../img/apply1.png";
|
||
import './index.scss';
|
||
import { FlexAJ } from '../../forge/Component/layout';
|
||
// 项目、课题报名
|
||
function Apply(props) {
|
||
const {current_user, round} = props;
|
||
const [reload, setReload] = useState(undefined);
|
||
const [cateList, setCateList] = useState([]);
|
||
const [userApplyInfo, setUserApplyInfo] = useState([]);
|
||
// 添加一个项目
|
||
const [isAddRepo, setIsAddRepo] = useState(false);
|
||
// 编辑项目个数
|
||
const [editRepoCount, setEditRepoCount] = useState(0);
|
||
|
||
useEffect(()=>{
|
||
// 进入此页面置顶
|
||
window.scrollTo(0,0);
|
||
if(current_user && current_user.login){
|
||
// 获取项目分类参数
|
||
const url = `/project_categories/pinned_index.json`;
|
||
axios.get(url).then(result=>{
|
||
if(result && result.data){
|
||
setCateList(result.data.project_categories);
|
||
}
|
||
}).catch(error=>{})
|
||
}else{
|
||
window.location.href="/login?go_page=/glcc/apply";
|
||
}
|
||
}, [])
|
||
|
||
useEffect(()=>{
|
||
// 获取当前用户报名信息
|
||
current_user && round && getUserApplyInfo({userId: current_user.user_id, round}).then(response=>{
|
||
if(response && response.message === "success"){
|
||
setUserApplyInfo(response.data);
|
||
}
|
||
})
|
||
}, [reload])
|
||
|
||
// 添加项目点击函数
|
||
function addRepoBut(){
|
||
if(isAddRepo || editRepoCount){
|
||
scrollToEdit();
|
||
message.error("请先提交当前项目信息");
|
||
return;
|
||
}
|
||
setIsAddRepo(true);
|
||
setTimeout(() => {
|
||
scrollToEdit()
|
||
}, 100);
|
||
}
|
||
|
||
// 屏幕滚动到编辑区域
|
||
function scrollToEdit(){
|
||
const element = document.getElementById("editRepoInfoId");
|
||
window.scrollTo(0, element.offsetTop-80);
|
||
}
|
||
|
||
return(
|
||
<div className="glcc_apply">
|
||
{/* <img className="glcc-banner" src={banner} alt=''></img> */}
|
||
<div className='apply'>
|
||
<Breadcrumb className='pt20 font-16 breadcrumbGlcc'>
|
||
<Breadcrumb.Item><a href="/glcc">开源夏令营</a></Breadcrumb.Item>
|
||
<Breadcrumb.Item>项目报名</Breadcrumb.Item>
|
||
</Breadcrumb>
|
||
{userApplyInfo.length > 0 && <div className='applySuccess mt20 font-15'>您已报名成功,可实时修改您的报名信息再次提交。请关注夏令营首页新闻公告获得更多活动资讯!</div>}
|
||
<div className={`explain`}>
|
||
<p className='font-15 c000'>申请说明</p>
|
||
<div>1、项目报名时间为<span className='c000'>4月29日—5月30日</span>,请在报名截止时间(北京时间<span className='c000'>2023年5月30日24点</span>)前提交报名信息。</div>
|
||
<div>2、本次GLCC夏令营建议使用GitLink为代码托管平台,学生基于GitLink上项目完成编程任务。同时也欢迎使用其他代码托管平台的项目参与活动。目前GLCC只对夏令营期间使用GitLink托管的项目提供部分奖金支持。</div>
|
||
<div>3、如果您的项目还未迁移到GitLink上,迁移事项请查看<a href='https://forum.gitlink.org.cn/forums/7296/detail' target="_blank" className='link'>迁移说明文档</a>。如在迁移过程中遇到问题,请加qq群: 1071514693 联系qq群管理员。</div>
|
||
<div>4、提交社区和题目信息后,欢迎与组委会联系沟通宣传推广和后续合作工作。联系人微信: _TigerWang(备注GitLink编程夏令营)</div>
|
||
<div><span className='c000'>5、奖金默认由项目方支持,请根据课题难度设定金额。若您可能无法支撑本课题奖金,GLCC组委会将进行资助评审,择优资助。如未获得资助,将下线该课题</span></div>
|
||
</div>
|
||
<FlexAJ className='pt20 font-18 pb20'>
|
||
<span><img src={apply1} alt="" width="25px" className="mr10"/>项目报名</span>
|
||
{userApplyInfo.length > 0 && <a className='font-16 addRepoBut' onClick={addRepoBut}><i className='iconfont icon-tianjia_tianchong mr5 font-22'></i>添加项目</a>}
|
||
</FlexAJ>
|
||
{userApplyInfo.length > 0 && <div className='repoListBox'>
|
||
{userApplyInfo.map((item, index)=><div className='repoList mb20' key={index}><RepoInfo cateList={cateList} applyInfo={item} current_user={current_user} round={round} setReload={()=>{setReload(Math.random())}} isAddRepo={isAddRepo} editRepoCount={editRepoCount} setEditRepoCount={setEditRepoCount} repoCount={userApplyInfo.length} scrollToEdit={scrollToEdit}/></div>)}
|
||
</div>}
|
||
{(!userApplyInfo.length || isAddRepo) && <EditInfo isAddRepo={isAddRepo} setIsAddRepo={setIsAddRepo} round={round} cateList={cateList} current_user={current_user} setReload={()=>{setReload(Math.random())}}/>}
|
||
</div>
|
||
</div>
|
||
)
|
||
}
|
||
export default Apply; |