fix: fetch selected project members (#741)

* fix: fetch selected project members

* chore: remove old imports
This commit is contained in:
Aaryan Khandelwal 2023-04-08 13:46:21 +05:30 committed by GitHub
parent 0a3d13706e
commit beedd57ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -44,6 +44,7 @@ export const GithubImportUsers: FC<Props> = ({ handleStepChange, users, setUsers
index={index}
users={users}
setUsers={setUsers}
project={watch("project")}
/>
))}
</div>

View File

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