bigbuffet-rw/app/soapbox/features/compose/containers/quoted_status_container.tsx
marcin mikolajczak 6cce0a0291 Introduce useCompose hook
Signed-off-by: marcin mikolajczak <git@mkljczk.pl>
2022-09-14 20:01:44 +02:00

38 lines
936 B
TypeScript

import React from 'react';
import { cancelQuoteCompose } from 'soapbox/actions/compose';
import QuotedStatus from 'soapbox/components/quoted-status';
import { useAppSelector, useAppDispatch } from 'soapbox/hooks';
import { makeGetStatus } from 'soapbox/selectors';
const getStatus = makeGetStatus();
interface IQuotedStatusContainer {
composeId: string,
}
/** QuotedStatus shown in post composer. */
const QuotedStatusContainer: React.FC<IQuotedStatusContainer> = ({ composeId }) => {
const dispatch = useAppDispatch();
const status = useAppSelector(state => getStatus(state, { id: state.compose.get(composeId)?.quote! }));
const onCancel = () => {
dispatch(cancelQuoteCompose());
};
if (!status) {
return null;
}
return (
<div className='mb-2'>
<QuotedStatus
status={status}
onCancel={onCancel}
compose
/>
</div>
);
};
export default QuotedStatusContainer;