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