mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
#58 using formik at node submit form
This commit is contained in:
parent
4b542e0291
commit
b871cc2042
17 changed files with 230 additions and 423 deletions
|
@ -6,29 +6,18 @@ import { selectUploads } from '~/redux/uploads/selectors';
|
|||
import { ImageGrid } from '~/components/editors/ImageGrid';
|
||||
import styles from './styles.module.scss';
|
||||
import { NodeEditorProps } from '~/redux/node/types';
|
||||
import { useFileUploaderContext } from '~/utils/hooks/fileUploader';
|
||||
|
||||
const mapStateToProps = selectUploads;
|
||||
const mapDispatchToProps = {
|
||||
uploadUploadFiles: UPLOAD_ACTIONS.uploadUploadFiles,
|
||||
};
|
||||
type IProps = NodeEditorProps;
|
||||
|
||||
type IProps = ReturnType<typeof mapStateToProps> & typeof mapDispatchToProps & NodeEditorProps;
|
||||
|
||||
const ImageEditorUnconnected: FC<IProps> = ({ data, setData, temp, statuses }) => {
|
||||
const pending_files = useMemo(() => temp.filter(id => !!statuses[id]).map(id => statuses[id]), [
|
||||
temp,
|
||||
statuses,
|
||||
]);
|
||||
|
||||
const setFiles = useCallback((files: IFile[]) => setData({ ...data, files }), [data, setData]);
|
||||
const ImageEditor: FC<IProps> = () => {
|
||||
const { pending, files, setFiles } = useFileUploaderContext()!;
|
||||
|
||||
return (
|
||||
<div className={styles.wrap}>
|
||||
<ImageGrid files={data.files} setFiles={setFiles} locked={pending_files} />
|
||||
<ImageGrid files={files} setFiles={setFiles} locked={pending} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const ImageEditor = connect(mapStateToProps, mapDispatchToProps)(ImageEditorUnconnected);
|
||||
|
||||
export { ImageEditor };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue