All files / src/apps/user/pages Organisations.tsx

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                    1x 2x   2x   1x     2x                                          
import React from "react";
import { useQuery } from "@tanstack/react-query";
import { Link } from "react-router-dom";
import { useApiHandler } from "@/services/useApiHandler";
import MainPage from "@/components/page/MainPage/MainPage";
import { QUERY_KEYS } from "@/services/query_keys";
import { APP_ROUTES } from "@/routes/const";
import OrganisationsGrid from "./organisations/OrganisationsGrid";
import { Plus } from "lucide-react";
 
const Organisations: React.FC = () => {
  const { getApiHandler } = useApiHandler();
 
  const { data: organisations, isLoading } = useQuery({
    queryKey: [QUERY_KEYS.GET.ORGANISATIONS],
    queryFn: () => getApiHandler().organisation_router.list(),
  });
 
  return (
    <MainPage
      title="Organisations"
      description="Organisations you own or collaborate in — shared workspaces for teams."
      links={[
        <Link
          to={APP_ROUTES.USER.ORGANISATIONS.new}
          className="flex items-center gap-1.5 px-3 py-2 rounded-lg bg-gray-900 dark:bg-white text-white dark:text-gray-900 text-sm font-medium hover:opacity-80 transition-opacity"
        >
          <Plus className="size-4" />
          New Organisation
        </Link>,
      ]}
    >
      <br />
      <OrganisationsGrid organisations={organisations ?? []} loading={isLoading} />
    </MainPage>
  );
};
 
export default Organisations;