Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions frontend/unified/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ export const App: React.FC = () => {
if (data === undefined) {
return <p>Data undefined</p>;
}
if (data.account === null) {
return <p>Account null</p>;
}

const instrumentSession =
data.account?.instrumentSessionRoles.edges[0].node.instrumentSession;
data.account.instrumentSessionRoles.edges[0].node.instrumentSession;

const handleChangeTechnique = (
/**
Expand Down Expand Up @@ -200,9 +203,9 @@ export const App: React.FC = () => {
// a capitalised "proposal code", whereas the workflows service only accepts
// it in lowercase
proposalCode:
instrumentSession?.proposal.proposalCategory.toLowerCase(),
proposalNumber: instrumentSession?.proposal.proposalNumber,
number: instrumentSession?.instrumentSessionNumber,
instrumentSession.proposal.proposalCategory.toLowerCase(),
proposalNumber: instrumentSession.proposal.proposalNumber,
number: instrumentSession.instrumentSessionNumber,
}}
/>
</Stack>
Expand Down
19 changes: 3 additions & 16 deletions frontend/unified/src/components/SessionSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,10 @@ enum SessionSelectionMode {
Custom = "Custom",
}

type Proposal = {
proposalNumber: number;
proposalCategory: string;
};

type Instrument = {
name: string;
};

export type InstrumentSession = {
instrumentSessionNumber: number;
proposal: Proposal;
instrument: Instrument;
};
type NonNullAccount = NonNullable<SessionQueryQuery["account"]>;

type SessionSelectorProps = {
session: InstrumentSession;
session: NonNullAccount["instrumentSessionRoles"]["edges"][0]["node"]["instrumentSession"];
};

export const SessionSelector: React.FC<SessionSelectorProps> = ({
Expand All @@ -42,7 +29,7 @@ export const SessionSelector: React.FC<SessionSelectorProps> = ({
const [textInputValue, setTextInputValue] = useState<string>("");

const proposal = session?.proposal;
const latestSession = `${proposal?.proposalCategory?.toLowerCase()}${proposal?.proposalNumber}-${session?.instrumentSessionNumber}`;
const latestSession = `${proposal.proposalCategory?.toLowerCase()}${proposal.proposalNumber}-${session.instrumentSessionNumber}`;

return (
<Stack direction="row" spacing={2} alignItems={"center"}>
Expand Down
Loading