@@ -164,9 +164,11 @@ export default function FrameworkListPage() {
FrameworkListPageQuery
);
+ const { currentOrganization } = useOrganization();
+
useEffect(() => {
- loadQuery({});
- }, [loadQuery]);
+ loadQuery({ organizationId: currentOrganization!.id });
+ }, [loadQuery, currentOrganization]);
return (
<>
diff --git a/apps/console/src/pages/HomePage.tsx b/apps/console/src/pages/HomePage.tsx
index bd3e558d5..69819d0bb 100644
--- a/apps/console/src/pages/HomePage.tsx
+++ b/apps/console/src/pages/HomePage.tsx
@@ -12,7 +12,7 @@ export const HomePageQuery = graphql`
query HomePageQuery {
viewer {
id
- organization {
+ organizations {
name
createdAt
updatedAt
diff --git a/apps/console/src/pages/PeopleListPage.tsx b/apps/console/src/pages/PeopleListPage.tsx
index 2da4efc33..6881dae94 100644
--- a/apps/console/src/pages/PeopleListPage.tsx
+++ b/apps/console/src/pages/PeopleListPage.tsx
@@ -18,28 +18,34 @@ import type { PeopleListPageQuery as PeopleListPageQueryType } from "./__generat
import type { PeopleListPageDeletePeopleMutation } from "./__generated__/PeopleListPageDeletePeopleMutation.graphql";
import { PeopleListPagePaginationQuery } from "./__generated__/PeopleListPagePaginationQuery.graphql";
import { PeopleListPage_peoples$key } from "./__generated__/PeopleListPage_peoples.graphql";
+import { useOrganization } from "@/contexts/OrganizationContext";
const ITEMS_PER_PAGE = 25;
const peopleListPageQuery = graphql`
query PeopleListPageQuery(
+ $organizationId: ID!
$first: Int
$after: CursorKey
$last: Int
$before: CursorKey
) {
- viewer {
- id
- organization {
- ...PeopleListPage_peoples
- }
+ organization: node(id: $organizationId) {
+ ...PeopleListPage_peoples
+ @arguments(first: $first, after: $after, last: $last, before: $before)
}
}
`;
const peopleListFragment = graphql`
fragment PeopleListPage_peoples on Organization
- @refetchable(queryName: "PeopleListPagePaginationQuery") {
+ @refetchable(queryName: "PeopleListPagePaginationQuery")
+ @argumentDefinitions(
+ first: { type: "Int" }
+ after: { type: "CursorKey" }
+ last: { type: "Int" }
+ before: { type: "CursorKey" }
+ ) {
id
peoples(first: $first, after: $after, last: $last, before: $before)
@connection(key: "PeopleListPage_peoples") {
@@ -147,7 +153,7 @@ function PeopleListContent({
} = usePaginationFragment<
PeopleListPagePaginationQuery,
PeopleListPage_peoples$key
- >(peopleListFragment, data.viewer.organization);
+ >(peopleListFragment, data.organization);
const peoples =
peoplesConnection.peoples.edges.map((edge) => edge.node) ?? [];
@@ -301,17 +307,20 @@ export default function PeopleListPage() {
const [queryRef, loadQuery] =
useQueryLoader
(peopleListPageQuery);
+ const { currentOrganization } = useOrganization();
+
useEffect(() => {
const after = searchParams.get("after");
const before = searchParams.get("before");
loadQuery({
+ organizationId: currentOrganization!.id,
first: before ? undefined : ITEMS_PER_PAGE,
after: after || undefined,
last: before ? ITEMS_PER_PAGE : undefined,
before: before || undefined,
});
- }, [loadQuery]);
+ }, [loadQuery, currentOrganization]);
if (!queryRef) {
return ;
diff --git a/apps/console/src/pages/SettingsPage.tsx b/apps/console/src/pages/SettingsPage.tsx
index edf7d0d2a..048c71ef9 100644
--- a/apps/console/src/pages/SettingsPage.tsx
+++ b/apps/console/src/pages/SettingsPage.tsx
@@ -28,7 +28,7 @@ const settingsPageQuery = graphql`
query SettingsPageQuery {
viewer {
id
- organization {
+ organizations {
name
logoUrl
}
@@ -49,7 +49,7 @@ function SettingsPageContent({
queryRef: PreloadedQuery;
}) {
const data = usePreloadedQuery(settingsPageQuery, queryRef);
- const organization = data.viewer.organization;
+ const organization = data.viewer.organizations[0];
const members: Member[] = [];
return (
diff --git a/apps/console/src/pages/VendorListPage.tsx b/apps/console/src/pages/VendorListPage.tsx
index 26eeaa95a..371140bf1 100644
--- a/apps/console/src/pages/VendorListPage.tsx
+++ b/apps/console/src/pages/VendorListPage.tsx
@@ -22,28 +22,35 @@ import { VendorListPageDeleteVendorMutation } from "./__generated__/VendorListPa
import { toast } from "@/hooks/use-toast";
import { VendorListPagePaginationQuery } from "./__generated__/VendorListPagePaginationQuery.graphql";
import { VendorListPage_vendors$key } from "./__generated__/VendorListPage_vendors.graphql";
+import { useToast } from "@/hooks/use-toast";
+import { useOrganization } from "@/contexts/OrganizationContext";
const ITEMS_PER_PAGE = 25;
const vendorListPageQuery = graphql`
query VendorListPageQuery(
+ $organizationId: ID!
$first: Int
$after: CursorKey
$last: Int
$before: CursorKey
) {
- viewer {
- id
- organization {
- ...VendorListPage_vendors
- }
+ organization: node(id: $organizationId) {
+ ...VendorListPage_vendors
+ @arguments(first: $first, after: $after, last: $last, before: $before)
}
}
`;
const vendorListFragment = graphql`
fragment VendorListPage_vendors on Organization
- @refetchable(queryName: "VendorListPagePaginationQuery") {
+ @refetchable(queryName: "VendorListPagePaginationQuery")
+ @argumentDefinitions(
+ first: { type: "Int" }
+ after: { type: "CursorKey" }
+ last: { type: "Int" }
+ before: { type: "CursorKey" }
+ ) {
id
vendors(first: $first, after: $after, last: $last, before: $before)
@connection(key: "VendorListPage_vendors") {
@@ -96,8 +103,15 @@ const deleteVendorMutation = graphql`
}
`;
+// Define a proper type for the vendor items
+interface VendorItem {
+ id: string;
+ name: string;
+ createdAt: string;
+}
+
// TODO: Remove this once we have a real list of vendors
-const vendorsList = [
+const vendorsList: VendorItem[] = [
{ id: "1", name: "Amazon Web Services", createdAt: new Date().toISOString() },
{
id: "2",
@@ -172,6 +186,7 @@ function VendorListContent({
}: {
queryRef: PreloadedQuery;
}) {
+ const { toast } = useToast();
const data = usePreloadedQuery(
vendorListPageQuery,
queryRef
@@ -179,7 +194,7 @@ function VendorListContent({
const [searchParams, setSearchParams] = useSearchParams();
const [isPending, startTransition] = useTransition();
const [searchTerm, setSearchTerm] = useState("");
- const [filteredVendors, setFilteredVendors] = useState>([]);
+ const [filteredVendors, setFilteredVendors] = useState([]);
const [createVendor] =
useMutation(createVendorMutation);
const [deleteVendor] =
@@ -196,7 +211,7 @@ function VendorListContent({
} = usePaginationFragment<
VendorListPagePaginationQuery,
VendorListPage_vendors$key
- >(vendorListFragment, data.viewer.organization);
+ >(vendorListFragment, data.organization);
const vendors =
vendorsConnection.vendors.edges.map((edge) => edge.node) ?? [];
@@ -245,7 +260,7 @@ function VendorListContent({
style={{ borderRadius: "0.3rem" }}
className="absolute top-full left-0 mt-1 w-[calc(100%-100px)] max-h-48 overflow-y-auto border bg-popover shadow-md z-10"
>
- {filteredVendors.map((vendor) => (
+ {filteredVendors.map((vendor: VendorItem) => (