Skip to content

Commit

Permalink
Merge branch 'main' of github.com:francesco-velluto/se2023-15-thesis-…
Browse files Browse the repository at this point in the history
…management
  • Loading branch information
aleche28 committed Jan 17, 2024
2 parents 6c5ea93 + 9d3579a commit 0ce15bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion frontend/src/components/ApplicationButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { Button, Container, Modal } from "react-bootstrap";
import { LoggedUserContext } from "../context/AuthenticationContext";
import PropTypes from "prop-types";
import UploadResume from './UploadFile';
import { propTypes } from 'react-bootstrap/esm/Image';

const ApplicationButton = ({ proposalID, setErrMsg, applicationStatusCallback, setFileSent, setIsFile }) => {
const [isActive, setIsActive] = useState(false);
const [applied, setApplied] = useState(false);
const [disabled, setDisabled] = useState(false);
const [showModal, setShowModal] = useState(false);
Expand All @@ -25,6 +27,10 @@ const ApplicationButton = ({ proposalID, setErrMsg, applicationStatusCallback, s

const { loggedUser } = useContext(LoggedUserContext);

const handleIsActiveChange = (value) => {
setIsActive(value);
};

const getApplicationList = async () => {
try {
const Applist = await getAllApplicationsByStudent(loggedUser.id);
Expand Down Expand Up @@ -92,13 +98,14 @@ const ApplicationButton = ({ proposalID, setErrMsg, applicationStatusCallback, s
<Modal.Title>Add a PDF file (optional)</Modal.Title>
</Modal.Header>
<Modal.Body>
<UploadResume setCallbackUploadId={setUploadId} />
<UploadResume setCallbackUploadId={setUploadId} onIsActiveChange={handleIsActiveChange} />
</Modal.Body>
<Modal.Footer>
<Button
id="confirm-application"
variant="success"
onClick={handleButtonClick}
disabled={isActive && uploadId===null}
>
Confirm
</Button>
Expand All @@ -114,6 +121,7 @@ ApplicationButton.propTypes = {
applicationStatusCallback: PropTypes.func,
setFileSent: PropTypes.func,
setIsFile: PropTypes.func,
isActive: propTypes.bool,

}

Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/UploadFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { NativeTypes } from 'react-dnd-html5-backend';
import PropTypes from 'prop-types';
import Swal from 'sweetalert2';

const UploadResume = ({ setCallbackUploadId }) => {
const UploadResume = ({ setCallbackUploadId, onIsActiveChange }) => {
const { loggedUser } = useContext(LoggedUserContext);
const [file, setFile] = useState(null);
const [isActive, setIsActive] = useState(false);
Expand All @@ -31,11 +31,13 @@ const UploadResume = ({ setCallbackUploadId }) => {
const selectedFile = event.target.files[0];
setFile(selectedFile);
setIsActive(true);
onIsActiveChange(true);
};

const handleFileDrop = (files) => {
setFile(files[0]);
setIsActive(true);
onIsActiveChange(true);
};

const handleFilenameChange = (e) => {
Expand Down Expand Up @@ -84,6 +86,7 @@ const UploadResume = ({ setCallbackUploadId }) => {
setFilename("");
setIsActive(false);
setIsFileName(false);
onIsActiveChange(false);
};

const formatDate = (dateString) => {
Expand Down Expand Up @@ -170,6 +173,7 @@ const UploadResume = ({ setCallbackUploadId }) => {

UploadResume.propTypes = {
setCallbackUploadId: PropTypes.func,
onIsActiveChange: PropTypes.func
};

export default UploadResume;

0 comments on commit 0ce15bd

Please sign in to comment.