Skip to content
Snippets Groups Projects
Select Git revision
  • 4e0c96c59607fd366b7bb2430706351820b2369d
  • main default
  • tp3
  • tp2
  • tp1
  • tp3-correction
  • tp2-correction
  • tp1-correction
  • admins
9 results

Expression.py

Blame
  • Forked from an inaccessible project.
    SubmitForm.js 2.18 KiB
    import React, { useState, useEffect } from "react";
    import { MDBRow, MDBCol, MDBInput, MDBBtn, MDBCard, MDBCardBody, MDBModalFooter, MDBIcon, MDBContainer } from 'mdbreact';
    import axios from 'axios';
    import eventData from "../../eventData/eventData.json";
    
    function Submit(props) {
    
        /*var [participants,setParticipants] = useState([]);
            useEffect(() => {
                const interval = setInterval(() => {
                axios.get('/api/participants_by_id',{
                    id: props.participant.value
                }).then((response) => setParticipants(response.data));
                }, 500);
            return () => clearInterval(interval);
            }, []);*/
    
    
        function addScore() {
    
            /*if (participants[0] === undefined) {
                axios.post('/api/staff/new_participant_with_id',
            {
                id: props.participant.value,
                name: props.participant.label
            })
            }*/
    
            const timenow = Date.now();
            var realId;
            var realName;
    
            if (timenow < 0/*eventData.dateFin*/) {
                realId = props.participant.value;
                realName = props.participant.label
            }
            else {
                realId = 'sprint';
                realName = 'Sprint'
            }
    
            axios.post('/api/staff/new_score',
                {
                    score: Math.max(0, props.score),
                    equipe: props.equipe.value,
                    participant: realId//props.participant.value
                })
                .then(() => {
                    axios.post('/api/staff/new_participant_with_id',
                        {
                            id: realId,//props.participant.value,
                            name: realName//props.participant.label
                        })
                })
                .then(() => {
                    alert("Score ajouté");
                    window.location = '/Input';
                }, (error) => {
                    console.log(error);
                })
        };
    
    
    
    
    
    
    
    
        const onSubmit = () => { addScore() };