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

37 lines
1 KiB
TypeScript

import classNames from 'clsx';
import React from 'react';
import { useCompose } from 'soapbox/hooks';
import SensitiveButton from './sensitive-button';
import Upload from './upload';
import UploadProgress from './upload-progress';
import type { Attachment as AttachmentEntity } from 'soapbox/types/entities';
interface IUploadForm {
composeId: string,
}
const UploadForm: React.FC<IUploadForm> = ({ composeId }) => {
const mediaIds = useCompose(composeId).media_attachments.map((item: AttachmentEntity) => item.id);
const classes = classNames('compose-form__uploads-wrapper', {
'contains-media': mediaIds.size !== 0,
});
return (
<div className='compose-form__upload-wrapper'>
<UploadProgress composeId={composeId} />
<div className={classes}>
{mediaIds.map((id: string) => (
<Upload id={id} key={id} composeId={composeId} />
))}
</div>
{!mediaIds.isEmpty() && <SensitiveButton composeId={composeId} />}
</div>
);
};
export default UploadForm;