Removed children from ShortUrlForm

This commit is contained in:
Alejandro Celaya 2021-03-27 10:41:13 +01:00
parent ca670d810d
commit 1403538660
3 changed files with 19 additions and 19 deletions

View file

@ -43,19 +43,20 @@ const CreateShortUrl = (ShortUrlForm: FC<ShortUrlFormProps>, CreateShortUrlResul
const initialState = useMemo(() => getInitialState(shortUrlCreationSettings), [ shortUrlCreationSettings ]);
return (
<>
<ShortUrlForm
initialState={initialState}
saving={shortUrlCreationResult.saving}
selectedServer={selectedServer}
mode={basicMode ? 'create-basic' : 'create'}
onSave={createShortUrl}
>
/>
<CreateShortUrlResult
{...shortUrlCreationResult}
resetCreateShortUrl={resetCreateShortUrl}
canBeClosed={basicMode}
/>
</ShortUrlForm>
</>
);
};

View file

@ -71,18 +71,19 @@ export const EditShortUrl = (ShortUrlForm: FC<ShortUrlFormProps>) => ({
}
return (
<>
<ShortUrlForm
initialState={getInitialState(shortUrl, shortUrlCreationSettings)}
saving={saving}
selectedServer={selectedServer}
mode="edit"
onSave={async (shortUrlData) => shortUrl && editShortUrl(shortUrl.shortCode, shortUrl.domain, shortUrlData)}
>
/>
{savingError && (
<Result type="error" className="mt-3">
<ShlinkApiError errorData={savingErrorData} fallbackMessage="An error occurred while updating short URL :(" />
</Result>
)}
</ShortUrlForm>
</>
);
};

View file

@ -39,7 +39,7 @@ export const ShortUrlForm = (
TagsSelector: FC<TagsSelectorProps>,
ForServerVersion: FC<Versions>,
DomainSelector: FC<DomainSelectorProps>,
): FC<ShortUrlFormProps> => ({ mode, saving, onSave, initialState, selectedServer, children }) => { // eslint-disable-line complexity
): FC<ShortUrlFormProps> => ({ mode, saving, onSave, initialState, selectedServer }) => { // eslint-disable-line complexity
const [ shortUrlData, setShortUrlData ] = useState(initialState);
const isEdit = mode === 'edit';
const changeTags = (tags: string[]) => setShortUrlData({ ...shortUrlData, tags: tags.map(normalizeTag) });
@ -201,8 +201,6 @@ export const ShortUrlForm = (
{saving ? 'Saving...' : 'Save'}
</Button>
</div>
{children}
</form>
);
};