chore: show workspace members (#852)

This commit is contained in:
Aaryan Khandelwal 2023-04-17 16:41:16 +05:30 committed by GitHub
parent f5351e4419
commit dc53708109
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 19 deletions

View File

@ -1,7 +1,5 @@
import { FC } from "react"; import { FC } from "react";
import { useRouter } from "next/router";
// react-hook-form // react-hook-form
import { UseFormWatch } from "react-hook-form"; import { UseFormWatch } from "react-hook-form";
// ui // ui
@ -22,8 +20,6 @@ type Props = {
}; };
export const GithubImportUsers: FC<Props> = ({ handleStepChange, users, setUsers, watch }) => { export const GithubImportUsers: FC<Props> = ({ handleStepChange, users, setUsers, watch }) => {
const router = useRouter();
const isInvalid = users.filter((u) => u.import !== false && u.email === "").length > 0; const isInvalid = users.filter((u) => u.import !== false && u.email === "").length > 0;
return ( return (
@ -44,7 +40,6 @@ export const GithubImportUsers: FC<Props> = ({ handleStepChange, users, setUsers
index={index} index={index}
users={users} users={users}
setUsers={setUsers} setUsers={setUsers}
project={watch("project")}
/> />
))} ))}
</div> </div>

View File

@ -4,21 +4,20 @@ import { useRouter } from "next/router";
import useSWR from "swr"; import useSWR from "swr";
// services // services
import projectService from "services/project.service"; import workspaceService from "services/workspace.service";
// ui // ui
import { Avatar, CustomSearchSelect, CustomSelect, Input } from "components/ui"; import { Avatar, CustomSearchSelect, CustomSelect, Input } from "components/ui";
// types // types
import { IGithubRepoCollaborator } from "types"; import { IGithubRepoCollaborator } from "types";
import { IUserDetails } from "./root"; import { IUserDetails } from "./root";
// fetch-keys // fetch-keys
import { PROJECT_MEMBERS } from "constants/fetch-keys"; import { WORKSPACE_MEMBERS } from "constants/fetch-keys";
type Props = { type Props = {
collaborator: IGithubRepoCollaborator; collaborator: IGithubRepoCollaborator;
index: number; index: number;
users: IUserDetails[]; users: IUserDetails[];
setUsers: React.Dispatch<React.SetStateAction<IUserDetails[]>>; setUsers: React.Dispatch<React.SetStateAction<IUserDetails[]>>;
project: string | null;
}; };
const importOptions = [ const importOptions = [
@ -36,21 +35,13 @@ const importOptions = [
}, },
]; ];
export const SingleUserSelect: React.FC<Props> = ({ export const SingleUserSelect: React.FC<Props> = ({ collaborator, index, users, setUsers }) => {
collaborator,
index,
users,
setUsers,
project,
}) => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;
const { data: members } = useSWR( const { data: members } = useSWR(
workspaceSlug && project ? PROJECT_MEMBERS(project) : null, workspaceSlug ? WORKSPACE_MEMBERS(workspaceSlug.toString()) : null,
workspaceSlug && project workspaceSlug ? () => workspaceService.workspaceMembers(workspaceSlug.toString()) : null
? () => projectService.projectMembers(workspaceSlug as string, project)
: null
); );
const options = const options =