<commit_before>const defaultState = {
	filesCount: 0,
	files: [],
	tags: [],
};

export default function reducer(state = defaultState, action) {
	switch (action.type) {
	case 'ADD_FILES':
		return {
			...state,
			files: action.payload.files.map(file => {
				return { ...file, isVisible: true, isChecked: true };
			}),
		};
	case 'ADD_TAGS':
		return {
			...state,
			tags: action.payload.tags.map(tag => {
				return { ...tag, isVisible: true };
			}),
		};
	case 'DELETE_FILE':
		return { ...state, files: state.files.filter(file => file.Key !== action.payload.key) };
	case 'DELETE_FILES':
		return defaultState;
	case 'SET_COUNT':
		return { ...state, filesCount: action.payload.count };
	case 'SORT_FILES':
		switch (action.payload.type) {
		case 'boolean':
			return {
				...state,
				files: state.files.sort((fileA, fileB) => {
					let compareA = fileA[action.payload.field];
					let compareB = fileB[action.payload.field];
					if (compareA && !compareB) return action.payload.direction == 'down' ? -1 : 1;
					if (!compareA && compareB) return action.payload.direction == 'down' ? 1 : -1;
					return 0;
				}),
			};
		case 'string':
			return {
				...state,
				files: state.files.sort((fileA, fileB) => {
					let compareA = fileA[action.payload.field].toLowerCase();
					let compareB = fileB[action.payload.field].toLowerCase();
					if (compareA > compareB) return action.payload.direction == 'down' ? 1 : -1;
					if (compareA < compareB) return action.payload.direction == 'down' ? -1 : 1;
					return 0;
				}),
			};
		default:
			return state;
		}
	case 'SEARCH_FILES':
		return {
			...state,
			files: state.files.map(file => {
				return file.OriginalName.toLowerCase().indexOf(action.payload.keyword) === -1
					? { ...file, isVisible: false }
					: { ...file, isVisible: true };
			}),
		};
	case 'TOGGLE_FILE_CHECKED':
		return {
			...state,<commit_msg>Added search tags reducer function<commit_after>const defaultState = {
	filesCount: 0,
	files: [],
	tags: [],
};

export default function reducer(state = defaultState, action) {
	switch (action.type) {
	case 'ADD_FILES':
		return {
			...state,
			files: action.payload.files.map(file => {
				return { ...file, isVisible: true, isChecked: true };
			}),
		};
	case 'ADD_TAGS':
		return {
			...state,
			tags: action.payload.tags.map(tag => {
				return { ...tag, isVisible: true };
			}),
		};
	case 'DELETE_FILE':
		return { ...state, files: state.files.filter(file => file.Key !== action.payload.key) };
	case 'DELETE_FILES':
		return defaultState;
	case 'SET_COUNT':
		return { ...state, filesCount: action.payload.count };
	case 'SORT_FILES':
		switch (action.payload.type) {
		case 'boolean':
			return {
				...state,
				files: state.files.sort((fileA, fileB) => {
					let compareA = fileA[action.payload.field];
					let compareB = fileB[action.payload.field];
					if (compareA && !compareB) return action.payload.direction == 'down' ? -1 : 1;
					if (!compareA && compareB) return action.payload.direction == 'down' ? 1 : -1;
					return 0;
				}),
			};
		case 'string':
			return {
				...state,
				files: state.files.sort((fileA, fileB) => {
					let compareA = fileA[action.payload.field].toLowerCase();
					let compareB = fileB[action.payload.field].toLowerCase();
					if (compareA > compareB) return action.payload.direction == 'down' ? 1 : -1;
					if (compareA < compareB) return action.payload.direction == 'down' ? -1 : 1;
					return 0;
				}),
			};
		default:
			return state;
		}
	case 'SEARCH_FILES':
		return {
			...state,
			files: state.files.map(file => {
				return file.OriginalName.toLowerCase().indexOf(action.payload.keyword) === -1
					? { ...file, isVisible: false }
					: { ...file, isVisible: true };
			}),
		};
	case 'SEARCH_TAGS':
		return {
			...state,
			tags: state.tags.map(tag => {
				return tag.Name.toLowerCase().indexOf(action.payload.keyword) === -1
					? { ...tag, isVisible: false }
					: { ...tag, isVisible: true };
			}),
		};
	case 'TOGGLE_FILE_CHECKED':
		return {
			...state,
{'fraction_non_alphanumeric': 0.17524752475247524, 'fraction_numerical': 0.006188118811881188, 'mean_word_length': 2.8669856459330143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3807467', 'n_tokens_mistral': 1629, 'n_tokens_neox': 1361, 'n_words': 302}