Fixes #3 [FE][Certs] Force users to select a denomination if available
This commit is contained in:
parent
5c9acd9246
commit
2d18349d5b
@ -21,6 +21,16 @@ export function ManualRegistration(props: {
|
||||
|
||||
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) => {
|
||||
ev.preventDefault();
|
||||
|
||||
@ -30,6 +40,15 @@ export function ManualRegistration(props: {
|
||||
return;
|
||||
}
|
||||
|
||||
if (courseHasCustomLabel() && customLabel() === "") {
|
||||
setError("Escoge una denominación");
|
||||
|
||||
console.log(error());
|
||||
|
||||
setTimeout(() => setError(""), 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
const date = datePicker.value;
|
||||
|
||||
if (subject === null) {
|
||||
@ -57,16 +76,6 @@ export function ManualRegistration(props: {
|
||||
setCustomLabel("");
|
||||
};
|
||||
|
||||
const courseHasCustomLabel = () => {
|
||||
const courseId = selectedCourseId();
|
||||
if (courseId === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const course = courseMap()[courseId];
|
||||
return course?.course_has_custom_label === true;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<form onsubmit={register}>
|
||||
@ -112,8 +121,7 @@ export function ManualRegistration(props: {
|
||||
/>
|
||||
|
||||
<p
|
||||
class="my-2 p-1 w-fit mx-4 text-c-error inline-block"
|
||||
// style={{opacity: error() === "" ? "0" : "1", "user-select": "none"}}
|
||||
class="my-2 p-1 w-fit mx-4 text-c-error inline-block bg-c-background relative z-10"
|
||||
>
|
||||
{error()}
|
||||
</p>
|
||||
|
Loading…
Reference in New Issue
Block a user