Fixes #3 [FE][Certs] Force users to select a denomination if available

This commit is contained in:
Araozu 2023-09-20 11:20:04 -05:00
parent 5c9acd9246
commit 2d18349d5b

View File

@ -21,6 +21,16 @@ export function ManualRegistration(props: {
let datePicker: HTMLInputElement | undefined; let datePicker: HTMLInputElement | undefined;
const courseHasCustomLabel = () => {
const courseId = selectedCourseId();
if (courseId === null) {
return false;
}
const course = courseMap()[courseId];
return course?.course_has_custom_label === true;
};
const register: HTMLEventFn = async(ev) => { const register: HTMLEventFn = async(ev) => {
ev.preventDefault(); ev.preventDefault();
@ -30,6 +40,15 @@ export function ManualRegistration(props: {
return; return;
} }
if (courseHasCustomLabel() && customLabel() === "") {
setError("Escoge una denominación");
console.log(error());
setTimeout(() => setError(""), 5000);
return;
}
const date = datePicker.value; const date = datePicker.value;
if (subject === null) { if (subject === null) {
@ -57,16 +76,6 @@ export function ManualRegistration(props: {
setCustomLabel(""); setCustomLabel("");
}; };
const courseHasCustomLabel = () => {
const courseId = selectedCourseId();
if (courseId === null) {
return false;
}
const course = courseMap()[courseId];
return course?.course_has_custom_label === true;
};
return ( return (
<> <>
<form onsubmit={register}> <form onsubmit={register}>
@ -112,8 +121,7 @@ export function ManualRegistration(props: {
/> />
<p <p
class="my-2 p-1 w-fit mx-4 text-c-error inline-block" class="my-2 p-1 w-fit mx-4 text-c-error inline-block bg-c-background relative z-10"
// style={{opacity: error() === "" ? "0" : "1", "user-select": "none"}}
> >
{error()}&nbsp; {error()}&nbsp;
</p> </p>