Skip to content

Commit

Permalink
Hotfix banner pls work
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibaud-Collyn committed May 24, 2024
1 parent 9a42e1e commit 0685765
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions frontend/app/[locale]/components/CreateCourseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { DatePicker } from '@mui/x-date-pickers/DatePicker';
import UploadFileIcon from "@mui/icons-material/UploadFile";
import {visuallyHidden} from "@mui/utils";
import dayjs from "dayjs";
import defaultBanner from "../../../public/ugent_banner.png";

const CreateCourseForm = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -49,6 +50,7 @@ const CreateCourseForm = () => {
formData.append('description', description);
formData.append('open_course', open.toString());
formData.append('year', year.toString());

const fileReader = new FileReader();
fileReader.onload = async function () {
const arrayBuffer = this.result;
Expand All @@ -57,8 +59,12 @@ const CreateCourseForm = () => {
await postData("/courses/", formData).then((response) => {
window.location.href = `/course/${response.course_id}`;
});
return;
}
}
await postData("/courses/", formData).then((response) => {
window.location.href = `/course/${response.course_id}`;
});
if (selectedImage) fileReader.readAsArrayBuffer(selectedImage);
};

Expand All @@ -68,7 +74,7 @@ const CreateCourseForm = () => {
.then(response => response.blob())
.then(blob => {
const file = new File([blob], "filename", {type: "image/png"});
setSelectedImage(file);

setSelectedImageURL(banner.src)
})
}
Expand Down Expand Up @@ -142,7 +148,7 @@ const CreateCourseForm = () => {
<Box
component={'img'}
alt={t('select image')}
src={selectedImageURL}
src={selectedImageURL ? selectedImageURL : defaultBanner.src}
sx={{
borderRadius: '16px',
height: 'fit-content',
Expand Down
3 changes: 2 additions & 1 deletion frontend/app/[locale]/components/EditCourseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {DatePicker} from '@mui/x-date-pickers/DatePicker';
import {visuallyHidden} from '@mui/utils';
import UploadFileIcon from '@mui/icons-material/UploadFile';
import dayjs from "dayjs";
import defaultBanner from "../../../public/ugent_banner.png";

interface EditCourseFormProps {
courseId: number
Expand Down Expand Up @@ -167,7 +168,7 @@ const EditCourseForm = ({courseId}: EditCourseFormProps) => {
<Box
component={'img'}
alt={t('select image')}
src={selectedImageURL}
src={selectedImageURL ? selectedImageURL : defaultBanner.src}
sx={{
borderRadius: '16px',
height: 'fit-content',
Expand Down

0 comments on commit 0685765

Please sign in to comment.