2022-08-31 02:35:06 -07:00
|
|
|
import classNames from 'clsx';
|
2022-04-10 03:46:25 -07:00
|
|
|
import React from 'react';
|
|
|
|
|
2022-12-01 12:32:55 -08:00
|
|
|
import { HStack } from 'soapbox/components/ui';
|
2022-09-14 11:01:00 -07:00
|
|
|
import { useCompose } from 'soapbox/hooks';
|
2022-04-10 03:46:25 -07:00
|
|
|
|
2022-09-11 10:28:12 -07:00
|
|
|
import Upload from './upload';
|
|
|
|
import UploadProgress from './upload-progress';
|
2022-04-10 03:46:25 -07:00
|
|
|
|
2022-04-10 05:26:30 -07:00
|
|
|
import type { Attachment as AttachmentEntity } from 'soapbox/types/entities';
|
|
|
|
|
2022-09-10 14:52:06 -07:00
|
|
|
interface IUploadForm {
|
|
|
|
composeId: string,
|
|
|
|
}
|
|
|
|
|
|
|
|
const UploadForm: React.FC<IUploadForm> = ({ composeId }) => {
|
2022-09-14 11:01:00 -07:00
|
|
|
const mediaIds = useCompose(composeId).media_attachments.map((item: AttachmentEntity) => item.id);
|
2022-04-10 03:46:25 -07:00
|
|
|
|
|
|
|
return (
|
2022-12-01 12:32:55 -08:00
|
|
|
<div className='overflow-hidden'>
|
2022-09-10 14:52:06 -07:00
|
|
|
<UploadProgress composeId={composeId} />
|
2022-04-10 03:46:25 -07:00
|
|
|
|
2022-12-01 12:32:55 -08:00
|
|
|
<HStack wrap className={classNames(mediaIds.size !== 0 && 'p-1')}>
|
2022-04-10 03:46:25 -07:00
|
|
|
{mediaIds.map((id: string) => (
|
2022-09-11 10:28:12 -07:00
|
|
|
<Upload id={id} key={id} composeId={composeId} />
|
2022-04-10 03:46:25 -07:00
|
|
|
))}
|
2022-12-01 12:32:55 -08:00
|
|
|
</HStack>
|
2022-04-10 03:46:25 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default UploadForm;
|