Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Dec 4, 2023
1 parent d992f29 commit efddf73
Show file tree
Hide file tree
Showing 12 changed files with 371 additions and 392 deletions.
19 changes: 13 additions & 6 deletions databox/client/src/components/Dialog/Collection/EditCollection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Collection} from '../../../types';
import {putCollection} from '../../../api/collection';
import {clearWorkspaceCache, postCollection, putCollection} from '../../../api/collection';
import {useTranslation} from 'react-i18next';
import {toast} from 'react-toastify';
import {useFormSubmit} from '@alchemy/api';
Expand All @@ -17,7 +17,11 @@ type Props = {
export default function EditCollection({data, onClose, minHeight}: Props) {
const {t} = useTranslation();

const {submitting, submitted, handleSubmit, errors} = useFormSubmit({
const usedFormSubmit = useFormSubmit({
defaultValues: {
title: '',
privacy: 0,
},
onSubmit: async (data: Collection) => {
return await putCollection(data.id, data);
},
Expand All @@ -32,22 +36,25 @@ export default function EditCollection({data, onClose, minHeight}: Props) {
},
});

const {
submitting,
remoteErrors,
} = usedFormSubmit;

const formId = 'edit-collection';

return (
<FormTab
onClose={onClose}
formId={formId}
loading={submitting}
errors={errors}
errors={remoteErrors}
minHeight={minHeight}
>
<CollectionForm
usedFormSubmit={usedFormSubmit}
data={data}
formId={formId}
onSubmit={handleSubmit}
submitting={submitting}
submitted={submitted}
/>
</FormTab>
);
Expand Down
Loading

0 comments on commit efddf73

Please sign in to comment.