diff --git a/frontend/unified/src/App.tsx b/frontend/unified/src/App.tsx index ad36268..251b74e 100644 --- a/frontend/unified/src/App.tsx +++ b/frontend/unified/src/App.tsx @@ -93,9 +93,12 @@ export const App: React.FC = () => { if (data === undefined) { return

Data undefined

; } + if (data.account === null) { + return

Account null

; + } const instrumentSession = - data.account?.instrumentSessionRoles.edges[0].node.instrumentSession; + data.account.instrumentSessionRoles.edges[0].node.instrumentSession; const handleChangeTechnique = ( /** @@ -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, }} /> diff --git a/frontend/unified/src/components/SessionSelector.tsx b/frontend/unified/src/components/SessionSelector.tsx index ca1b689..d3e8be3 100644 --- a/frontend/unified/src/components/SessionSelector.tsx +++ b/frontend/unified/src/components/SessionSelector.tsx @@ -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; type SessionSelectorProps = { - session: InstrumentSession; + session: NonNullAccount["instrumentSessionRoles"]["edges"][0]["node"]["instrumentSession"]; }; export const SessionSelector: React.FC = ({ @@ -42,7 +29,7 @@ export const SessionSelector: React.FC = ({ const [textInputValue, setTextInputValue] = useState(""); const proposal = session?.proposal; - const latestSession = `${proposal?.proposalCategory?.toLowerCase()}${proposal?.proposalNumber}-${session?.instrumentSessionNumber}`; + const latestSession = `${proposal.proposalCategory?.toLowerCase()}${proposal.proposalNumber}-${session.instrumentSessionNumber}`; return (