2024-06-22 22:06:16 +01:00
|
|
|
import ToolLayout from '../components/ToolLayout';
|
2024-06-26 09:02:05 +01:00
|
|
|
import React, { JSXElementConstructor, LazyExoticComponent } from 'react';
|
2025-02-25 06:17:10 +00:00
|
|
|
import { IconifyIcon } from '@iconify/react';
|
2025-07-15 19:42:34 +01:00
|
|
|
import { FullI18nKey, validNamespaces } from '../i18n';
|
2025-07-14 18:33:59 +01:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2024-06-22 22:06:16 +01:00
|
|
|
|
2025-07-22 19:47:09 +01:00
|
|
|
export type UserType = 'generalUsers' | 'developers';
|
2025-07-11 15:25:01 -07:00
|
|
|
|
2025-04-17 08:03:18 +01:00
|
|
|
export interface ToolMeta {
|
2024-06-22 22:06:16 +01:00
|
|
|
path: string;
|
2025-02-27 02:21:08 +00:00
|
|
|
component: LazyExoticComponent<JSXElementConstructor<ToolComponentProps>>;
|
2024-06-22 22:06:16 +01:00
|
|
|
keywords: string[];
|
2025-03-02 02:58:50 +00:00
|
|
|
icon: IconifyIcon | string;
|
2025-07-14 13:55:01 +01:00
|
|
|
i18n: {
|
2025-07-13 15:39:12 +01:00
|
|
|
name: FullI18nKey;
|
|
|
|
|
description: FullI18nKey;
|
|
|
|
|
shortDescription: FullI18nKey;
|
|
|
|
|
longDescription?: FullI18nKey;
|
2025-07-18 14:45:15 -07:00
|
|
|
userTypes?: UserType[];
|
2025-07-12 23:02:35 -07:00
|
|
|
};
|
2024-06-22 22:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-27 13:05:38 +00:00
|
|
|
export type ToolCategory =
|
|
|
|
|
| 'string'
|
2025-07-11 15:25:01 -07:00
|
|
|
| 'image-generic'
|
2025-02-27 13:05:38 +00:00
|
|
|
| 'png'
|
|
|
|
|
| 'number'
|
|
|
|
|
| 'gif'
|
|
|
|
|
| 'list'
|
2025-03-09 00:41:59 +00:00
|
|
|
| 'json'
|
2025-03-27 10:14:05 -04:00
|
|
|
| 'time'
|
2025-03-24 20:23:28 +00:00
|
|
|
| 'csv'
|
2025-07-11 15:25:01 -07:00
|
|
|
| 'video'
|
2025-04-02 03:46:42 +00:00
|
|
|
| 'pdf'
|
2025-07-08 22:45:09 +01:00
|
|
|
| 'audio'
|
2025-07-08 12:56:31 -07:00
|
|
|
| 'xml';
|
2025-02-23 01:38:42 +01:00
|
|
|
|
2024-06-22 23:31:00 +01:00
|
|
|
export interface DefinedTool {
|
2025-02-23 01:38:42 +01:00
|
|
|
type: ToolCategory;
|
2024-06-22 22:06:16 +01:00
|
|
|
path: string;
|
2025-07-14 14:51:46 +01:00
|
|
|
name: FullI18nKey;
|
|
|
|
|
description: FullI18nKey;
|
|
|
|
|
shortDescription: FullI18nKey;
|
2025-03-02 02:58:50 +00:00
|
|
|
icon: IconifyIcon | string;
|
2024-06-22 22:06:16 +01:00
|
|
|
keywords: string[];
|
|
|
|
|
component: () => JSX.Element;
|
2025-07-11 15:25:01 -07:00
|
|
|
userTypes?: UserType[];
|
2024-06-22 22:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-27 02:21:08 +00:00
|
|
|
export interface ToolComponentProps {
|
2025-03-09 01:22:23 +00:00
|
|
|
title: string;
|
|
|
|
|
longDescription?: string;
|
2025-02-27 02:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-22 22:06:16 +01:00
|
|
|
export const defineTool = (
|
2025-02-23 01:38:42 +01:00
|
|
|
basePath: ToolCategory,
|
2025-04-17 08:03:18 +01:00
|
|
|
options: ToolMeta
|
2024-06-22 22:06:16 +01:00
|
|
|
): DefinedTool => {
|
2025-07-14 18:04:30 +01:00
|
|
|
const { icon, path, keywords, component, i18n } = options;
|
2024-06-22 22:06:16 +01:00
|
|
|
const Component = component;
|
|
|
|
|
return {
|
2024-06-23 01:26:04 +01:00
|
|
|
type: basePath,
|
2024-06-22 22:06:16 +01:00
|
|
|
path: `${basePath}/${path}`,
|
2025-07-14 18:04:30 +01:00
|
|
|
name: i18n.name,
|
2025-02-25 06:17:10 +00:00
|
|
|
icon,
|
2025-07-14 18:04:30 +01:00
|
|
|
description: i18n.description,
|
|
|
|
|
shortDescription: i18n.shortDescription,
|
2024-06-22 22:06:16 +01:00
|
|
|
keywords,
|
2025-07-18 14:45:15 -07:00
|
|
|
userTypes: i18n.userTypes,
|
2025-07-14 18:33:59 +01:00
|
|
|
component: function ToolComponent() {
|
2025-07-15 19:42:34 +01:00
|
|
|
const { t } = useTranslation(validNamespaces);
|
2024-06-22 22:06:16 +01:00
|
|
|
return (
|
2024-06-25 19:45:29 +01:00
|
|
|
<ToolLayout
|
2025-02-25 06:17:10 +00:00
|
|
|
icon={icon}
|
2024-06-25 19:45:29 +01:00
|
|
|
type={basePath}
|
2025-07-15 14:08:42 +01:00
|
|
|
i18n={i18n}
|
2025-07-15 14:01:38 +01:00
|
|
|
fullPath={`${basePath}/${path}`}
|
2024-06-25 19:45:29 +01:00
|
|
|
>
|
2025-07-14 18:33:59 +01:00
|
|
|
<Component
|
|
|
|
|
title={t(i18n.name)}
|
|
|
|
|
longDescription={
|
|
|
|
|
i18n.longDescription ? t(i18n.longDescription) : undefined
|
|
|
|
|
}
|
|
|
|
|
/>
|
2024-06-22 22:06:16 +01:00
|
|
|
</ToolLayout>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|