-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Unable to edit time_bound access codes #656
Changes from 6 commits
cbde03b
ed70f00
503245b
96791cc
5917d95
14c81db
dc6a06d
1414939
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -80,12 +80,12 @@ function Content({ | |||||||||
} | ||||||||||
|
||||||||||
const start = startDate.toISO() | ||||||||||
if (start == null) { | ||||||||||
if (start === null || start === undefined) { | ||||||||||
throw new Error(`Invalid start date: ${startDate.invalidReason}`) | ||||||||||
} | ||||||||||
|
||||||||||
const end = endDate.toISO() | ||||||||||
if (end == null) { | ||||||||||
if (end === null || end === undefined) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
throw new Error(`Invalid end date: ${endDate.invalidReason}`) | ||||||||||
} | ||||||||||
|
||||||||||
|
@@ -172,8 +172,7 @@ function Content({ | |||||||||
? t.codeLengthRequirement(codeLengthRequirement) | ||||||||||
: null | ||||||||||
|
||||||||||
const hasCodeInputs = | ||||||||||
accessCode?.type !== 'time_bound' || accessCode.is_offline_access_code | ||||||||||
const hasCodeInputs = accessCode?.type !== 'time_bound' | ||||||||||
|
||||||||||
return ( | ||||||||||
<> | ||||||||||
|
@@ -206,81 +205,83 @@ function Content({ | |||||||||
}} | ||||||||||
/> | ||||||||||
</FormField> | ||||||||||
{hasCodeInputs && ( | ||||||||||
<> | ||||||||||
<FormField className='seam-code-field'> | ||||||||||
<InputLabel>{t.codeInputLabel}</InputLabel> | ||||||||||
<TextField | ||||||||||
size='large' | ||||||||||
clearable | ||||||||||
hasError={hasCodeError} | ||||||||||
helperText={responseErrors?.code ?? errors.code?.message} | ||||||||||
inputProps={{ | ||||||||||
...register('code', { | ||||||||||
required: t.codeRequiredError, | ||||||||||
validate: (value: string) => | ||||||||||
validateCodeLength(device, value), | ||||||||||
}), | ||||||||||
}} | ||||||||||
/> | ||||||||||
<div | ||||||||||
className={classNames('seam-bottom', { | ||||||||||
'has-hints': codeLengthRequirementMessage != null, | ||||||||||
})} | ||||||||||
> | ||||||||||
{codeLengthRequirementMessage != null && ( | ||||||||||
<ul | ||||||||||
className={classNames('seam-requirements', { | ||||||||||
'seam-error': hasCodeError, | ||||||||||
})} | ||||||||||
> | ||||||||||
<li>{codeLengthRequirementMessage}</li> | ||||||||||
<li>{t.codeNumbersOnlyRequirement}</li> | ||||||||||
</ul> | ||||||||||
)} | ||||||||||
<Button | ||||||||||
size='small' | ||||||||||
onMouseDown={(e) => { | ||||||||||
e.preventDefault() // Disable stealing input focus | ||||||||||
handleGenerateCode() | ||||||||||
{hasCodeInputs !== null && | ||||||||||
hasCodeInputs !== undefined && | ||||||||||
hasCodeInputs && ( | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's redundant, I have removed it now |
||||||||||
<> | ||||||||||
<FormField className='seam-code-field'> | ||||||||||
<InputLabel>{t.codeInputLabel}</InputLabel> | ||||||||||
<TextField | ||||||||||
size='large' | ||||||||||
clearable | ||||||||||
hasError={hasCodeError} | ||||||||||
helperText={responseErrors?.code ?? errors.code?.message} | ||||||||||
inputProps={{ | ||||||||||
...register('code', { | ||||||||||
required: t.codeRequiredError, | ||||||||||
validate: (value: string) => | ||||||||||
validateCodeLength(device, value), | ||||||||||
}), | ||||||||||
}} | ||||||||||
disabled={isGeneratingCode} | ||||||||||
/> | ||||||||||
<div | ||||||||||
className={classNames('seam-bottom', { | ||||||||||
'has-hints': codeLengthRequirementMessage != null, | ||||||||||
})} | ||||||||||
> | ||||||||||
{t.codeGenerateButton} | ||||||||||
</Button> | ||||||||||
</div> | ||||||||||
</FormField> | ||||||||||
<FormField> | ||||||||||
<InputLabel>{t.timingInputLabel}</InputLabel> | ||||||||||
<RadioField | ||||||||||
value={type} | ||||||||||
onChange={setType} | ||||||||||
name='type' | ||||||||||
options={[ | ||||||||||
{ | ||||||||||
label: t.typeOngoingLabel, | ||||||||||
value: 'ongoing', | ||||||||||
}, | ||||||||||
{ | ||||||||||
label: t.typeTimeBoundLabel, | ||||||||||
value: 'time_bound', | ||||||||||
}, | ||||||||||
]} | ||||||||||
/> | ||||||||||
<> | ||||||||||
{type === 'time_bound' && ( | ||||||||||
<AccessCodeFormTimes | ||||||||||
startDate={startDate} | ||||||||||
endDate={endDate} | ||||||||||
onEdit={() => { | ||||||||||
setDatePickerVisible(true) | ||||||||||
{codeLengthRequirementMessage != null && ( | ||||||||||
<ul | ||||||||||
className={classNames('seam-requirements', { | ||||||||||
'seam-error': hasCodeError, | ||||||||||
})} | ||||||||||
> | ||||||||||
<li>{codeLengthRequirementMessage}</li> | ||||||||||
<li>{t.codeNumbersOnlyRequirement}</li> | ||||||||||
</ul> | ||||||||||
)} | ||||||||||
<Button | ||||||||||
size='small' | ||||||||||
onMouseDown={(e) => { | ||||||||||
e.preventDefault() // Disable stealing input focus | ||||||||||
handleGenerateCode() | ||||||||||
}} | ||||||||||
/> | ||||||||||
)} | ||||||||||
</> | ||||||||||
</FormField> | ||||||||||
</> | ||||||||||
)} | ||||||||||
disabled={isGeneratingCode} | ||||||||||
> | ||||||||||
{t.codeGenerateButton} | ||||||||||
</Button> | ||||||||||
</div> | ||||||||||
</FormField> | ||||||||||
<FormField> | ||||||||||
<InputLabel>{t.timingInputLabel}</InputLabel> | ||||||||||
<RadioField | ||||||||||
value={type} | ||||||||||
onChange={setType} | ||||||||||
name='type' | ||||||||||
options={[ | ||||||||||
{ | ||||||||||
label: t.typeOngoingLabel, | ||||||||||
value: 'ongoing', | ||||||||||
}, | ||||||||||
{ | ||||||||||
label: t.typeTimeBoundLabel, | ||||||||||
value: 'time_bound', | ||||||||||
}, | ||||||||||
]} | ||||||||||
/> | ||||||||||
<> | ||||||||||
{type === 'time_bound' && ( | ||||||||||
<AccessCodeFormTimes | ||||||||||
startDate={startDate} | ||||||||||
endDate={endDate} | ||||||||||
onEdit={() => { | ||||||||||
setDatePickerVisible(true) | ||||||||||
}} | ||||||||||
/> | ||||||||||
)} | ||||||||||
</> | ||||||||||
</FormField> | ||||||||||
</> | ||||||||||
)} | ||||||||||
{responseErrors?.unknown != null && ( | ||||||||||
<div className='seam-unknown-error'>{responseErrors?.unknown}</div> | ||||||||||
)} | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.