Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Oct 12, 2023
1 parent b6596e0 commit 937b517
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
14 changes: 9 additions & 5 deletions services/main-frontend/src/components/forms/NewCourseForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from "@emotion/css"
import styled from "@emotion/styled"
import React, { useState } from "react"
import React, { useRef, useState } from "react"
import { useTranslation } from "react-i18next"

import { Course, NewCourse } from "../../shared-module/bindings"
Expand Down Expand Up @@ -53,6 +53,7 @@ const NewCourseForm: React.FC<React.PropsWithChildren<NewCourseFormProps>> = ({
const [submitDisabled, setSubmitDisabled] = useState(false)
const [error, setError] = useState<string | null>(null)
const [copyCourseUserPermissions, setCopyUserCoursePermissions] = useState<boolean>(false)
const formRef = useRef<HTMLFormElement>(null)

const handleDuplicateMenu = (e: string, coursesData: Course[]) => {
const findCourse = coursesData.find((course) => course.id === e)
Expand Down Expand Up @@ -131,6 +132,9 @@ const NewCourseForm: React.FC<React.PropsWithChildren<NewCourseFormProps>> = ({

const mutation = useToastMutation(
() => {
if (formRef.current && !formRef.current?.checkValidity()) {
return Promise.reject()
}
if (createDuplicate) {
return handleCreateNewLanguageVersion()
}
Expand All @@ -149,9 +153,9 @@ const NewCourseForm: React.FC<React.PropsWithChildren<NewCourseFormProps>> = ({
}

return (
<div
<form
ref={formRef}
className={css`
width: 500px;
padding: 1rem 0;
`}
>
Expand Down Expand Up @@ -192,6 +196,7 @@ const NewCourseForm: React.FC<React.PropsWithChildren<NewCourseFormProps>> = ({
<TextField
required
label={t("teacher-in-charge-email")}
type="email"
value={teacherInChargeEmail}
onChangeByValue={(value) => {
setTeacherInChargeEmail(value)
Expand All @@ -200,7 +205,6 @@ const NewCourseForm: React.FC<React.PropsWithChildren<NewCourseFormProps>> = ({
</FieldContainer>
<FieldContainer>
<TextArea
required
label={t("text-field-label-description")}
value={description}
onChangeByValue={(value) => {
Expand Down Expand Up @@ -335,7 +339,7 @@ const NewCourseForm: React.FC<React.PropsWithChildren<NewCourseFormProps>> = ({
{t("button-text-close")}
</Button>
</div>
</div>
</form>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const UpdateCourseForm: React.FC<React.PropsWithChildren<UpdateCourseFormProps>>
return (
<div
className={css`
width: 500px;
padding: 1rem 0;
`}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const LinearProgress = styled.div<LinearProgressProps>`
${respondToOrLarger.sm} {
height: ${({ height }) => (height === "small" ? "16px" : "28px")};
/* width: 500px; */
width: 100%;
}
`
Expand Down

0 comments on commit 937b517

Please sign in to comment.