fix more lint errors

This commit is contained in:
Ulf Gebhardt 2024-10-29 10:46:14 +01:00
parent d115a1331b
commit 95f108c2f7
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
21 changed files with 49 additions and 49 deletions

View File

@ -94,7 +94,7 @@ export const Layer = ({
popupopen: (e) => {
const item = Object.entries(leafletRefs).find(r => r[1].popup == e.popup)?.[1].item;
if (item?.layer?.name == name && window.location.pathname.split("/")[1] != item.id) {
let params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.search);
if (!location.pathname.includes("/item/")) {
window.history.pushState({}, "", `/${item.id}` + `${params.toString() !== "" ? `?${params}` : ""}`)
}

View File

@ -86,8 +86,8 @@ export const SearchControl = () => {
const location = useLocation();
useEffect(() => {
let params = new URLSearchParams(location.search);
let embedded = params.get("embedded");
const params = new URLSearchParams(location.search);
const embedded = params.get("embedded");
embedded != "true" && setEmbedded(false)
}, [location]);

View File

@ -41,7 +41,7 @@ export function HeaderView({ item, api, editCallback, deleteCallback, setPositio
const [address, setAdress] = React.useState<string>("");
let params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.search);
const openDeleteModal = async (event: React.MouseEvent<HTMLElement>) => {

View File

@ -6,7 +6,7 @@ import { useGetItemTags } from '../../hooks/useTags';
export const PopupButton = ({url, parameterField, text, colorField, item} : {url: string, parameterField?: string, text: string, colorField?: string, item? : Item}) => {
let params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.search);
const getItemTags = useGetItemTags();

View File

@ -31,7 +31,7 @@ export const ItemViewPopup = React.forwardRef((props: ItemViewPopupProps, ref: a
const setSelectPosition = useSetSelectPosition();
const [infoExpanded, setInfoExpanded] = useState<Boolean>(false);
const [infoExpanded, setInfoExpanded] = useState<boolean>(false);
const handleEdit = (event: React.MouseEvent<HTMLElement>) => {
event.stopPropagation();
@ -57,7 +57,7 @@ export const ItemViewPopup = React.forwardRef((props: ItemViewPopupProps, ref: a
}
setLoading(false);
map.closePopup();
let params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.search);
window.history.pushState({}, "", "/" + `${params ? `?${params}` : ""}`);
navigate("/");
}

View File

@ -23,10 +23,10 @@ const filterTags = useFilterTags()
useEffect(() => {
let params = new URLSearchParams(location.search);
let urlTags = params.get("tags")
let decodedTags = urlTags ? decodeURIComponent(urlTags) : "";
let decodedTagsArray = decodedTags.split(";");
const params = new URLSearchParams(location.search);
const urlTags = params.get("tags")
const decodedTags = urlTags ? decodeURIComponent(urlTags) : "";
const decodedTagsArray = decodedTags.split(";");
if(decodedTagsArray?.some(ut => !filterTags.find(ft => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase()))||filterTags?.some(ft => !decodedTagsArray?.find(ut => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase())))
{resetFilterTags()
decodedTagsArray?.map(urlTag => {

View File

@ -81,7 +81,7 @@ export function UtopiaMapInner({
}
const resetMetaTags = () => {
let params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.search);
if (!window.location.pathname.includes("/item/")) {
window.history.pushState({}, "", `/` + `${params.toString() !== "" ? `?${params}` : ""}`);
}

View File

@ -128,9 +128,9 @@ function useFilterManager(initialTags: Tag[]): {
const [searchPhrase, searchPhraseSet] = React.useState<string>("");
const addFilterTag = useCallback((tag: Tag) => {
let params = new URLSearchParams(location.search);
let urlTags = params.get("tags")
let decodedTags = urlTags ? decodeURIComponent(urlTags) : "";
const params = new URLSearchParams(location.search);
const urlTags = params.get("tags")
const decodedTags = urlTags ? decodeURIComponent(urlTags) : "";
if(!decodedTags?.includes(tag.name))
params.set("tags", `${urlTags ? urlTags : ""}${urlTags? ';' : ''}${tag.name}`)
@ -149,10 +149,10 @@ function useFilterManager(initialTags: Tag[]): {
const removeFilterTag = useCallback((name: string) => {
let params = new URLSearchParams(window.location.search);
let urlTags = params.get("tags");
const params = new URLSearchParams(window.location.search);
const urlTags = params.get("tags");
let newUrlTags = "";
let tags = urlTags?.split(";");
const tags = urlTags?.split(";");
if(tags?.length==0 && urlTags?.length && urlTags?.length > 0) tags[0]=urlTags;
tags?.map(urlTag => {
if(!(urlTag.toLocaleLowerCase() === name.toLocaleLowerCase()))

View File

@ -97,7 +97,7 @@ function useSelectPositionManager(): {
const linkItem = async (id: string) => {
if (markerClicked) {
let new_relations = markerClicked.relations || [];
const new_relations = markerClicked.relations || [];
if (!new_relations.some(r => r.related_items_id == id)) {
new_relations?.push({ items_id: markerClicked.id, related_items_id: id })

View File

@ -60,7 +60,7 @@ const ContactInfo = ({ email, telephone, name, avatar, link }: { email: string,
export default ContactInfo;
const ConditionalLink = ({ url, children }) => {
let params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.search);
if (url) {
return (

View File

@ -22,8 +22,8 @@ export const OnepagerView = ({item, userType}:{item: Item, userType: string}) =>
'liebevoll.jetzt': 'liebevoll.jetzt',
};
let groupType = item.group_type ? item.group_type : 'default';
let groupTypeText = typeMapping[groupType];
const groupType = item.group_type ? item.group_type : 'default';
const groupTypeText = typeMapping[groupType];
return (
<div className='tw-h-full tw-overflow-y-auto fade'>

View File

@ -16,7 +16,7 @@ export const TabsForm = ({ item, state, setState, updatePermission, linkItem, un
const updateActiveTab = useCallback((id: number) => {
setActiveTab(id);
let params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.search);
params.set("tab", `${id}`);
const newUrl = location.pathname + "?" + params.toString();
@ -25,8 +25,8 @@ export const TabsForm = ({ item, state, setState, updatePermission, linkItem, un
}, [location.pathname]);
useEffect(() => {
let params = new URLSearchParams(location.search);
let urlTab = params.get("tab");
const params = new URLSearchParams(location.search);
const urlTab = params.get("tab");
setActiveTab(urlTab ? Number(urlTab) : 1);
}, [location.search]);

View File

@ -38,7 +38,7 @@ export const TabsView = ({ attestations, userType, item, offers, needs, relation
const updateActiveTab = useCallback((id: number) => {
setActiveTab(id);
let params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.search);
params.set("tab", `${id}`);
const newUrl = location.pathname + "?" + params.toString();
window.history.pushState({}, '', newUrl);
@ -47,8 +47,8 @@ export const TabsView = ({ attestations, userType, item, offers, needs, relation
useEffect(() => {
let params = new URLSearchParams(location.search);
let urlTab = params.get("tab");
const params = new URLSearchParams(location.search);
const urlTab = params.get("tab");
setActiveTab(urlTab ? Number(urlTab) : 1);
}, [location.search]);

View File

@ -42,7 +42,7 @@ export const submitNewItem = async (evt: any, type: string, item, user, setLoadi
}
export const linkItem = async (id: string, item, updateItem) => {
let new_relations = item.relations || [];
const new_relations = item.relations || [];
new_relations?.push({ items_id: item.id, related_items_id: id })
const updatedItem = { id: item.id, relations: new_relations }
@ -60,7 +60,7 @@ export const linkItem = async (id: string, item, updateItem) => {
}
export const unlinkItem = async (id: string, item, updateItem) => {
let new_relations = item.relations?.filter(r => r.related_items_id !== id)
const new_relations = item.relations?.filter(r => r.related_items_id !== id)
const updatedItem = { id: item.id, relations: new_relations }
@ -94,7 +94,7 @@ export const handleDelete = async (event: React.MouseEvent<HTMLElement>, item, s
}
setLoading(false);
map.closePopup();
let params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.search);
window.history.pushState({}, "", "/" + `${params ? `?${params}` : ""}`);
navigate("/");
}
@ -103,7 +103,7 @@ export const handleDelete = async (event: React.MouseEvent<HTMLElement>, item, s
export const onUpdateItem = async (state, item, tags, addTag, setLoading, navigate, updateItem, addItem, user, params) => {
let changedItem = {} as Item;
let offer_updates: Array<any> = [];
const offer_updates: Array<any> = [];
//check for new offers
await state.offers?.map(o => {
const existingOffer = item?.offers?.find(t => t.tags_id === o.id)
@ -112,7 +112,7 @@ export const onUpdateItem = async (state, item, tags, addTag, setLoading, naviga
!existingOffer && offer_updates.push({ items_id: item?.id, tags_id: o.id })
});
let needs_updates: Array<any> = [];
const needs_updates: Array<any> = [];
await state.needs?.map(n => {
const existingNeed = item?.needs?.find(t => t.tags_id === n.id)
@ -142,8 +142,8 @@ export const onUpdateItem = async (state, item, tags, addTag, setLoading, naviga
...state.needs.length > 0 && { needs: needs_updates }
};
let offers_state: Array<any> = [];
let needs_state: Array<any> = [];
const offers_state: Array<any> = [];
const needs_state: Array<any> = [];
state.offers.map(o => {
offers_state.push({ items_id: item?.id, tags_id: o.id })

View File

@ -17,8 +17,8 @@ export const AttestationForm = ({api}:{api?:ItemsApi<any>}) => {
const navigate = useNavigate();
useEffect(() => {
let params = new URLSearchParams(location.search);
let to_user_ids = params.get("to");
const params = new URLSearchParams(location.search);
const to_user_ids = params.get("to");
setUsers(items.filter(i => to_user_ids?.includes(i.id)))
}, [items, location])

View File

@ -12,7 +12,7 @@ export const ItemCard = ({ i, loading, url, parameterField, deleteCallback }: {
return (
<div className='tw-cursor-pointer tw-card tw-border-[1px] tw-border-base-300 tw-card-body tw-shadow-xl tw-bg-base-100 tw-text-base-content tw-p-4 tw-mb-4 tw-h-fit' onClick={() => {
let params = new URLSearchParams(window.location.search);
const params = new URLSearchParams(window.location.search);
if (windowDimensions.width < 786 && i.position) navigate("/" + getValue(i, parameterField) + `${params ? `?${params}` : ""}`)
else navigate(url + getValue(i, parameterField) + `${params ? `?${params}` : ""}`)
}}>

View File

@ -18,7 +18,7 @@ export const MoonCalendar = () => {
const [currMonth, setCurrMonth] = useState(() => format(today, "MMM-yyyy"));
let firstDayOfMonth = parse(currMonth, "MMM-yyyy", new Date());
const firstDayOfMonth = parse(currMonth, "MMM-yyyy", new Date());
const getPrevMonth = (event: React.MouseEvent<SVGSVGElement>) => {

View File

@ -1,8 +1,8 @@
export function getValue(obj, path) {
if (!obj || typeof path !== 'string') return undefined;
var pathArray = path.split('.'); // Use a different variable for the split path
for (var i = 0, len = pathArray.length; i < len; i++) {
const pathArray = path.split('.'); // Use a different variable for the split path
for (let i = 0, len = pathArray.length; i < len; i++) {
if (!obj) return undefined; // Check if obj is falsy at each step
obj = obj[pathArray[i]]; // Dive one level deeper
}

View File

@ -1,4 +1,4 @@
export const LUNAR_MONTH: number = 29.530588853;
export const LUNAR_MONTH = 29.530588853;
export const getJulianDate = (date: Date = new Date()): number => {
const time: number = date.getTime();

View File

@ -5,12 +5,12 @@ export const randomColor = () => {
const golden_ratio_conjugate = 0.618033988749895;
function hsvToHex(h, s, v) {
var r, g, b;
var i = (Math.floor(h * 6));
var f = h * 6 - i;
var p = v * (1 - s);
var q = v * (1 - f * s);
var t = v * (1 - (1 - f) * s);
let r, g, b;
const i = (Math.floor(h * 6));
const f = h * 6 - i;
const p = v * (1 - s);
const q = v * (1 - f * s);
const t = v * (1 - (1 - f) * s);
switch (i % 6) {
case 0: r = v, g = t, b = p; break;

View File

@ -20,7 +20,7 @@ export const timeAgo = (date: string | number | Date) => {
};
const calculateTimeDifference = (time: number) => {
for (let { label, seconds } of units) {
for (const { label, seconds } of units) {
const interval = Math.floor(time / seconds);
if (interval >= 1) {
return {