Fix of errors: automatic and some manual

This commit is contained in:
2024-11-04 19:56:03 +01:00
parent 90798b12e5
commit f05c25853c
41 changed files with 101 additions and 148 deletions

View File

@@ -37,7 +37,7 @@ export const ISOToDate = (str: string|null): Date|null => {
return null;
}
let
const
[year, month, day] = str.split('-').map(p => parseInt(p));
return new Date(year, month-1, day, 0, 0, 0, 0);
@@ -52,7 +52,7 @@ export const ISOToDatetime = (str: string|null): Date|null => {
return null;
}
let
const
[cal, times] = str.split('T'),
[year, month, date] = cal.split('-').map(s => parseInt(s)),
[time, timezone] = times.split(times.charAt(8)),
@@ -91,7 +91,7 @@ export const datetimeToISO = (date: Date): string => {
Math.abs(date.getTimezoneOffset() % 60).toString().padStart(2, '0'),
].join('');
let x = cal + 'T' + time + offset;
const x = cal + 'T' + time + offset;
return x;
};

View File

@@ -1,11 +1,9 @@
import {Scope} from '../../types';
export type body = {[key: string]: boolean|string|number|null};
export type fetchOption = {[key: string]: boolean|string|number|null};
export type body = Record<string, boolean|string|number|null>;
export type fetchOption = Record<string, boolean|string|number|null>;
export interface Params {
[key: string]: number|string
}
export type Params = Record<string, number|string>;
export interface PaginationResponse<T> {
pagination: {
@@ -16,9 +14,7 @@ export interface PaginationResponse<T> {
count: number;
}
export interface FetchParams {
[K: string]: string|number|null;
};
export type FetchParams = Record<string, string|number|null>;;
export interface TransportExceptionInterface {
name: string;
@@ -118,15 +114,15 @@ export const makeFetch = <Input, Output>(
* Fetch results with certain parameters
*/
function _fetchAction<T>(page: number, uri: string, params?: FetchParams): Promise<PaginationResponse<T>> {
const item_per_page: number = 50;
const item_per_page = 50;
let searchParams = new URLSearchParams();
const searchParams = new URLSearchParams();
searchParams.append('item_per_page', item_per_page.toString());
searchParams.append('page', page.toString());
if (params !== undefined) {
Object.keys(params).forEach(key => {
let v = params[key];
const v = params[key];
if (typeof v === 'string') {
searchParams.append(key, v);
} else if (typeof v === 'number') {
@@ -137,7 +133,7 @@ function _fetchAction<T>(page: number, uri: string, params?: FetchParams): Promi
});
}
let url = uri + '?' + searchParams.toString();
const url = uri + '?' + searchParams.toString();
return fetch(url, {
method: 'GET',
@@ -177,7 +173,7 @@ function _fetchAction<T>(page: number, uri: string, params?: FetchParams): Promi
export const fetchResults = async<T> (uri: string, params?: FetchParams): Promise<T[]> => {
let promises: Promise<T[]>[] = [],
page = 1;
let firstData: PaginationResponse<T> = await _fetchAction(page, uri, params) as PaginationResponse<T>;
const firstData: PaginationResponse<T> = await _fetchAction(page, uri, params) as PaginationResponse<T>;
promises.push(Promise.resolve(firstData.results));

View File

@@ -41,7 +41,7 @@ export class CollectionEventPayload {
}
export const handleAdd = (button: any): void => {
let
const
form_name = button.dataset.collectionAddTarget,
prototype = button.dataset.formPrototype,
collection: HTMLUListElement | null = document.querySelector('ul[data-collection-name="' + form_name + '"]');
@@ -50,7 +50,7 @@ export const handleAdd = (button: any): void => {
return;
}
let
const
empty_explain: HTMLLIElement | null = collection.querySelector('li[data-collection-empty-explain]'),
entry = document.createElement('li'),
counter = collection.querySelectorAll('li.entry').length, // Updated counter logic
@@ -85,7 +85,7 @@ const initializeRemove = (collection: HTMLUListElement, entry: HTMLLIElement): v
export const buildRemoveButton = (collection: HTMLUListElement, entry: HTMLLIElement): HTMLButtonElement|null => {
let
const
button = document.createElement('button'),
isPersisted = entry.dataset.collectionIsPersisted || '',
content = collection.dataset.collectionButtonRemoveLabel || '',
@@ -108,19 +108,19 @@ export const buildRemoveButton = (collection: HTMLUListElement, entry: HTMLLIEle
}
window.addEventListener('load', () => {
let
const
addButtons: NodeListOf<HTMLButtonElement> = document.querySelectorAll("button[data-collection-add-target]"),
collections: NodeListOf<HTMLUListElement> = document.querySelectorAll("ul[data-collection-regular]");
for (let i = 0; i < addButtons.length; i++) {
let addButton = addButtons[i];
const addButton = addButtons[i];
addButton.addEventListener('click', (e: Event) => {
e.preventDefault();
handleAdd(e.target);
});
}
for (let i = 0; i < collections.length; i++) {
let entries: NodeListOf<HTMLLIElement> = collections[i].querySelectorAll(':scope > li');
const entries: NodeListOf<HTMLLIElement> = collections[i].querySelectorAll(':scope > li');
for (let j = 0; j < entries.length; j++) {
if (entries[j].dataset.collectionEmptyExplain === "1") {
continue;

View File

@@ -47,7 +47,7 @@ export interface UserAssociatedInterface {
id: number;
};
export type TranslatableString = {
export interface TranslatableString {
fr?: string;
nl?: string;
}
@@ -59,7 +59,7 @@ export interface Postcode {
center: Point;
}
export type Point = {
export interface Point {
type: "Point";
coordinates: [lat: number, lon: number];
}

View File

@@ -32,9 +32,7 @@ const data: AddressModalData = reactive({
const props = defineProps<AddressModalContentProps>();
const emit = defineEmits<{
(e: 'update-address', value: Address): void
}>();
const emit = defineEmits<(e: 'update-address', value: Address) => void>();
const address_modal = ref<InstanceType<typeof AddressModal> | null>(null);

View File

@@ -18,9 +18,7 @@ interface AddressModalContentProps {
const props = defineProps<AddressModalContentProps>();
const emit = defineEmits<{
(e: 'update-address', value: Address): void
}>();
const emit = defineEmits<(e: 'update-address', value: Address) => void>();
const onUpdateAddress = (address: Address): void => {
emit('update-address', address);

View File

@@ -27,9 +27,7 @@ interface AddressModalState {
const props = defineProps<AddressModalProps>();
const emit = defineEmits<{
(e: 'update-address', value: Address): void
}>();
const emit = defineEmits<(e: 'update-address', value: Address) => void>();
const state: AddressModalState = reactive({show_modal: false});

View File

@@ -53,9 +53,7 @@ export interface AddressDetailsRefMatchingProps {
const props = defineProps<AddressDetailsRefMatchingProps>();
const emit = defineEmits<{
(e: 'update-address', value: Address): void
}>();
const emit = defineEmits<(e: 'update-address', value: Address) => void>();
const applyUpdate = async () => {
const new_address = await syncAddressWithReference(props.address);