cleaning up javascript code
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { onMount } from 'svelte';
|
||||
import { useTinyRouter } from 'svelte-tiny-router';
|
||||
import ContactSelector from '../../Components/ContactSelector.svelte';
|
||||
|
||||
let router = useTinyRouter();
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
import ContactSelector from '../../Components/ContactSelector.svelte';
|
||||
|
||||
let company = $state(null);
|
||||
let error = $state(null);
|
||||
let docType = $state(null);
|
||||
let error = $state(null);
|
||||
let router = useTinyRouter();
|
||||
|
||||
let document = $state({
|
||||
type : +router.query.document_type,
|
||||
customer : {
|
||||
@@ -20,11 +24,11 @@
|
||||
});
|
||||
|
||||
async function loadCompanies(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/company/list`;
|
||||
var resp = await fetch(url,{ credentials: 'include'});
|
||||
const url = api('company/list');
|
||||
const resp = await fetch(url,{ credentials: 'include'});
|
||||
if (resp.ok){
|
||||
const companies = await resp.json();
|
||||
company = companies[document.sender.company];
|
||||
const companies = await resp.json();
|
||||
company = companies[document.sender.company];
|
||||
document.sender.name = '';
|
||||
if (company.name) document.sender.name += company.name+"\n";
|
||||
if (company.address) document.sender.name += company.address+"\n";
|
||||
@@ -37,8 +41,8 @@
|
||||
}
|
||||
|
||||
async function loadDocType(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/types`;
|
||||
var resp = await fetch(url,{ credentials: 'include'});
|
||||
const url = api('document/types');
|
||||
const resp = await fetch(url,{ credentials: 'include'});
|
||||
if (resp.ok){
|
||||
const types = await resp.json();
|
||||
docType = t('type_'+types[document.type]);
|
||||
@@ -69,7 +73,7 @@
|
||||
}
|
||||
|
||||
async function submit(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document`;
|
||||
const url = api('document');
|
||||
const resp = await fetch(url,{
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
|
||||
Reference in New Issue
Block a user