-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1162 from danskernesdigitalebibliotek/release/her…
…mod-14 Hermod sprint 14
- Loading branch information
Showing
44 changed files
with
553 additions
and
412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/apps/opening-hours-editor/ConfirmEditRepeatedOpeningHour.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import React, { ChangeEvent, FC, useState } from "react"; | ||
import { useText } from "../../core/utils/text"; | ||
|
||
enum OptionValue { | ||
This = "This", | ||
All = "All" | ||
} | ||
|
||
type ConfirmEditRepeatedOpeningHourType = { | ||
title: string; | ||
confirmSubmit: (editSerie: boolean) => void; | ||
closeDialog: () => void; | ||
}; | ||
|
||
const ConfirmEditRepeatedOpeningHour: FC< | ||
ConfirmEditRepeatedOpeningHourType | ||
> = ({ confirmSubmit, closeDialog, title }) => { | ||
const t = useText(); | ||
const options = [ | ||
{ | ||
value: OptionValue.This, | ||
label: t("openingHoursEditEventConfirmOptionThisText"), | ||
cy: "opening-hours-editor-form__radio-this" | ||
}, | ||
{ | ||
value: OptionValue.All, | ||
label: t("openingHoursEditEventConfirmOptionAllText"), | ||
cy: "opening-hours-editor-form__radio-all" | ||
} | ||
]; | ||
|
||
const [selectedOption, setSelectedOption] = useState(options[0].value); | ||
|
||
const handleRadioChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
if ( | ||
event.target.value === OptionValue.This || | ||
event.target.value === OptionValue.All | ||
) { | ||
setSelectedOption(event.target.value); | ||
} | ||
}; | ||
|
||
return ( | ||
<form className="opening-hours-editor-form"> | ||
<h2 className="opening-hours-editor-form__label">{title}</h2> | ||
{options.map(({ value, label, cy }) => ( | ||
<div className="opening-hours-editor-form__radio" key={value}> | ||
<input | ||
data-cy={cy} | ||
type="radio" | ||
id={value} | ||
value={value} | ||
checked={selectedOption === value} | ||
onChange={handleRadioChange} | ||
/> | ||
<label htmlFor={value}>{label}</label> | ||
</div> | ||
))} | ||
<button | ||
className="opening-hours-editor-form__cancel" | ||
data-cy="opening-hours-editor-form__cancel" | ||
type="button" | ||
onClick={() => { | ||
closeDialog(); | ||
setSelectedOption(options[0].value); | ||
}} | ||
> | ||
{t("openingHoursConfirmAddRepeatedCancelText")} | ||
</button> | ||
<button | ||
className="opening-hours-editor-form__submit" | ||
data-cy="opening-hours-editor-form__confirm" | ||
type="button" | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
confirmSubmit(selectedOption === OptionValue.All); | ||
setSelectedOption(options[0].value); | ||
}} | ||
> | ||
{t("openingHoursConfirmRepeatedSubmitText")} | ||
</button> | ||
</form> | ||
); | ||
}; | ||
|
||
export default ConfirmEditRepeatedOpeningHour; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.