v1.0
- added task rendering instead of molecule - fied a lot of errors - changes experiment page to show generic experiment info
This commit is contained in:
@@ -1,16 +1,26 @@
|
||||
import { Card, Text, UnstyledButton } from "@mantine/core";
|
||||
import { IconCancel, IconCheck, IconTrash } from "@tabler/icons-react";
|
||||
import type { MouseEvent } from "react";
|
||||
import { Card, NumberInput, Text, UnstyledButton } from "@mantine/core";
|
||||
import {
|
||||
IconCancel,
|
||||
IconCheck,
|
||||
IconPencil,
|
||||
IconTrash,
|
||||
} from "@tabler/icons-react";
|
||||
import { useState, type MouseEvent } from "react";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
import type { SystemTeamData, SystemWithTeams } from "Types/Machine/Machine";
|
||||
import { removeSystemFromTeam } from "Api/QuantumBackend/MachineManagment";
|
||||
import {
|
||||
giveSystemToTeam,
|
||||
removeSystemFromTeam,
|
||||
} from "Api/QuantumBackend/MachineManagment";
|
||||
import { useDeviceStore } from "Stores/DeviceStore";
|
||||
|
||||
function TeamInMachineListCard(props: {
|
||||
team: SystemTeamData;
|
||||
system: SystemWithTeams;
|
||||
}) {
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const { updateDevice } = useDeviceStore();
|
||||
const [count, setCount] = useState(props.team.num_qubits);
|
||||
|
||||
const handleRemovePerm = () => {
|
||||
// TODO: fix delete
|
||||
@@ -76,7 +86,69 @@ function TeamInMachineListCard(props: {
|
||||
flexDirection: "row",
|
||||
}}
|
||||
>
|
||||
<Text>Количество кубит: {props.team.num_qubits}</Text>
|
||||
{isEditing && (
|
||||
<>
|
||||
<Text>Количество кубит: </Text>
|
||||
<NumberInput
|
||||
value={count}
|
||||
onChange={(ev) => {
|
||||
setCount(Number(ev.valueOf()));
|
||||
}}
|
||||
></NumberInput>
|
||||
<UnstyledButton
|
||||
onClick={() => {
|
||||
giveSystemToTeam({
|
||||
system_id: props.system.system.id,
|
||||
team_id: props.team.team.team_id,
|
||||
qubits_given: count,
|
||||
}).then(() => {
|
||||
const team = props.system.teams.find((t) => {
|
||||
return t.team.team_id == props.team.team.team_id;
|
||||
});
|
||||
if (team) {
|
||||
const updatedItem = { ...team, num_qubits: count };
|
||||
|
||||
// Create new array with the updated item in the same position
|
||||
const updatedItems = props.system.teams.map(
|
||||
(currentItem) =>
|
||||
currentItem.team.team_id === team.team.team_id
|
||||
? updatedItem
|
||||
: currentItem,
|
||||
);
|
||||
|
||||
updateDevice(props.system.system.id, {
|
||||
teams: updatedItems,
|
||||
});
|
||||
}
|
||||
|
||||
setIsEditing(false);
|
||||
});
|
||||
}}
|
||||
>
|
||||
<IconCheck size={25} />
|
||||
</UnstyledButton>
|
||||
<UnstyledButton
|
||||
onClick={() => {
|
||||
setCount(props.team.num_qubits);
|
||||
setIsEditing(false);
|
||||
}}
|
||||
>
|
||||
<IconCancel size={25} />
|
||||
</UnstyledButton>
|
||||
</>
|
||||
)}
|
||||
{!isEditing && (
|
||||
<>
|
||||
<Text>Количество кубит: {count}</Text>
|
||||
<UnstyledButton
|
||||
onClick={() => {
|
||||
setIsEditing(true);
|
||||
}}
|
||||
>
|
||||
<IconPencil size={25} />
|
||||
</UnstyledButton>
|
||||
</>
|
||||
)}
|
||||
</Card.Section>
|
||||
<Card.Section
|
||||
inheritPadding
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
UnstyledButton,
|
||||
} from "@mantine/core";
|
||||
import {
|
||||
IconCancel,
|
||||
IconCheck,
|
||||
IconCrown,
|
||||
IconForbid,
|
||||
@@ -196,23 +197,35 @@ function TeamMemberCard(props: { cur_team: Team; member: TeamMember }) {
|
||||
deleteMember({
|
||||
team_id: props.cur_team.id,
|
||||
user_id: props.member.user.keycloak_id,
|
||||
}).then(() => {
|
||||
notifications.show({
|
||||
radius: "md",
|
||||
title: "Пользователь удален успешно",
|
||||
message: "",
|
||||
icon: <IconCheck />,
|
||||
style: { paddingLeft: "5px" },
|
||||
})
|
||||
.then(() => {
|
||||
notifications.show({
|
||||
radius: "md",
|
||||
title: "Пользователь удален успешно",
|
||||
message: "",
|
||||
icon: <IconCheck />,
|
||||
style: { paddingLeft: "5px" },
|
||||
});
|
||||
updateTeam(props.cur_team.id, {
|
||||
members: [
|
||||
...props.cur_team.members.filter(
|
||||
(member) =>
|
||||
member.user.keycloak_id !=
|
||||
props.member.user.keycloak_id,
|
||||
),
|
||||
],
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
notifications.show({
|
||||
radius: "md",
|
||||
title: "Пользователя не получилось удалить",
|
||||
message: "",
|
||||
color: "red",
|
||||
icon: <IconCancel />,
|
||||
style: { paddingLeft: "5px" },
|
||||
});
|
||||
});
|
||||
updateTeam(props.cur_team.id, {
|
||||
members: [
|
||||
...props.cur_team.members.filter(
|
||||
(member) =>
|
||||
member.user.keycloak_id != props.member.user.keycloak_id,
|
||||
),
|
||||
],
|
||||
});
|
||||
});
|
||||
}}
|
||||
style={{
|
||||
cursor: "pointer",
|
||||
|
||||
Reference in New Issue
Block a user