mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 14:09:31 +02:00
Fixing errors with userTypes
This commit is contained in:
@@ -103,7 +103,7 @@ export default function ToolHeader({
|
||||
items={[
|
||||
{ title: 'All tools', link: '/' },
|
||||
{
|
||||
title: getToolsByCategory(t).find(
|
||||
title: getToolsByCategory([], t).find(
|
||||
(category) => category.type === type
|
||||
)!.rawTitle,
|
||||
link: '/categories/' + type
|
||||
|
@@ -43,7 +43,7 @@ export default function ToolLayout({
|
||||
const toolDescription: string = t(i18n.description);
|
||||
|
||||
const otherCategoryTools =
|
||||
getToolsByCategory(t)
|
||||
getToolsByCategory([], t)
|
||||
.find((category) => category.type === type)
|
||||
?.tools.filter((tool) => t(tool.name) !== toolTitle)
|
||||
.map((tool) => ({
|
||||
@@ -77,8 +77,9 @@ export default function ToolLayout({
|
||||
<AllTools
|
||||
title={t('translation:toolLayout.allToolsTitle', '', {
|
||||
type: capitalizeFirstLetter(
|
||||
getToolsByCategory(t).find((category) => category.type === type)!
|
||||
.title
|
||||
getToolsByCategory([], t).find(
|
||||
(category) => category.type === type
|
||||
)!.title
|
||||
)
|
||||
})}
|
||||
toolCards={otherCategoryTools}
|
||||
|
@@ -6,11 +6,11 @@ export const tool = defineTool('csv', {
|
||||
name: 'csv:csvRowsToColumns.title',
|
||||
description: 'csv:csvRowsToColumns.description',
|
||||
shortDescription: 'csv:csvRowsToColumns.shortDescription',
|
||||
longDescription: 'csv:csvRowsToColumns.longDescription'
|
||||
longDescription: 'csv:csvRowsToColumns.longDescription',
|
||||
userTypes: ['General Users', 'Students', 'Developers']
|
||||
},
|
||||
path: 'csv-rows-to-columns',
|
||||
icon: 'fluent:text-arrow-down-right-column-24-filled',
|
||||
keywords: ['csv', 'rows', 'columns', 'transpose'],
|
||||
userTypes: ['Developers'],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
||||
|
@@ -5,13 +5,13 @@ export const tool = defineTool('csv', {
|
||||
i18n: {
|
||||
name: 'csv:csvToJson.title',
|
||||
description: 'csv:csvToJson.description',
|
||||
shortDescription: 'csv:csvToJson.shortDescription'
|
||||
shortDescription: 'csv:csvToJson.shortDescription',
|
||||
userTypes: ['General Users', 'Students', 'Developers']
|
||||
},
|
||||
|
||||
path: 'csv-to-json',
|
||||
icon: 'lets-icons:json-light',
|
||||
|
||||
keywords: ['csv', 'json', 'convert', 'transform', 'parse'],
|
||||
userTypes: ['Developers'],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
||||
|
@@ -6,12 +6,12 @@ export const tool = defineTool('csv', {
|
||||
name: 'csv:csvToTsv.title',
|
||||
description: 'csv:csvToTsv.description',
|
||||
shortDescription: 'csv:csvToTsv.shortDescription',
|
||||
longDescription: 'csv:csvToTsv.longDescription'
|
||||
longDescription: 'csv:csvToTsv.longDescription',
|
||||
userTypes: ['General Users', 'Students', 'Developers']
|
||||
},
|
||||
|
||||
path: 'csv-to-tsv',
|
||||
icon: 'codicon:keyboard-tab',
|
||||
keywords: ['csv', 'tsv', 'convert', 'transform', 'parse'],
|
||||
userTypes: ['Developers'],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
||||
|
@@ -5,13 +5,13 @@ export const tool = defineTool('csv', {
|
||||
i18n: {
|
||||
name: 'csv:csvToXml.title',
|
||||
description: 'csv:csvToXml.description',
|
||||
shortDescription: 'csv:csvToXml.shortDescription'
|
||||
shortDescription: 'csv:csvToXml.shortDescription',
|
||||
userTypes: ['General Users', 'Students', 'Developers']
|
||||
},
|
||||
|
||||
path: 'csv-to-xml',
|
||||
icon: 'mdi-light:xml',
|
||||
|
||||
keywords: ['csv', 'xml', 'convert', 'transform', 'parse'],
|
||||
userTypes: ['Developers'],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
||||
|
@@ -6,12 +6,12 @@ export const tool = defineTool('csv', {
|
||||
name: 'csv:swapCsvColumns.title',
|
||||
description: 'csv:swapCsvColumns.description',
|
||||
shortDescription: 'csv:swapCsvColumns.shortDescription',
|
||||
longDescription: 'csv:swapCsvColumns.longDescription'
|
||||
longDescription: 'csv:swapCsvColumns.longDescription',
|
||||
userTypes: ['General Users', 'Students', 'Developers']
|
||||
},
|
||||
|
||||
path: 'swap-csv-columns',
|
||||
icon: 'eva:swap-outline',
|
||||
keywords: ['csv', 'swap', 'columns'],
|
||||
userTypes: ['Developers'],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
||||
|
@@ -5,7 +5,8 @@ export const tool = defineTool('pdf', {
|
||||
i18n: {
|
||||
name: 'pdf:editor.title',
|
||||
description: 'pdf:editor.description',
|
||||
shortDescription: 'pdf:editor.shortDescription'
|
||||
shortDescription: 'pdf:editor.shortDescription',
|
||||
userTypes: ['General Users', 'Students', 'Developers']
|
||||
},
|
||||
|
||||
path: 'editor',
|
||||
@@ -26,6 +27,5 @@ export const tool = defineTool('pdf', {
|
||||
'annotation',
|
||||
'markup'
|
||||
],
|
||||
userTypes: ['General Users', 'Students', 'Developers'],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
||||
|
@@ -6,13 +6,13 @@ export const tool = defineTool('string', {
|
||||
i18n: {
|
||||
name: 'string:rot13.title',
|
||||
description: 'string:rot13.description',
|
||||
shortDescription: 'string:rot13.shortDescription'
|
||||
shortDescription: 'string:rot13.shortDescription',
|
||||
userTypes: ['General Users', 'Students', 'Developers']
|
||||
},
|
||||
|
||||
path: 'rot13',
|
||||
icon: 'hugeicons:encrypt',
|
||||
|
||||
keywords: ['rot13'],
|
||||
userTypes: ['Developers', 'CyberSec', 'Students'],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
||||
|
@@ -6,13 +6,13 @@ export const tool = defineTool('string', {
|
||||
i18n: {
|
||||
name: 'string:rotate.title',
|
||||
description: 'string:rotate.description',
|
||||
shortDescription: 'string:rotate.shortDescription'
|
||||
shortDescription: 'string:rotate.shortDescription',
|
||||
userTypes: ['General Users', 'Students', 'Developers']
|
||||
},
|
||||
|
||||
path: 'rotate',
|
||||
icon: 'carbon:rotate',
|
||||
|
||||
keywords: ['rotate'],
|
||||
userTypes: ['General Users', 'Students', 'Developers'],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
||||
|
@@ -5,7 +5,8 @@ export const tool = defineTool('string', {
|
||||
i18n: {
|
||||
name: 'string:textReplacer.title',
|
||||
description: 'string:textReplacer.description',
|
||||
shortDescription: 'string:textReplacer.shortDescription'
|
||||
shortDescription: 'string:textReplacer.shortDescription',
|
||||
userTypes: ['General Users', 'Students', 'Developers']
|
||||
},
|
||||
|
||||
path: 'replacer',
|
||||
@@ -13,6 +14,5 @@ export const tool = defineTool('string', {
|
||||
icon: 'material-symbols-light:find-replace',
|
||||
|
||||
keywords: ['text', 'replace'],
|
||||
userTypes: ['General Users', 'Students', 'Developers'],
|
||||
component: lazy(() => import('./index'))
|
||||
});
|
||||
|
@@ -198,6 +198,7 @@ export const getToolsByCategory = (
|
||||
type: ToolCategory;
|
||||
example: { title: string; path: string };
|
||||
tools: DefinedTool[];
|
||||
userTypes: UserType[]; // <-- Add this line
|
||||
}[] => {
|
||||
const groupedByType: Partial<Record<ToolCategory, DefinedTool[]>> =
|
||||
Object.groupBy(tools, ({ type }) => type);
|
||||
@@ -214,6 +215,11 @@ export const getToolsByCategory = (
|
||||
? filterToolsByUserTypes(tools ?? [], userTypes)
|
||||
: tools ?? [];
|
||||
|
||||
// Aggregate unique userTypes from all tools in this category
|
||||
const aggregatedUserTypes = Array.from(
|
||||
new Set((filteredTools ?? []).flatMap((tool) => tool.userTypes ?? []))
|
||||
);
|
||||
|
||||
return {
|
||||
rawTitle: categoryConfig?.title
|
||||
? t(categoryConfig.title)
|
||||
@@ -228,7 +234,8 @@ export const getToolsByCategory = (
|
||||
example:
|
||||
filteredTools.length > 0
|
||||
? { title: filteredTools[0].name, path: filteredTools[0].path }
|
||||
: { title: '', path: '' }
|
||||
: { title: '', path: '' },
|
||||
userTypes: aggregatedUserTypes // <-- Add this line
|
||||
};
|
||||
})
|
||||
.filter((category) => category.tools.length > 0) // Only show categories with tools
|
||||
|
@@ -114,7 +114,7 @@ export const getToolCategoryTitle = (
|
||||
categoryName: string,
|
||||
t: TFunction<I18nNamespaces[]>
|
||||
): string =>
|
||||
getToolsByCategory(t).find((category) => category.type === categoryName)!
|
||||
getToolsByCategory([], t).find((category) => category.type === categoryName)!
|
||||
.rawTitle;
|
||||
|
||||
// Type guard to check if a value is a valid I18nNamespaces
|
||||
|
Reference in New Issue
Block a user