Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: UX Bug, rearrange provider search #3603

Closed
Matvey-Kuk opened this issue Feb 20, 2025 · 2 comments
Closed

[🐛 Bug]: UX Bug, rearrange provider search #3603

Matvey-Kuk opened this issue Feb 20, 2025 · 2 comments
Labels
Bug Something isn't working UI User interface related issues

Comments

@Matvey-Kuk
Copy link
Contributor

  1. I search for existing providers, I don't see it below my installed and linked providers:
Image
  1. I search for non-existing providers and there is no message showing "We can't find anything"
Image

Proposal:

When we search or filter, put search results on top of installed / linked providers.

Copy link

dosubot bot commented Feb 20, 2025

To address the UX bug and implement the proposed changes, you can modify the ProvidersPage component to rearrange the provider search results above the installed and linked providers, and display a message when no providers are found. Here's how you can do it:

  1. Rearrange the Display Order: Ensure that the search results are displayed before the installed and linked providers by conditionally rendering the search results section first.

  2. Show a Message When No Providers Are Found: Add a conditional check to display a message when the filtered providers array is empty.

Here's a code snippet to implement these changes:

export default function ProvidersPage({
  searchParams,
}: {
  searchParams?: { [key: string]: string };
}) {
  const {
    providers,
    installedProviders,
    linkedProviders,
    isLocalhost,
    mutate,
  } = useFetchProviders();

  const {
    providersSearchString,
    providersSelectedTags,
    providersSelectedCategories,
  } = useFilterContext();

  useEffect(() => {
    if (searchParams?.oauth === "failure") {
      const reason = JSON.parse(searchParams.reason);
      showErrorToast(new Error(`Failed to install provider: ${reason.detail}`));
    } else if (searchParams?.oauth === "success") {
      toast.success("Successfully installed provider", {
        position: toast.POSITION.TOP_LEFT,
      });
    }
  }, [searchParams]);

  if (!providers || !installedProviders || providers.length <= 0) {
    return <Loading />;
  }

  const searchProviders = (provider: Provider) => {
    return (
      !providersSearchString ||
      provider.type?.toLowerCase().includes(providersSearchString.toLowerCase())
    );
  };

  const searchCategories = (provider: Provider) => {
    if (providersSelectedCategories.includes("Coming Soon")) {
      if (provider.coming_soon) {
        return true;
      }
    }

    return (
      providersSelectedCategories.length === 0 ||
      provider.categories.some((category) =>
        providersSelectedCategories.includes(category)
      )
    );
  };

  const searchTags = (provider: Provider) => {
    return (
      providersSelectedTags.length === 0 ||
      provider.tags.some((tag) => providersSelectedTags.includes(tag))
    );
  };

  const filteredProviders = providers.filter(
    (provider) =>
      searchProviders(provider) &&
      searchTags(provider) &&
      searchCategories(provider)
  );

  return (
    <>
      <div className="flex items-center mb-2.5">
        <Title>Search Results</Title>
      </div>
      <div className="flex flex-wrap mb-5 gap-5">
        {filteredProviders.length > 0 ? (
          filteredProviders.map((provider) => (
            <ProviderTile
              key={provider.id}
              provider={provider}
              onClick={() => handleConnectProvider(provider)}
            />
          ))
        ) : (
          <div>No providers found.</div>
        )}
      </div>

      {installedProviders.length > 0 && (
        <ProvidersTiles
          providers={installedProviders}
          installedProvidersMode={true}
          mutate={mutate}
        />
      )}
      {linkedProviders?.length > 0 && (
        <ProvidersTiles
          providers={linkedProviders}
          linkedProvidersMode={true}
          isLocalhost={isLocalhost}
          mutate={mutate}
        />
      )}
    </>
  );
}

This code ensures that the search results are displayed first, and if no providers are found, it shows a "No providers found." message [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot dosubot bot added Bug Something isn't working UI User interface related issues labels Feb 20, 2025
@Matvey-Kuk
Copy link
Contributor Author

Duplicate of #3569

@Matvey-Kuk Matvey-Kuk marked this as a duplicate of #3569 Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working UI User interface related issues
Projects
None yet
Development

No branches or pull requests

1 participant