@@ -30,7 +30,7 @@ import {
|
|||||||
SidebarMenuItem,
|
SidebarMenuItem,
|
||||||
} from "@/components/ui/sidebar";
|
} from "@/components/ui/sidebar";
|
||||||
import type { AppSidebarQuery as AppSidebarQueryType } from "./__generated__/AppSidebarQuery.graphql";
|
import type { AppSidebarQuery as AppSidebarQueryType } from "./__generated__/AppSidebarQuery.graphql";
|
||||||
import { TeamSwitcher } from "@/components/TeamSwitcher";
|
import { OrganizationSwitcher } from "@/components/OrganizationSwitcher";
|
||||||
|
|
||||||
function getNavItems(organizationId?: string) {
|
function getNavItems(organizationId?: string) {
|
||||||
// Always return the same structure, but with or without URLs depending on whether an organization is selected
|
// Always return the same structure, but with or without URLs depending on whether an organization is selected
|
||||||
@@ -91,7 +91,7 @@ const AppSidebarQuery = graphql`
|
|||||||
query AppSidebarQuery {
|
query AppSidebarQuery {
|
||||||
viewer {
|
viewer {
|
||||||
id
|
id
|
||||||
...TeamSwitcher_organizations
|
...OrganizationSwitcher_organizations
|
||||||
...NavUser_viewer
|
...NavUser_viewer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ function AppSidebarContent({
|
|||||||
return (
|
return (
|
||||||
<Sidebar variant="inset" {...props}>
|
<Sidebar variant="inset" {...props}>
|
||||||
<SidebarHeader>
|
<SidebarHeader>
|
||||||
<TeamSwitcher organizations={data.viewer} />
|
<OrganizationSwitcher organizations={data.viewer} />
|
||||||
</SidebarHeader>
|
</SidebarHeader>
|
||||||
<SidebarContent>
|
<SidebarContent>
|
||||||
<NavMain items={navItems.navMain} />
|
<NavMain items={navItems.navMain} />
|
||||||
|
|||||||
@@ -21,13 +21,14 @@ import {
|
|||||||
useSidebar,
|
useSidebar,
|
||||||
} from "@/components/ui/sidebar";
|
} from "@/components/ui/sidebar";
|
||||||
import {
|
import {
|
||||||
TeamSwitcher_organizations$key,
|
OrganizationSwitcher_organizations$key,
|
||||||
TeamSwitcher_organizations$data,
|
OrganizationSwitcher_organizations$data,
|
||||||
} from "./__generated__/TeamSwitcher_organizations.graphql";
|
} from "./__generated__/OrganizationSwitcher_organizations.graphql";
|
||||||
|
|
||||||
export const teamSwitcherFragment = graphql`
|
export const organizationSwitcherFragment = graphql`
|
||||||
fragment TeamSwitcher_organizations on User {
|
fragment OrganizationSwitcher_organizations on User {
|
||||||
organizations(first: 25) @connection(key: "TeamSwitcher_organizations") {
|
organizations(first: 25)
|
||||||
|
@connection(key: "OrganizationSwitcher_organizations") {
|
||||||
__id
|
__id
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
@@ -41,7 +42,7 @@ export const teamSwitcherFragment = graphql`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
type Organization =
|
type Organization =
|
||||||
TeamSwitcher_organizations$data["organizations"]["edges"][0]["node"];
|
OrganizationSwitcher_organizations$data["organizations"]["edges"][0]["node"];
|
||||||
|
|
||||||
const LogoComponent = ({
|
const LogoComponent = ({
|
||||||
org,
|
org,
|
||||||
@@ -56,13 +57,13 @@ const LogoComponent = ({
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function TeamSwitcher({
|
export function OrganizationSwitcher({
|
||||||
organizations,
|
organizations,
|
||||||
}: {
|
}: {
|
||||||
organizations: TeamSwitcher_organizations$key;
|
organizations: OrganizationSwitcher_organizations$key;
|
||||||
}) {
|
}) {
|
||||||
const { isMobile } = useSidebar();
|
const { isMobile } = useSidebar();
|
||||||
const data = useFragment(teamSwitcherFragment, organizations);
|
const data = useFragment(organizationSwitcherFragment, organizations);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { organizationId } = useParams();
|
const { organizationId } = useParams();
|
||||||
const [currentOrganization, setCurrentOrganization] =
|
const [currentOrganization, setCurrentOrganization] =
|
||||||
@@ -73,7 +74,7 @@ export function TeamSwitcher({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasOrganizations) {
|
if (hasOrganizations) {
|
||||||
const org = data.organizations.edges.find(
|
const org = data.organizations.edges.find(
|
||||||
(edge) => edge.node.id === organizationId,
|
(edge) => edge.node.id === organizationId
|
||||||
);
|
);
|
||||||
if (org) {
|
if (org) {
|
||||||
setCurrentOrganization(org.node);
|
setCurrentOrganization(org.node);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<a1cc304a7eb154a19a1ec9a68c2cda98>>
|
* @generated SignedSource<<d4b79299641fcf7b2547eec4064af57a>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -14,7 +14,7 @@ export type AppSidebarQuery$variables = Record<PropertyKey, never>;
|
|||||||
export type AppSidebarQuery$data = {
|
export type AppSidebarQuery$data = {
|
||||||
readonly viewer: {
|
readonly viewer: {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
readonly " $fragmentSpreads": FragmentRefs<"NavUser_viewer" | "TeamSwitcher_organizations">;
|
readonly " $fragmentSpreads": FragmentRefs<"NavUser_viewer" | "OrganizationSwitcher_organizations">;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
export type AppSidebarQuery = {
|
export type AppSidebarQuery = {
|
||||||
@@ -56,7 +56,7 @@ return {
|
|||||||
{
|
{
|
||||||
"args": null,
|
"args": null,
|
||||||
"kind": "FragmentSpread",
|
"kind": "FragmentSpread",
|
||||||
"name": "TeamSwitcher_organizations"
|
"name": "OrganizationSwitcher_organizations"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"args": null,
|
"args": null,
|
||||||
@@ -189,7 +189,7 @@ return {
|
|||||||
"args": (v1/*: any*/),
|
"args": (v1/*: any*/),
|
||||||
"filters": null,
|
"filters": null,
|
||||||
"handle": "connection",
|
"handle": "connection",
|
||||||
"key": "TeamSwitcher_organizations",
|
"key": "OrganizationSwitcher_organizations",
|
||||||
"kind": "LinkedHandle",
|
"kind": "LinkedHandle",
|
||||||
"name": "organizations"
|
"name": "organizations"
|
||||||
},
|
},
|
||||||
@@ -213,16 +213,16 @@ return {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
"cacheID": "52b7d912665a4da10a79b82987a7e58a",
|
"cacheID": "d92e5e742128d82b461ab1b6d52cd2a6",
|
||||||
"id": null,
|
"id": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"name": "AppSidebarQuery",
|
"name": "AppSidebarQuery",
|
||||||
"operationKind": "query",
|
"operationKind": "query",
|
||||||
"text": "query AppSidebarQuery {\n viewer {\n id\n ...TeamSwitcher_organizations\n ...NavUser_viewer\n }\n}\n\nfragment NavUser_viewer on User {\n id\n fullName\n email\n}\n\nfragment TeamSwitcher_organizations on User {\n organizations(first: 25) {\n edges {\n node {\n id\n name\n logoUrl\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n"
|
"text": "query AppSidebarQuery {\n viewer {\n id\n ...OrganizationSwitcher_organizations\n ...NavUser_viewer\n }\n}\n\nfragment NavUser_viewer on User {\n id\n fullName\n email\n}\n\nfragment OrganizationSwitcher_organizations on User {\n organizations(first: 25) {\n edges {\n node {\n id\n name\n logoUrl\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n}\n"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
(node as any).hash = "d5e28d934b5913169dd822042f4eca07";
|
(node as any).hash = "ebe1f481a1454380e017fb976b8bb8a5";
|
||||||
|
|
||||||
export default node;
|
export default node;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<a4a57a018956ccc09931f2b2ce87c933>>
|
* @generated SignedSource<<e71f99685baea9efcb9f603d577f7412>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
import { ReaderFragment } from 'relay-runtime';
|
import { ReaderFragment } from 'relay-runtime';
|
||||||
import { FragmentRefs } from "relay-runtime";
|
import { FragmentRefs } from "relay-runtime";
|
||||||
export type TeamSwitcher_organizations$data = {
|
export type OrganizationSwitcher_organizations$data = {
|
||||||
readonly organizations: {
|
readonly organizations: {
|
||||||
readonly __id: string;
|
readonly __id: string;
|
||||||
readonly edges: ReadonlyArray<{
|
readonly edges: ReadonlyArray<{
|
||||||
@@ -21,11 +21,11 @@ export type TeamSwitcher_organizations$data = {
|
|||||||
};
|
};
|
||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
readonly " $fragmentType": "TeamSwitcher_organizations";
|
readonly " $fragmentType": "OrganizationSwitcher_organizations";
|
||||||
};
|
};
|
||||||
export type TeamSwitcher_organizations$key = {
|
export type OrganizationSwitcher_organizations$key = {
|
||||||
readonly " $data"?: TeamSwitcher_organizations$data;
|
readonly " $data"?: OrganizationSwitcher_organizations$data;
|
||||||
readonly " $fragmentSpreads": FragmentRefs<"TeamSwitcher_organizations">;
|
readonly " $fragmentSpreads": FragmentRefs<"OrganizationSwitcher_organizations">;
|
||||||
};
|
};
|
||||||
|
|
||||||
const node: ReaderFragment = {
|
const node: ReaderFragment = {
|
||||||
@@ -43,14 +43,14 @@ const node: ReaderFragment = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"name": "TeamSwitcher_organizations",
|
"name": "OrganizationSwitcher_organizations",
|
||||||
"selections": [
|
"selections": [
|
||||||
{
|
{
|
||||||
"alias": "organizations",
|
"alias": "organizations",
|
||||||
"args": null,
|
"args": null,
|
||||||
"concreteType": "OrganizationConnection",
|
"concreteType": "OrganizationConnection",
|
||||||
"kind": "LinkedField",
|
"kind": "LinkedField",
|
||||||
"name": "__TeamSwitcher_organizations_connection",
|
"name": "__OrganizationSwitcher_organizations_connection",
|
||||||
"plural": false,
|
"plural": false,
|
||||||
"selections": [
|
"selections": [
|
||||||
{
|
{
|
||||||
@@ -155,6 +155,6 @@ const node: ReaderFragment = {
|
|||||||
"abstractKey": null
|
"abstractKey": null
|
||||||
};
|
};
|
||||||
|
|
||||||
(node as any).hash = "22731866cafda226a19f8c64fda51ba5";
|
(node as any).hash = "8150704a009e88c096c6f6aa13cada52";
|
||||||
|
|
||||||
export default node;
|
export default node;
|
||||||
@@ -86,11 +86,11 @@ export default function CreateOrganizationPage() {
|
|||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const data = useLazyLoadQuery<CreateOrganizationPageViewerQuery>(
|
const data = useLazyLoadQuery<CreateOrganizationPageViewerQuery>(
|
||||||
viewerQuery,
|
viewerQuery,
|
||||||
{},
|
{}
|
||||||
);
|
);
|
||||||
const [createOrganization] =
|
const [createOrganization] =
|
||||||
useMutation<CreateOrganizationPageCreateOrganizationMutation>(
|
useMutation<CreateOrganizationPageCreateOrganizationMutation>(
|
||||||
createOrganizationMutation,
|
createOrganizationMutation
|
||||||
);
|
);
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
@@ -114,7 +114,7 @@ export default function CreateOrganizationPage() {
|
|||||||
connections: [
|
connections: [
|
||||||
ConnectionHandler.getConnectionID(
|
ConnectionHandler.getConnectionID(
|
||||||
data.viewer.id,
|
data.viewer.id,
|
||||||
"TeamSwitcher_organizations",
|
"OrganizationSwitcher_organizations"
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user