Skip to content

Commit

Permalink
791:resolved typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
myapos committed Mar 15, 2024
1 parent 6909c25 commit 9d58852
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
9 changes: 7 additions & 2 deletions backend/src/db/schemas/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import { z } from "zod";

export const MemberSchema = z.object({
id: z.string(),
inviteEmail: z.string().nullable(),
orgId: z.string(),
role: z.string(),
roleId: z.string().nullable(),
status: z.string(),
projects: z.array(z.string()).nullable(),
email: z.string(),
firstName: z.string(),
lastName: z.string(),
userId: z.string(),
publicKey: z.string(),
projects: z.string().array()
publicKey: z.string()
});

export type MemberProps = z.infer<typeof MemberSchema>;
Expand Down
14 changes: 9 additions & 5 deletions backend/src/services/org/org-dal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,15 @@ export const orgDALFactory = (db: TDbClient) => {
`${TableName.UserEncryptionKey}.publicKey`
);

return members.map(({ email, firstName, lastName, userId, publicKey, projects, ...data }) => ({
...data,
projects: projects || [],
user: { email, firstName, lastName, id: userId, publicKey }
}));
const users = members.map(({ email, firstName, lastName, userId, publicKey, projects, ...data }) => {
return {
...data,
projects: projects || [],
user: { email, firstName, lastName, id: userId, publicKey }
};
});

return users;
} catch (error) {
throw new DatabaseError({ error, name: "Find all org members" });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ import useFilteredProjects from "./hooks/useFilteredProjects";
import useInitialCheckedProjects from "./hooks/useInitialCheckedProjects";
import ProjectsTable from "./projectsTable/ProjectsTable";
import addProjectFormSchema from "./utils/addProjectFormSchema";
import { CheckboxKeys, CheckedProjectsMap, Props } from "./types";
import { CheckboxKeys, CheckedProjectsMap, DataProps, Props } from "./types";

type TAddProjectForm = yup.InferType<typeof addProjectFormSchema>;

export const AddProjectModal = ({ popUp, handlePopUpToggle, handlePopUpClose }: Props) => {
const { createNotification } = useNotificationContext();
const { currentOrg } = useOrganization();
const { workspaces } = useWorkspace();
const email = popUp.addProject?.data?.email || "";
const userProjects = useMemo(() => popUp.addProject?.data?.projects || [], [popUp.addProject]);
const data = popUp.addProject?.data as DataProps;

const email = data?.email || "";
const userProjects = useMemo(() => data?.projects || [], [popUp.addProject]);

const { data: serverDetails } = useFetchServerStatus();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export enum CheckboxKeys {
ALL = "all"
}

export type DataProps = {
email: string;
projects: string[];
};
export type CheckedProjectsMap = Record<string, boolean>;

export type ProjectsTableProps = {
Expand Down

0 comments on commit 9d58852

Please sign in to comment.