code cleanup
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import { onMount } from 'svelte';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import TypeSelector from './TypeSelector.svelte';
|
||||
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
import TypeSelector from './TypeSelector.svelte';
|
||||
|
||||
|
||||
|
||||
let error = null;
|
||||
let companies = {};
|
||||
let documents = null;
|
||||
let error = null;
|
||||
let companies = {};
|
||||
let company_id = +router.query.company_id;
|
||||
let documents = null;
|
||||
let router = useTinyRouter();
|
||||
let docType = 0;
|
||||
let selected_company = null;
|
||||
let router = useTinyRouter();
|
||||
let company_id = +router.query.company_id;
|
||||
let docType = 0;
|
||||
|
||||
async function loadCompanies(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/company/list`;
|
||||
const url = api('company/list');
|
||||
const resp = await fetch(url,{ credentials: 'include'});
|
||||
if (resp.ok){
|
||||
companies = await resp.json();
|
||||
@@ -37,7 +40,7 @@
|
||||
async function load(company){
|
||||
router.navigate(`/document?company_id=${company.id}`);
|
||||
selected_company = company;
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/list`;
|
||||
const url = api('document/list');
|
||||
const resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
@@ -60,7 +63,7 @@
|
||||
|
||||
async function deleteDoc(ev,doc){
|
||||
if (confirm(t('really_delete',doc.number))){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${doc.id}`;
|
||||
const url = api(`document/${doc.id}`;
|
||||
const resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'DELETE'
|
||||
@@ -122,4 +125,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
|
||||
Reference in New Issue
Block a user