Skip to content

Commit c373a8b

Browse files
Merge pull request #47 from BIBSYSDEV/develop
bugfix Ncip server til prod
2 parents 6cfea99 + dbf158e commit c373a8b

7 files changed

Lines changed: 29 additions & 30 deletions

File tree

cypress/integration/app.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ context('start', () => {
2727

2828
it('shows errormessage when parameters is missing', () => {
2929
cy.visit('?recordid=123');
30-
cy.get('[data-testid="alert"]').should('exist').contains('URL must contain parameters: recordid and patrondid');
30+
cy.get('[data-testid="alert"]').should('exist').contains('URL must contain parameters: recordid and patronid');
3131
cy.visit('?patronid=123');
32-
cy.get('[data-testid="alert"]').should('exist').contains('URL must contain parameters: recordid and patrondid');
32+
cy.get('[data-testid="alert"]').should('exist').contains('URL must contain parameters: recordid and patronid');
3333
cy.visit('?recordid=123&patronid=');
34-
cy.get('[data-testid="alert"]').should('exist').contains('URL must contain parameters: recordid and patrondid');
34+
cy.get('[data-testid="alert"]').should('exist').contains('URL must contain parameters: recordid and patronid');
3535
cy.visit('');
36-
cy.get('[data-testid="alert"]').should('exist').contains('URL must contain parameters: recordid and patrondid');
36+
cy.get('[data-testid="alert"]').should('exist').contains('URL must contain parameters: recordid and patronid');
3737
});
3838

3939
it('metadata is cleaned up', () => {

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@cypress/instrument-cra": "^1.4.0",
3232
"@types/react": "^17.0.27",
3333
"@types/react-dom": "^17.0.9",
34-
"@types/styled-components": "^5.1.14",
34+
"@types/styled-components": "^5.1.15",
3535
"@types/yup": "^0.29.13",
3636
"axios-mock-adapter": "^1.20.0",
3737
"cypress": "^8.5.0",

src/AppContent.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const AppContent = () => {
7979
}
8080
};
8181
if (!recordId || !patronId) {
82-
setAppError(new Error('URL must contain parameters: recordid and patrondid'));
82+
setAppError(new Error('URL must contain parameters: recordid and patronid'));
8383
} else {
8484
fetchLibraryAccess().then();
8585
fetchMetadata().then();
@@ -94,7 +94,7 @@ const AppContent = () => {
9494
<StyledFullPageProgressWrapper>
9595
<CircularProgress />
9696
</StyledFullPageProgressWrapper>
97-
) : !libraryAccess?.isNcipLibrary ? (
97+
) : !libraryAccess?.ncip_server_url ? (
9898
<WarningBanner message="Sorry, this ILL feature is not available. Your library does not support the Norwegian NCIP profile." />
9999
) : !isLoadingMetaData ? (
100100
fetchMetaDataError ? (
@@ -107,7 +107,12 @@ const AppContent = () => {
107107
</Typography>
108108
<MetadataHolder metaData={metaData} />
109109
{patronId && (
110-
<OrderSchema metaData={metaData} patronId={patronId} readonly={libraryAccess.isAlmaLibrary} />
110+
<OrderSchema
111+
metaData={metaData}
112+
patronId={patronId}
113+
ncip_server_url={libraryAccess.ncip_server_url}
114+
readonly={libraryAccess.isAlmaLibrary}
115+
/>
111116
)}
112117
</PageWrapper>
113118
)

src/api/mockdata.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ export const mockSRUResponse: SRUResponse = {
2222

2323
export const mockedLibraryAccess: LibraryAccess = {
2424
isAlmaLibrary: false,
25-
isNcipLibrary: true,
25+
ncip_server_url: 'ncip_server_url',
2626
};
2727

2828
export const mockedLibraryAccessNoNcip: LibraryAccess = {
2929
isAlmaLibrary: true,
30-
isNcipLibrary: false,
30+
ncip_server_url: '',
3131
};
3232

3333
export const mockedLibraryAccessAlmaLibrary: LibraryAccess = {
3434
isAlmaLibrary: true,
35-
isNcipLibrary: true,
35+
ncip_server_url: 'ncip_server_url',
3636
};
3737

3838
export const mockSRUResponseWithNoItems: SRUResponse = {
@@ -66,39 +66,34 @@ export const mockMetadata: MetaData = {
6666
available_for_loan: true,
6767
institution_code: 'NB_DEP',
6868
mms_id: '9288276ff6656',
69-
ncip_server_url: 'http://www.example.com',
7069
},
7170
{
7271
display_name: 'NINA Biblioteket',
7372
library_code: '43424324',
7473
available_for_loan: false,
7574
institution_code: 'UIT',
7675
mms_id: '92882766626654',
77-
ncip_server_url: 'https://www.example.com',
7876
},
7977
{
8078
display_name: 'NTNU Universitetsbiblioteket Gunnerusbiblioteket',
8179
library_code: '6456456',
8280
available_for_loan: true,
8381
institution_code: 'UIT',
8482
mms_id: '92882766626651',
85-
ncip_server_url: 'https://www.example.com',
8683
},
8784
{
8885
display_name: 'UiT Norges arktiske universitet Narvikbiblioteket',
8986
library_code: '12344568',
9087
available_for_loan: false,
9188
institution_code: 'UIT',
9289
mms_id: '92882766626612',
93-
ncip_server_url: 'https://www.example.com',
9490
},
9591
{
9692
display_name: 'Universitetsbiblioteket i Bergen Bibliotek for matematisk- naturvitenskapelige fag',
9793
library_code: '1234569',
9894
available_for_loan: true,
9995
institution_code: 'UIB',
10096
mms_id: '92882766626623',
101-
ncip_server_url: 'https://www.example.com',
10297
},
10398

10499
{
@@ -107,15 +102,13 @@ export const mockMetadata: MetaData = {
107102
available_for_loan: true,
108103
institution_code: 'UIB',
109104
mms_id: '9288276662662233',
110-
ncip_server_url: 'https://www.example.com',
111105
},
112106
{
113107
display_name: 'Nasjonalbiblioteket Pliktavlevering',
114108
library_code: '0183334',
115109
available_for_loan: true,
116110
institution_code: 'UIB',
117111
mms_id: '92882766626623',
118-
ncip_server_url: 'https://www.example.com',
119112
},
120113
],
121114
};

src/components/OrderSchema.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,23 @@ const StyledTextFieldWrapper = styled.div`
5555
interface SchemaValues {
5656
patronId: string;
5757
selectedLibrary: string;
58+
ncip_server_url: string;
5859
}
5960

60-
const emptySchema: SchemaValues = { patronId: '', selectedLibrary: '' };
61+
const emptySchema: SchemaValues = { patronId: '', ncip_server_url: '', selectedLibrary: '' };
6162

6263
interface OrderSchemaProps {
6364
metaData: MetaData;
6465
readonly: boolean;
6566
patronId: string;
67+
ncip_server_url: string;
6668
}
6769

6870
const createSuccessMessage = (metaData: MetaData, selectedLibrary: Library, patronId: string) => {
6971
return `The request for '${metaData.display_title}' was sent successfully to ${selectedLibrary.display_name} for ${patronId} `;
7072
};
7173

72-
const OrderSchema: FC<OrderSchemaProps> = ({ metaData, patronId, readonly = false }) => {
74+
const OrderSchema: FC<OrderSchemaProps> = ({ metaData, patronId, ncip_server_url, readonly = false }) => {
7375
const [isPostingRequest, setIsPostingRequest] = useState(false);
7476
const [postRequestError, setPostRequestError] = useState<Error>();
7577
const history = useHistory();
@@ -91,7 +93,7 @@ const OrderSchema: FC<OrderSchemaProps> = ({ metaData, patronId, readonly = fals
9193
type: MediaTypes.Book,
9294
requestType: RequestTypes.Physical,
9395
comment: '',
94-
ncipServerUrl: selectedLibrary.ncip_server_url,
96+
ncipServerUrl: ncip_server_url,
9597
};
9698
try {
9799
setIsPostingRequest(true);

src/types/app.types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export interface Library {
1818
institution_code: string;
1919
library_code: string;
2020
mms_id: string;
21-
ncip_server_url: string;
2221
}
2322

2423
export interface SRUResponse {
@@ -31,7 +30,7 @@ export interface SRUResponse {
3130
}
3231

3332
export interface LibraryAccess {
34-
isNcipLibrary: boolean;
33+
ncip_server_url: string;
3534
isAlmaLibrary: boolean;
3635
}
3736

0 commit comments

Comments
 (0)