import {
useMantineTheme,
Modal,
Center,
Group,
TextInput,
Image,
Button,
Select,
AspectRatio,
Text,
Card,
} from '@mantine/core';
import { useForm } from '@mantine/hooks';
import { UseForm } from '@mantine/hooks/lib/use-form/use-form';
import { motion } from 'framer-motion';
import { useState } from 'react';
import { Apps } from 'tabler-icons-react';
import { useConfig } from '../../tools/state';
import { ServiceTypeList } from '../../tools/types';
import { AppShelfItemWrapper } from './AppShelfItemWrapper';
export default function AddItemShelfItem(props: any) {
const { addService } = useConfig();
const [opened, setOpened] = useState(false);
const theme = useMantineTheme();
return (
<>
setOpened(false)}
title="Add a service"
>
Add a service
setOpened(true)} size={60} />
>
);
}
function MatchIcon(
name: string,
form: UseForm<{
type: any;
name: any;
icon: any;
url: any;
apiKey: any;
}>
) {
// TODO: In order to avoid all the requests, we could fetch
// https://data.jsdelivr.com/v1/package/gh/IceWhaleTech/AppIcon@main
// and then iterate over the files -> files -> name and then remove the extension (.png)
// Compare it to the input and then fetch the icon
fetch(`https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name.toLowerCase()}.png`)
.then((res) => {
if (res.status === 200) {
form.setFieldValue('icon', res.url);
}
})
.catch((e) => {
// Do nothing
});
return false;
}
export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & any) {
const { setOpened } = props;
const { addService, config, setConfig } = useConfig();
const form = useForm({
initialValues: {
type: props.type ?? 'Other',
name: props.name ?? '',
icon: props.icon ?? '',
url: props.url ?? '',
apiKey: props.apiKey ?? (undefined as unknown as string),
},
});
return (
<>
>
);
}