RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/views/room/contextualBar/NotificationPreferences/components/NotificationPreference.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import type { SelectOption } from '@rocket.chat/fuselage';
import { Field, FieldLabel, FieldRow, Select } from '@rocket.chat/fuselage';
import type { ReactElement } from 'react';
import React from 'react';

type NotificationPreferenceProps = {
    id: string;
    name: string;
    options: SelectOption[];
    onChange: (e: unknown) => void;
    optionValue: string;
    children?: ReactElement;
};

const NotificationPreference = ({
    name,
    options,
    onChange,
    optionValue,
    children,
    ...props
}: NotificationPreferenceProps): ReactElement => (
    <Field {...props}>
        <FieldLabel>{name}</FieldLabel>
        <FieldRow>
            <Select onChange={onChange} options={options} value={optionValue} />
            {children}
        </FieldRow>
    </Field>
);

export default NotificationPreference;