implemented search in companies

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-09-02 09:06:35 +02:00
parent 9887f78949
commit 9f4f095023
5 changed files with 69 additions and 9 deletions

View File

@@ -9,6 +9,7 @@
const router = useTinyRouter();
console.log(router);
let bookmarks = $state(null);
let companies = $state(null);
let error = $state(null);
let fulltext = false;
let key = $state(router.getQueryParam('key'));
@@ -39,6 +40,7 @@
body: JSON.stringify(data)
};
fetch(api('bookmark/search'),options).then(handleBookmarks);
fetch(api('company/search'),options).then(handleCompanies);
fetch(api('project/search'),options).then(handleProjects);
fetch(api('task/search'),options).then(handleTasks);
}
@@ -57,6 +59,15 @@
}
}
async function handleCompanies(resp){
if (resp.ok){
const json = await resp.json();
companies = Object.keys(json).length ? json : null;
} else {
error = await resp.text();
}
}
async function handleProjects(resp){
if (resp.ok){
const res = await resp.json();
@@ -140,4 +151,18 @@
{/each}
</ul>
</fieldset>
{/if}
{/if}
{#if companies}
<fieldset>
<legend>
{t('companies')}
</legend>
<ul>
{#each Object.values(companies) as company}
<li>
<a href="#" onclick={e=>go(`/company/${company.id}/view`)} >{company.name}</a>
</li>
{/each}
</ul>
</fieldset>
{/if}