/* eslint-disable import/no-unresolved */ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: MIT-0 import React, { useState } from 'react'; import { Modal, ModalHeader, ModalBody, ModalButtonGroup, ModalButton, Input, Label, useNotificationDispatch, } from 'amazon-chime-sdk-component-library-react'; import { MAX_PRESENCE_STATUS_LENGTH } from "../../utilities/presence"; import './SetCustomStatusModal.css'; export const SetCustomStatusModal = ({ onClose, setCustomStatus }) => { const [status, setStatus] = useState(''); const dispatch = useNotificationDispatch(); const onStatusChange = (e) => { setStatus(e.target.value); }; const onSubmit = async (e) => { if (!status) { dispatch({ type: 0, payload: { message: 'Error, custom status cannot be blank.', severity: 'error', }, }); } else if (status.length > MAX_PRESENCE_STATUS_LENGTH) { dispatch({ type: 0, payload: { message: `Error, custom status length cannot exceed ${MAX_PRESENCE_STATUS_LENGTH} characters.`, severity: 'error', }, }); } try { await setCustomStatus(e, status); } catch { dispatch({ type: 0, payload: { message: 'Unable to set custom status.', severity: 'error', }, }); } finally { onClose(); } }; return (
onSubmit(e)}>
onStatusChange(e)} placeholder={"Type status"} />
, , ]} />
); }; export default SetCustomStatusModal;