mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2026-04-30 18:49:09 +00:00
switched to svelte 5
front gets a bit to complex to do in vanilla
This commit is contained in:
@@ -1,26 +1,9 @@
|
||||
import './style.css'
|
||||
import { IDMap, Name, requestMappings } from './idMapping'
|
||||
import { mount } from "svelte"
|
||||
import "./app.css"
|
||||
import App from "./App.svelte"
|
||||
|
||||
function createTableRow(a: string, b: string, c: string): HTMLTableRowElement {
|
||||
const tr = document.createElement('tr');
|
||||
[a, b, c].forEach(value => {
|
||||
const td = document.createElement('td');
|
||||
td.textContent = value;
|
||||
tr.appendChild(td);
|
||||
});
|
||||
return tr;
|
||||
}
|
||||
|
||||
function orderByFirstName(obj: IDMap): { id: string, name: Name }[] {
|
||||
return Object.entries(obj)
|
||||
.sort(([, a], [, b]) => a.first.localeCompare(b.first))
|
||||
.map(([id, { first, last }]) => ({ id, name: { first, last } }));
|
||||
}
|
||||
|
||||
requestMappings().then(r => {
|
||||
orderByFirstName(r.id_map).forEach(e => {
|
||||
let row = createTableRow(e.id, e.name.last, e.name.first);
|
||||
document.querySelector("#mappingTable")?.appendChild(row);
|
||||
})
|
||||
const app = mount(App, {
|
||||
target: document.getElementById('app')!,
|
||||
})
|
||||
|
||||
export default app
|
||||
|
||||
Reference in New Issue
Block a user