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/apps/meteor/ee/client/omnichannel/RemoveBusinessHourButton.js

46 lines
1.5 KiB

import { IconButton } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useSetModal, useToastMessageDispatch, useMethod, useTranslation } from '@rocket.chat/ui-contexts';
import React from 'react';
import GenericModal from '../../../client/components/GenericModal';
import { GenericTableCell } from '../../../client/components/GenericTable';
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 (
<GenericTableCell fontScale='p2' color='hint' onClick={handleDelete} withTruncatedText>
<IconButton icon='trash' mini title={t('Remove')} onClick={handleDelete} />
</GenericTableCell>
);
}
export default RemoveBusinessHourButton;