isPractice hotfix

This commit is contained in:
Carlos-Mesquita
2024-11-12 17:53:16 +00:00
parent 311036fe86
commit 153d7f5448
21 changed files with 109 additions and 28 deletions

View File

@@ -18,12 +18,12 @@ const SectionPicker: React.FC<Props> = ({
updateLocalAndScheduleGlobal
}) => {
const { dispatch } = useExamEditorStore();
const [selectedValue, setSelectedValue] = React.useState<number | null>(null);
const [selectedValue, setSelectedValue] = React.useState<number | undefined>(undefined);
const sectionState = useExamEditorStore(state =>
state.modules["level"].sections.find((s) => s.sectionId === sectionId)
);
if (sectionState === undefined) return null;
const { readingSection, listeningSection } = sectionState;
@@ -32,14 +32,16 @@ const SectionPicker: React.FC<Props> = ({
const openPicker = module === "reading" ? "isReadingPickerOpen" : "isListeningPickerOpen";
const handleSectionChange = (value: number) => {
setSelectedValue(value);
const newValue = currentValue === value ? undefined : value;
setSelectedValue(newValue);
dispatch({
type: "UPDATE_SECTION_SINGLE_FIELD",
payload: {
sectionId,
module: "level",
field: module === "reading" ? "readingSection" : "listeningSection",
value: value
value: newValue
}
});
};
@@ -67,17 +69,19 @@ const SectionPicker: React.FC<Props> = ({
className={`
flex items-center space-x-3 font-semibold cursor-pointer p-2 rounded
transition-colors duration-200
${currentValue === num
${currentValue === num
? `bg-ielts-${module}/90 text-white`
: `hover:bg-ielts-${module}/70 text-gray-700`}
`}
onClick={(e) => {
e.preventDefault();
handleSectionChange(num);
}}
>
<input
type="radio"
name={`${module === "reading" ? 'passage' : 'section'}-${sectionId}`}
value={num}
type="checkbox"
checked={currentValue === num}
onChange={() => handleSectionChange(num)}
onChange={() => {}}
className={`
h-5 w-5 cursor-pointer
accent-ielts-${module}
@@ -95,4 +99,4 @@ const SectionPicker: React.FC<Props> = ({
);
};
export default SectionPicker;
export default SectionPicker;