refactor: remove all legacy files

+ comment/delete things that haven't yet migrated to mantine
This commit is contained in:
Sonny
2024-11-07 00:29:58 +01:00
committed by Sonny
parent 861906d29b
commit 5c37fe9c31
148 changed files with 469 additions and 4728 deletions

View File

@@ -1,42 +0,0 @@
import i18n from '~/i18n';
export function groupItemBy(array: any[], property: string) {
const hash: any = {};
const props = property.split('.');
for (const item of array) {
const key = props.reduce((acc, prop) => acc && acc[prop], item);
const hashKey =
key !== undefined ? key : i18n.t('common:collection.collections');
if (!hash[hashKey]) {
hash[hashKey] = [];
}
hash[hashKey].push(item);
}
return hash;
}
// Thanks S/O
export function arrayMove<T>(
arr: T[],
previousIndex: number,
nextIndex: number
): T[] {
const arrayCopy = [...arr];
const [removedElement] = arrayCopy.splice(previousIndex, 1);
if (nextIndex >= arr.length) {
// Pad the array with undefined elements if needed
const padding = nextIndex - arr.length + 1;
arrayCopy.push(...new Array(padding).fill(undefined));
}
arrayCopy.splice(nextIndex, 0, removedElement);
return arrayCopy;
}
export const sortByCreationDate = <T extends { createdAt: any }>(arr: T[]) =>
arr.sort((a, b) => (a.createdAt > b.createdAt ? 1 : -1));

View File

@@ -1,28 +0,0 @@
import { CollectionWithLinks } from '~/types/app';
export default function sortCcollectionsByNextId(
collections: CollectionWithLinks[]
): CollectionWithLinks[] {
const sortedCollections: CollectionWithLinks[] = [];
const visit = (collection: CollectionWithLinks) => {
// Check if the collection has been visited
if (sortedCollections.includes(collection)) {
return;
}
// Visit the next collection recursively
const nextCollection = collections.find((c) => c.id === collection.nextId);
if (nextCollection) {
visit(nextCollection);
}
// Add the current collection to the sorted array
sortedCollections.push(collection);
};
// Visit each collection to build the sorted array
collections.forEach((collection) => visit(collection));
return sortedCollections.reverse();
}

View File

@@ -1,6 +0,0 @@
import hexRgb from 'hex-rgb';
export const rgba = (hex: string, alpha: number) => {
const rgb = hexRgb(hex, { format: 'array' }).slice(0, -1).join(',');
return `rgba(${rgb},${alpha})`;
};

View File

@@ -1,6 +0,0 @@
export const isImage = (type: string) => type.includes('image');
export const isBase64Image = (data: string) => data.startsWith('data:image/');
export const convertBase64ToBuffer = (base64: string) =>
Buffer.from(base64, 'base64');