From 9e49eceaba0f34be79866eae58013922e28749b9 Mon Sep 17 00:00:00 2001 From: erikao1998 Date: Wed, 12 Jun 2024 13:45:37 +0300 Subject: [PATCH] Remove some components used in admin page that are not currently needed --- src/client/components/Admin/Select.tsx | 139 +------------------------ 1 file changed, 2 insertions(+), 137 deletions(-) diff --git a/src/client/components/Admin/Select.tsx b/src/client/components/Admin/Select.tsx index 223d7de..17c3f79 100644 --- a/src/client/components/Admin/Select.tsx +++ b/src/client/components/Admin/Select.tsx @@ -1,14 +1,7 @@ /* eslint-disable import/no-extraneous-dependencies */ -import React, { useEffect, useState } from 'react' -import { - useLocation, - useNavigate, - useParams, - useSearchParams, -} from 'react-router-dom' -import { Control, Controller } from 'react-hook-form' +import React from 'react' +import { useLocation, useNavigate, useParams } from 'react-router-dom' import { useTranslation } from 'react-i18next' -import { HexColorInput, HexColorPicker } from 'react-colorful' import { Box, FormControl, @@ -16,19 +9,12 @@ import { Select, SelectChangeEvent, MenuItem, - FormLabel, - RadioGroup, - FormControlLabel, - Radio, } from '@mui/material' import { Locales } from '@backend/types' import useSurvey from '../../hooks/useSurvey' import useQuestions from '../../hooks/useQuestions' -import useRecommendations from '../../hooks/useRecommendations' - -import { languages } from './config' import sortQuestions from '../../util/questions' import useResults from '../../hooks/useResults' @@ -61,76 +47,6 @@ const SelectWrapper = ({ ) -export const DialogSelect = ({ - label, - value, - control, - children, - defaultValue = '', -}: { - label: string - value: string - control: Control - children: React.ReactNode - // eslint-disable-next-line react/require-default-props - defaultValue?: any -}) => ( - ( - - {label} - - - )} - /> -) - -export const LanguageSelect = () => { - const { t, i18n } = useTranslation() - const language = i18n.language as keyof Locales - const [searchParams, setSearchParams] = useSearchParams() - const [selectedLanguage, setSelectedLanguage] = useState('en') - - useEffect(() => { - const persistLanguage = searchParams.get('transLang') - - if (persistLanguage) setSelectedLanguage(persistLanguage as keyof Locales) - - if (!persistLanguage) setSearchParams({ transLang: selectedLanguage }) - }, [searchParams, selectedLanguage, setSearchParams]) - - const handleLanguageChange = (event: SelectChangeEvent) => { - const newLanguage = event.target.value as keyof Locales - - setSelectedLanguage(newLanguage) - setSearchParams({ language: newLanguage }) - } - - return ( - - - {t('admin:selectLanguage')} - - {languages.map(({ id, title }) => ( - } - label={title[language]} - checked={selectedLanguage === id} - /> - ))} - - - - ) -} - export const ResultSelect = () => { const { i18n } = useTranslation() const navigate = useNavigate() @@ -208,54 +124,3 @@ export const QuestionSelect = () => { ) } - -export const RecommendationSelect = () => { - const { t } = useTranslation() - const navigate = useNavigate() - const location = useLocation() - const { recommendationId } = useParams() - - const { survey } = useSurvey() - const { recommendations, isSuccess } = useRecommendations(survey?.id) - - const handleRecommendationChange = (event: SelectChangeEvent) => { - navigate({ - pathname: `./${event.target.value}`, - search: location.search, - }) - } - - if (!isSuccess || !recommendations) return null - - return ( - - {recommendations.map(({ id, label }) => ( - - {label} - - ))} - - ) -} - -export const ColorSelect = ({ - label, - value, - setValue, -}: { - label: string - value: string - setValue: (newColor: string) => void -}) => ( - - {label} - - - - - -)