Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #573 from SELab-2/hotfix/building-duration
Browse files Browse the repository at this point in the history
Hotfix/building duration
  • Loading branch information
simvadnbu authored May 21, 2023
2 parents f738778 + 3fa122d commit 0c9d9e7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ const AutocompleteComponent: React.FC<Props> = ({
setValue(initialOption);
setInputValue(initialOption.label);
}
} catch (err) {
console.error(err);
}
} catch (err) {}
}

fetch().then();
Expand Down
1 change: 0 additions & 1 deletion frontend/components/password/resetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function ResetPassword() {
event.preventDefault();

// Handle the reset password process here
console.log("Reset password");
};

return (
Expand Down
6 changes: 1 addition & 5 deletions frontend/lib/student-on-tour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ export function studentOnTourSearchString(studentOnTour: StudentOnTour) {
const tour: Tour = res.data;
return `${tour.name} (${studentOnTour.date})`;
},
(err) => {
console.error(err);
}
() => {}
);
}

Expand Down Expand Up @@ -184,8 +182,6 @@ export async function getActualToursOfStudent(
};

} catch (err) {
// Handle any errors that occurred while fetching data
console.error(err);
throw err;
}
}
Expand Down
84 changes: 40 additions & 44 deletions frontend/pages/admin/data/buildings/edit.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, {ChangeEvent, useEffect, useState} from "react";
import {useRouter} from "next/router";
import {Button, Col, Container, Form, Row} from "react-bootstrap";
import React, { ChangeEvent, useEffect, useState } from "react";
import { useRouter } from "next/router";
import { Button, Col, Container, Form, Row } from "react-bootstrap";
import {
deleteBuildingComment, durationToMinutes,
deleteBuildingComment,
durationToMinutes,
getBuildingComment,
getBuildingInfo,
getDurationFromMinutes,
Expand All @@ -11,17 +12,17 @@ import {
postBuilding,
postBuildingComment,
} from "@/lib/building";
import {getRegion} from "@/lib/region";
import {getUserInfo} from "@/lib/user";
import { getRegion } from "@/lib/region";
import { getUserInfo } from "@/lib/user";
import AdminHeader from "@/components/header/adminHeader";
import {withAuthorisation} from "@/components/withAuthorisation";
import { withAuthorisation } from "@/components/withAuthorisation";
import RegionAutocomplete from "@/components/autocompleteComponents/regionAutocomplete";
import PDFUploader from "@/components/pdfUploader";
import ErrorMessageAlert from "@/components/errorMessageAlert";
import ConfirmationMessage from "@/components/confirmMessage";
import SyndicAutocomplete from "@/components/autocompleteComponents/syndicAutocomplete";
import {handleError} from "@/lib/error";
import {postManual} from "@/lib/building-manual";
import { handleError } from "@/lib/error";
import { postManual } from "@/lib/building-manual";

function AdminDataBuildingsEdit() {
const requiredFieldsNotFilledMessage = "Gelieve alle verplichte velden (*) in te vullen.";
Expand All @@ -35,7 +36,6 @@ function AdminDataBuildingsEdit() {
const [regionId, setRegionId] = useState<number>(-1); //used for collecting the right id to post/patch
const [syndicId, setSyndicId] = useState<number>(-1); //used for collecting the right id to post/patch
const [manual, setManual] = useState<File | null>(null);
// const [duration, setDuration] = useState<string>("00:00");
const [publicId, setPublicId] = useState<string>("");
const [validated, setValidated] = useState<boolean>(false);
const [durationInMinutes, setDurationInMinutes] = useState<number>(0);
Expand Down Expand Up @@ -98,7 +98,7 @@ function AdminDataBuildingsEdit() {
}
}
if (manual) {
await postManual({building: buildingId, file: manual});
await postManual({ building: buildingId, file: manual });
}
setShowConfirmation(true);
} catch (error: any) {
Expand All @@ -124,7 +124,6 @@ function AdminDataBuildingsEdit() {
setPostalCode(res.data.postal_code);
setCity(res.data.city);
setName(res.data.name ? res.data.name : "");
console.log(res.data.duration);
setDurationInMinutes(durationToMinutes(res.data.duration));
setPublicId(res.data.public_id ?? "");
const region = await getRegion(res.data.region);
Expand Down Expand Up @@ -152,19 +151,18 @@ function AdminDataBuildingsEdit() {

return (
<div className="tablepageContainer">
<AdminHeader/>
<Container className="tableContainer" style={{flex: '1'}}>
<AdminHeader />
<Container className="tableContainer" style={{ flex: "1" }}>
<Form id="buildingForm" noValidate validated={validated}>
<Row>
<Col md={6} style={{paddingLeft: '20px'}}>
<Col md={6} style={{ paddingLeft: "20px" }}>
<p className="subtitle">Bewerk gebouw</p>
<ConfirmationMessage
showConfirm={showConfirmation}
confirmMessage={"De informatie voor dit gebouw is opgeslagen!"}
onClose={setShowConfirmation}
/>
<ErrorMessageAlert errorMessages={errorMessages}
setErrorMessages={setErrorMessages}/>
<ErrorMessageAlert errorMessages={errorMessages} setErrorMessages={setErrorMessages} />
<Form.Group controlId="buildingName" className="input">
<Form.Label className="normal_text">Gebouw naam</Form.Label>
<Form.Control
Expand All @@ -184,8 +182,7 @@ function AdminDataBuildingsEdit() {
onChange={(e: ChangeEvent<HTMLInputElement>) => setPostalCode(e.target.value)}
required
/>
<Form.Control.Feedback type="invalid">Vul een postcode
in.</Form.Control.Feedback>
<Form.Control.Feedback type="invalid">Vul een postcode in.</Form.Control.Feedback>
</Form.Group>

<Form.Group controlId="city" className="input">
Expand Down Expand Up @@ -230,9 +227,9 @@ function AdminDataBuildingsEdit() {
onChange={(e: ChangeEvent<HTMLInputElement>) => setBusNumber(e.target.value)}
/>
</Form.Group>
<PDFUploader onUpload={setManual}/>
<PDFUploader onUpload={setManual} />
</Col>
<Col md={6} style={{paddingLeft: '20px'}}>
<Col md={6} style={{ paddingLeft: "20px" }}>
<p className="subtitle"></p>
<Form.Group controlId="clientId" className="input">
<Form.Label className="normal_text">Klantennummer afvalophaaldienst</Form.Label>
Expand All @@ -244,8 +241,7 @@ function AdminDataBuildingsEdit() {
/>
</Form.Group>
<Form.Group controlId="publicId" className="input">
<Form.Label className="normal_text">Publieke identificatie (voor
bewoners)</Form.Label>
<Form.Label className="normal_text">Publieke identificatie (voor bewoners)</Form.Label>
<Form.Control
className="form_control"
type="text"
Expand All @@ -255,8 +251,7 @@ function AdminDataBuildingsEdit() {
</Form.Group>

<Form.Group controlId="duration" className="input">
<Form.Label className="normal_text">Duur van een ronde (in
minuten)*</Form.Label>
<Form.Label className="normal_text">Duur van een ronde (in minuten)*</Form.Label>
<Form.Control
className="form_control"
type="number"
Expand All @@ -271,33 +266,34 @@ function AdminDataBuildingsEdit() {
<Form.Label className="normal_text">Opmerkingen</Form.Label>
<Form.Control
className="form_control"
style={{height: '100px'}}
style={{ height: "100px" }}
as="textarea"
value={buildingComments}
onChange={(e: ChangeEvent<HTMLInputElement>) => setBuildingComments(e.target.value)}
/>
</Form.Group>
<div style={{paddingLeft: '15px', paddingBottom: '15px', maxWidth: "300px", width: '100%'}}>
<RegionAutocomplete
initialId={regionId}
setObjectId={setRegionId}
required={true}
/>
<p style={{paddingTop: '10px'}}/>
<SyndicAutocomplete
initialId={syndicId}
setObjectId={setSyndicId}
required={true}
/>
<div
style={{ paddingLeft: "15px", paddingBottom: "15px", maxWidth: "300px", width: "100%" }}
>
<RegionAutocomplete initialId={regionId} setObjectId={setRegionId} required={true} />
<p style={{ paddingTop: "10px" }} />
<SyndicAutocomplete initialId={syndicId} setObjectId={setSyndicId} required={true} />
</div>
<div style={{paddingTop: '20px'}}>
<Button variant="secondary" className="btn-light" style={{maxWidth: '140px', width: '100%'}}
onClick={goBack}>
<div style={{ paddingTop: "20px" }}>
<Button
variant="secondary"
className="btn-light"
style={{ maxWidth: "140px", width: "100%" }}
onClick={goBack}
>
Terug
</Button>
<Button variant="primary" className="btn-dark"
style={{marginLeft: '20px', maxWidth: '140px', width: '100%'}}
onClick={handleSubmit}>
<Button
variant="primary"
className="btn-dark"
style={{ marginLeft: "20px", maxWidth: "140px", width: "100%" }}
onClick={handleSubmit}
>
Opslaan
</Button>
</div>
Expand Down

0 comments on commit 0c9d9e7

Please sign in to comment.