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