The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/ee/client/omnichannel/RemoveBusinessHourButton.js

50 lines
1.7 KiB

import { Table, Icon, Button } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import React from 'react';
import GenericModal from '../../../client/components/GenericModal';
import { useSetModal } from '../../../client/contexts/ModalContext';
import { useMethod } from '../../../client/contexts/ServerContext';
import { useToastMessageDispatch } from '../../../client/contexts/ToastMessagesContext';
import { useTranslation } from '../../../client/contexts/TranslationContext';
function RemoveBusinessHourButton({ _id, type, reload }) {
const removeBusinessHour = useMethod('livechat:removeBusinessHour');
const setModal = useSetModal();
const dispatchToastMessage = useToastMessageDispatch();
const t = useTranslation();
const handleRemoveClick = useMutableCallback(async () => {
try {
await removeBusinessHour(_id, type);
} catch (error) {
console.log(error);
}
reload();
});
const handleDelete = useMutableCallback((e) => {
e.stopPropagation();
const onBusinessHour = async () => {
try {
await handleRemoveClick();
dispatchToastMessage({ type: 'success', message: t('Business_Hour_Removed') });
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
setModal();
};
setModal(<GenericModal variant='danger' onConfirm={onBusinessHour} onCancel={() => setModal()} confirmText={t('Delete')} />);
});
return (
<Table.Cell fontScale='p2' color='hint' onClick={handleDelete} withTruncatedText>
<Button small ghost title={t('Remove')} onClick={handleDelete}>
<Icon name='trash' size='x16' />
</Button>
</Table.Cell>
);
}
export default RemoveBusinessHourButton;