Skip to content

Commit

Permalink
hide personality results while is loading
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopedro10 committed Nov 15, 2024
1 parent f1efd88 commit 5bff399
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
45 changes: 25 additions & 20 deletions src/components/Personality/PersonalityCreateSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ const PersonalityCreateSearch = ({
setIsFormSubmitted(!isFormSubmitted);
};

const handleInputSearch = (name) => {
const handleInputSearch = async (name) => {
setIsLoading(true);
const trimmedName = name.trim();
dispatch({
type: ActionTypes.SET_SEARCH_NAME,
searchName: trimmedName,
});
setIsLoading(true);
api.getPersonalities(
await api.getPersonalities(
{ withSuggestions, searchName: trimmedName, i18n },
dispatch
)
.finally(() => setIsLoading(false));
);
setIsLoading(false);
};

const personalitiesCreated = personalities.filter(
Expand Down Expand Up @@ -128,21 +128,26 @@ const PersonalityCreateSearch = ({
/>
</Form.Item>
</Form>
{isLoading && <Loading />}
<PersonalitySearchResultSection
selectPersonality={selectPersonality}
personalities={personalitiesCreated}
label={t("personalityCTA:created")}
onClick={onClickSeeProfile}
isFormSubmitted={isFormSubmitted}
/>
<PersonalitySearchResultSection
selectPersonality={selectPersonality}
personalities={personalitiesAvailable}
label={t("personalityCTA:available")}
onClick={createPersonality}
isFormSubmitted={isFormSubmitted}
/>
{isLoading ? (
<Loading />
) : (
<>
<PersonalitySearchResultSection
selectPersonality={selectPersonality}
personalities={personalitiesCreated}
label={t("personalityCTA:created")}
onClick={onClickSeeProfile}
isFormSubmitted={isFormSubmitted}
/>
<PersonalitySearchResultSection
selectPersonality={selectPersonality}
personalities={personalitiesAvailable}
label={t("personalityCTA:available")}
onClick={createPersonality}
isFormSubmitted={isFormSubmitted}
/>
</>
)}
</Row>
);
};
Expand Down
6 changes: 3 additions & 3 deletions src/components/Search/OverlaySearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ const OverlaySearchInput = () => {
};
});

const handleInputSearch = async (searchText) => {
const handleInputSearch = async (name) => {
dispatch(actions.isFetchingResults());
dispatch(actions.openResultsOverlay());
dispatch({
type: ActionTypes.SET_SEARCH_OVERLAY_NAME,
searchOverlayInput: searchText,
searchOverlayInput: name,
});

const { personalities, sentences, claims } =
await SearchApi.getFeedResults({
page,
pageSize,
searchText: searchText,
searchText: name,
nameSpace: nameSpace,
});

Expand Down

0 comments on commit 5bff399

Please sign in to comment.