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 ]); const initialState = useMemo(() => getInitialState(shortUrlCreationSettings), [ shortUrlCreationSettings ]);
return ( return (
<ShortUrlForm <>
initialState={initialState} <ShortUrlForm
saving={shortUrlCreationResult.saving} initialState={initialState}
selectedServer={selectedServer} saving={shortUrlCreationResult.saving}
mode={basicMode ? 'create-basic' : 'create'} selectedServer={selectedServer}
onSave={createShortUrl} mode={basicMode ? 'create-basic' : 'create'}
> onSave={createShortUrl}
/>
<CreateShortUrlResult <CreateShortUrlResult
{...shortUrlCreationResult} {...shortUrlCreationResult}
resetCreateShortUrl={resetCreateShortUrl} resetCreateShortUrl={resetCreateShortUrl}
canBeClosed={basicMode} canBeClosed={basicMode}
/> />
</ShortUrlForm> </>
); );
}; };

View file

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

View file

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