[FE][Certs] Refresh register list on add

This commit is contained in:
Araozu 2023-08-30 16:02:32 -05:00
parent 3734c49084
commit b458eeedd2
2 changed files with 10 additions and 3 deletions

View File

@ -5,10 +5,13 @@ import { Register } from "../../types/Register";
import { courseMap } from "../../utils/allCourses"; import { courseMap } from "../../utils/allCourses";
import { certGenerator } from "../../certGenerator"; import { certGenerator } from "../../certGenerator";
export function Registers(props: {person: Person | null}) { export function Registers(props: {person: Person | null, count: number}) {
const [registers, setRegisters] = createSignal<Array<Register>>([]); const [registers, setRegisters] = createSignal<Array<Register>>([]);
createEffect(async() => { createEffect(async() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _count = props.count;
if (props.person === null) { if (props.person === null) {
setRegisters([]); setRegisters([]);
return; return;

View File

@ -6,12 +6,16 @@ import { Person } from "../types/Person";
export function Certs() { export function Certs() {
const [person, setPerson] = createSignal<Person | null>(null); const [person, setPerson] = createSignal<Person | null>(null);
const [count, setCount] = createSignal(0);
return ( return (
<div class="grid grid-cols-[16rem_25rem_1fr]"> <div class="grid grid-cols-[16rem_25rem_1fr]">
<Search setPerson={setPerson} /> <Search setPerson={setPerson} />
<NewRegister personId={person()?.person_id ?? -1} onSuccess={() => {}} /> <NewRegister
<Registers person={person()} /> personId={person()?.person_id ?? -1}
onSuccess={() => setCount((x) => x + 1)}
/>
<Registers person={person()} count={count()} />
</div> </div>
); );
} }