Move label dialog with the rest of the dialogs.

This commit is contained in:
Paulo Gustavo Veiga 2022-02-17 18:41:03 -08:00
parent a5847c64d4
commit 18531a981b
3 changed files with 5 additions and 3 deletions

View File

@ -22,7 +22,7 @@ type AddLabelFormProps = {
onAdd: (newLabel: Label) => void; onAdd: (newLabel: Label) => void;
}; };
export default function AddLabelForm({ onAdd }: AddLabelFormProps): React.ReactElement { const AddLabelDialog = ({ onAdd }: AddLabelFormProps): React.ReactElement => {
const intl = useIntl(); const intl = useIntl();
const [createLabelColorIndex, setCreateLabelColorIndex] = React.useState( const [createLabelColorIndex, setCreateLabelColorIndex] = React.useState(
Math.floor(Math.random() * labelColors.length) Math.floor(Math.random() * labelColors.length)
@ -92,3 +92,5 @@ export default function AddLabelForm({ onAdd }: AddLabelFormProps): React.ReactE
</CreateLabel> </CreateLabel>
); );
} }
export default AddLabelDialog;

View File

@ -8,7 +8,7 @@ import Client, { Label, ErrorInfo, MapInfo } from '../../../../classes/client';
import { useQuery } from 'react-query'; import { useQuery } from 'react-query';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { activeInstance } from '../../../../redux/clientSlice'; import { activeInstance } from '../../../../redux/clientSlice';
import AddLabelForm from '../add-label-form'; import AddLabelDialog from '../../action-dispatcher/add-label-dialog';
import { LabelListContainer } from './styled'; import { LabelListContainer } from './styled';
export type LabelSelectorProps = { export type LabelSelectorProps = {
@ -29,7 +29,7 @@ export function LabelSelector({ onChange, maps }: LabelSelectorProps): React.Rea
return ( return (
<Container> <Container>
<FormGroup> <FormGroup>
<AddLabelForm onAdd={(label) => onChange(label, true)} /> <AddLabelDialog onAdd={(label) => onChange(label, true)} />
</FormGroup> </FormGroup>
<LabelListContainer> <LabelListContainer>
{labels.map(({ id, title, color }) => ( {labels.map(({ id, title, color }) => (