Skip to content

Commit

Permalink
Add members
Browse files Browse the repository at this point in the history
  • Loading branch information
kplatis committed Apr 11, 2024
1 parent 1356086 commit 4cc56ef
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/components/VirtualLab/VirtualLabHomePage/Member.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import VirtualLabMemberIcon from '../VirtualLabMemberIcon';
import { MockRole } from '@/types/virtual-lab/members';
import { Role } from '@/types/virtual-lab/members';

type Props = {
name: string;
lastActive: string;
memberRole: MockRole;
memberRole: Role;
};

export default function Member({ name, lastActive, memberRole }: Props) {
Expand Down
11 changes: 5 additions & 6 deletions src/components/VirtualLab/VirtualLabHomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import WelcomeUserBanner from './WelcomeUserBanner';
import { basePath } from '@/config';
import { MembersGroupIcon, StatsEditIcon } from '@/components/icons';
import Brain from '@/components/icons/Brain';
import { mockMembers } from '@/components/VirtualLab/mockData/members';
import { mockProjects } from '@/components/VirtualLab/mockData/projects';
import { mockVirtualLab } from '@/components/VirtualLab/mockData/lab';
import { virtualLabDetailAtomFamily } from '@/state/virtual-lab/lab';
Expand Down Expand Up @@ -159,12 +158,12 @@ export default function VirtualLabHomePage({ id }: Props) {
<div>
<div className="my-5 text-lg font-bold uppercase">Members</div>
<div className="flex-no-wrap flex overflow-x-auto overflow-y-hidden">
{mockMembers.map((member) => (
{virtualLabDetail.data.users.map((user) => (
<Member
key={member.key}
name={member.name}
lastActive={member.lastActive}
memberRole={member.role}
key={user.id}
name={`${user.first_name} ${user.last_name}`}
lastActive="N/A"
memberRole={user.role}
/>
))}
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/components/VirtualLab/VirtualLabMemberIcon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { MockRole } from '@/types/virtual-lab/members';
import { Role } from "@/types/virtual-lab/members";


type Props = {
role: MockRole;
role: Role;
name: string;
};

Expand Down
15 changes: 14 additions & 1 deletion src/components/VirtualLab/VirtualLabSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ export default function VirtualLabSidebar({ virtualLabId }: Props) {
return null;
};

/**
* Returns the amount of virtual lab members
*/
const renderUsersAmount = () => {
if (virtualLab.state === 'loading') {
return <Spin indicator={<LoadingOutlined />} />;
}
if (virtualLab.state === 'hasData') {
return virtualLab.data.users.length;
}
return null;
};

const linkItems: LinkItem[] = [
{ key: 'lab', content: 'The Virtual Lab', href: 'lab' },
{
Expand All @@ -67,7 +80,7 @@ export default function VirtualLabSidebar({ virtualLabId }: Props) {
content: (
<div className="flex justify-between">
<span>Team</span>
<span className="font-normal text-primary-3">23 members</span>
<span className="font-normal text-primary-3">{renderUsersAmount()} members</span>
</div>
),
href: 'team',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ export default function VirtualLabProjectItem({ project }: Props) {
<VirtualLabStatistic
icon={<EyeTargetIcon style={iconStyle} />}
title="Explore sessions"
detail={350}
detail="N/A"
/>
<VirtualLabStatistic icon={<Brain style={iconStyle} />} title="Builds" detail={18} />
<VirtualLabStatistic icon={<Brain style={iconStyle} />} title="Builds" detail="N/A" />
<VirtualLabStatistic
icon={<StatsEditIcon style={iconStyle} />}
title="Simulation experiments"
detail={30}
detail="N/A"
/>
<VirtualLabStatistic
icon={<UserOutlined style={iconStyle} />}
Expand Down
3 changes: 2 additions & 1 deletion src/services/virtual-lab/labs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Project } from '@/types/virtual-lab/projects';

// Add the bearer token from the frontend below
// This constant will be replaced by the actual login token as soon as login is implemented
const accessToken = 'Bearer <TOKEN>';
const accessToken =
'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJza2hnaTdjRWxFbEJzRFpnZXh1NGlvSzBNV081eGtQbWlXWENYang4eHVrIn0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4gHnVWSE6-quqxOd7dlhJAn3o96Qh4WG-n_e0L1DbGs9-TvQbHNHQUFn5C4h9wpL_LW2VMPbPqyuS6mqDXIINl0yBARkUdq548eKRF37d4rMuk5p8yDnBqq-Fv-hbVfDj-MGOEYIzdzwiInv6uSjht-nqqwQ';

export async function getVirtualLabDetail(id: string): Promise<VirtualLabAPIResponse> {
const response = await fetch(`${virtualLabApi.url}/virtual-labs/${id}`, {
Expand Down
3 changes: 1 addition & 2 deletions src/types/virtual-lab/lab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type VirtualLab = {
reference_email: string;
budget: number;
plan_id: number;
users: VirtualLabMember[];
};

export enum VirtualLabPlanType {
Expand All @@ -17,8 +18,6 @@ export enum VirtualLabPlanType {
advanced = 'advanced',
}

export type NewMember = Pick<VirtualLabMember, 'email' | 'role'>;

export type MockBilling = {
organization: string;
firstname: string;
Expand Down
12 changes: 9 additions & 3 deletions src/types/virtual-lab/members.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
export type MockRole = 'administrator' | 'member';

export type Role = 'admin' | 'member';

export type MockMember = {
key: string;
name: string;
lastActive: string;
role: MockRole;
};
export interface VirtualLabMember {
id: string;
username: string;
created_at: string;
first_name: string;
last_name: string;
invite_accepted: boolean;
role: Role;
name: string;
email: string;
role: 'admin' | 'user';
lastActive?: number;
}

0 comments on commit 4cc56ef

Please sign in to comment.