[FE][Certs] Add an indicator that all certs have been downloaded
This commit is contained in:
parent
fe3541ac4c
commit
8ccc53fd27
@ -32,8 +32,8 @@ export function Registers(props: {person: Person | null, count: number}) {
|
|||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
setRegisters(response.data.Ok);
|
setRegisters(response.data.Ok);
|
||||||
} else {
|
} else {
|
||||||
console.error(response.data.Err);
|
console.error(response.data.Error);
|
||||||
setError(response.data.Err.reason);
|
setError(response.data.Error.reason);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -101,20 +101,29 @@ export function Registers(props: {person: Person | null, count: number}) {
|
|||||||
?.filter((r) => r.register_creation_date === today) ?? [];
|
?.filter((r) => r.register_creation_date === today) ?? [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const [downButtonBg, setDownButtonBg] = createSignal("bg-c-primary text-c-on-primary");
|
||||||
const downloadTodayCerts = () => {
|
const downloadTodayCerts = () => {
|
||||||
if (props.person === null) return;
|
if (props.person === null) return;
|
||||||
|
|
||||||
todayRegisters().forEach((register) => {
|
todayRegisters().forEach((register) => {
|
||||||
generateCert(props.person!, register);
|
generateCert(props.person!, register);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setDownButtonBg("bg-c-success text-c-on-success");
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setDownButtonBg("bg-c-primary text-c-on-primary");
|
||||||
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="m-4 p-4 rounded-md relative">
|
<div class="m-4 p-4 rounded-md relative">
|
||||||
<h3 class="text-xl font-medium">
|
<h3 class="text-xl font-medium">
|
||||||
<button
|
<button
|
||||||
class="bg-c-primary text-c-on-primary inline-block mr-2 rounded-full
|
class={`${downButtonBg()} inline-block mr-2 rounded-full transition-colors
|
||||||
disabled:opacity-25 disabled:cursor-not-allowed px-2"
|
disabled:opacity-25 disabled:cursor-not-allowed px-2`}
|
||||||
disabled={todayRegisters().length === 0}
|
disabled={todayRegisters().length === 0}
|
||||||
title="Descargar todos los cert. creados hoy"
|
title="Descargar todos los cert. creados hoy"
|
||||||
onclick={downloadTodayCerts}
|
onclick={downloadTodayCerts}
|
||||||
@ -276,7 +285,7 @@ function generateCert(person: Person, register: Register) {
|
|||||||
|
|
||||||
const generator = certGenerator[courseN];
|
const generator = certGenerator[courseN];
|
||||||
if (generator === undefined) {
|
if (generator === undefined) {
|
||||||
alert(`Generator function with key \`${courseN}\` not found`);
|
alert(`El cert \`${courseN}\` no está implementado`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user