0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-03-22 08:58:11 +00:00

move duplicategroups to separate file for easier modification

This commit is contained in:
Víctor Losada Hernández
2026-03-11 12:15:22 +01:00
parent 89a21f8099
commit f4cf72a5b3
2 changed files with 12 additions and 12 deletions

View File

@@ -1,4 +1,4 @@
export default [ export const tagSuggestionList = [
// ############################## Systems // ############################## Systems
// D&D // D&D
'system:D&D Original', 'system:D&D Original',
@@ -208,3 +208,12 @@ export default [
'SW5e', 'SW5e',
'Star Wars 5e', 'Star Wars 5e',
]; ];
// substrings to be normalized to the first value on the array
export const canonizationList = [
['5e 2024', '5.5e', '5e\'24', '5.24', '5e24', '5.5'],
['5e', '5th Edition'],
['Dungeons & Dragons', 'Dungeons and Dragons', 'Dungeons n dragons'],
['D&D', 'DnD', 'dnd', 'Dnd', 'dnD', 'd&d', 'd&D', 'D&d'],
['P2e', 'p2e', 'P2E', 'Pathfinder 2e'],
];

View File

@@ -2,7 +2,7 @@ import './tagInput.less';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import Combobox from '../../../components/combobox.jsx'; import Combobox from '../../../components/combobox.jsx';
import tagSuggestionList from './curatedTagSuggestionList.js'; import { tagSuggestionList, canonizationList } from './curatedTagSuggestionList.js';
const TagInput = ({ tooltip, label, valuePatterns, values = [], unique = true, placeholder = '', smallText = '', onChange })=>{ const TagInput = ({ tooltip, label, valuePatterns, values = [], unique = true, placeholder = '', smallText = '', onChange })=>{
const [tagList, setTagList] = useState( const [tagList, setTagList] = useState(
@@ -35,20 +35,11 @@ const TagInput = ({ tooltip, label, valuePatterns, values = [], unique = true, p
}); });
}, [tagList]); }, [tagList]);
// substrings to be normalized to the first value on the array
const duplicateGroups = [
['5e 2024', '5.5e', '5e\'24', '5.24', '5e24', '5.5'],
['5e', '5th Edition'],
['Dungeons & Dragons', 'Dungeons and Dragons', 'Dungeons n dragons'],
['D&D', 'DnD', 'dnd', 'Dnd', 'dnD', 'd&d', 'd&D', 'D&d'],
['P2e', 'p2e', 'P2E', 'Pathfinder 2e'],
];
const normalizeValue = (input)=>{ const normalizeValue = (input)=>{
const lowerInput = input.toLowerCase(); const lowerInput = input.toLowerCase();
let normalizedTag = input; let normalizedTag = input;
for (const group of duplicateGroups) { for (const group of canonizationList) {
for (const tag of group) { for (const tag of group) {
if(!tag) continue; if(!tag) continue;