Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ const EditModulePage = () => {
loading={mutationLoading}
submitText="Save"
isEdit
minDate={
data?.getProgram?.startedAt ? formatDateForInput(data.getProgram.startedAt) : undefined
}
maxDate={data?.getProgram?.endedAt ? formatDateForInput(data.getProgram.endedAt) : undefined}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
GetProgramAndModulesDocument,
} from 'types/__generated__/programsQueries.generated'
import type { ExtendedSession } from 'types/auth'
import { formatDateForInput } from 'utils/dateFormatter'
import { parseCommaSeparated } from 'utils/parser'
import LoadingSpinner from 'components/LoadingSpinner'
import ModuleForm from 'components/ModuleForm'
Expand Down Expand Up @@ -168,6 +169,16 @@ const CreateModulePage = () => {
onSubmit={handleSubmit}
loading={mutationLoading}
isEdit={false}
minDate={
programData?.getProgram?.startedAt
? formatDateForInput(programData.getProgram.startedAt)
: undefined
}
maxDate={
programData?.getProgram?.endedAt
? formatDateForInput(programData.getProgram.endedAt)
: undefined
}
/>
)
}
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/components/ModuleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ interface ModuleFormProps {
isEdit?: boolean
title: string
submitText?: string
minDate?: string
maxDate?: string
}

const EXPERIENCE_LEVELS = [
Expand All @@ -58,6 +60,8 @@ const ModuleForm = ({
title,
isEdit,
submitText = 'Save',
minDate,
maxDate,
}: ModuleFormProps) => {
const [touched, setTouched] = useState<Record<string, boolean>>({})

Expand Down Expand Up @@ -213,6 +217,8 @@ const ModuleForm = ({
error={errors.startedAt}
touched={touched.startedAt}
required
min={minDate}
max={maxDate}
/>
<FormDateInput
id="module-end-date"
Expand All @@ -225,7 +231,8 @@ const ModuleForm = ({
error={errors.endedAt}
touched={touched.endedAt}
required
min={formData.startedAt || undefined}
min={formData.startedAt || minDate || undefined}
max={maxDate}
/>
<div className="w-full min-w-0" style={{ maxWidth: '100%', overflow: 'hidden' }}>
<Select
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/forms/shared/FormDateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface FormDateInputProps {
touched?: boolean
required?: boolean
min?: string
max?: string
}

export const FormDateInput = ({
Expand All @@ -31,6 +32,7 @@ export const FormDateInput = ({
touched,
required = false,
min,
max,
}: FormDateInputProps) => {
return (
<div className="w-full min-w-0" style={{ maxWidth: '100%', overflow: 'hidden' }}>
Expand All @@ -45,6 +47,7 @@ export const FormDateInput = ({
isInvalid={touched && !!error}
errorMessage={touched ? error : undefined}
min={min}
max={max}
classNames={COMMON_INPUT_CLASS_NAMES}
/>
</div>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/server/queries/moduleQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export const GET_PROGRAM_ADMINS_AND_MODULES = gql`
query GetProgramAdminsAndModules($programKey: String!, $moduleKey: String!) {
getProgram(programKey: $programKey) {
id
startedAt
endedAt
admins {
id
login
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/server/queries/programsQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export const GET_PROGRAM_ADMIN_DETAILS = gql`
id
key
name
startedAt
endedAt
admins {
id
login
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/types/__generated__/moduleQueries.generated.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading