fix: noticeswrapper api response error (#139)

This commit is contained in:
Jansen Kantor
2023-04-21 10:09:22 -04:00
committed by GitHub
parent 14f7389900
commit b09c36e13e
2 changed files with 3 additions and 3 deletions

View File

@@ -21,9 +21,9 @@ export const useNoticesWrapperData = () => {
if (getConfig().ENABLE_NOTICES) {
getNotices({
onLoad: (data) => {
if (data?.results?.length > 0) {
if (data?.data?.results?.length > 0) {
setIsRedirected(true);
window.location.replace(`${data.results[0]}?next=${window.location.href}`);
window.location.replace(`${data.data.results[0]}?next=${window.location.href}`);
}
},
});

View File

@@ -64,7 +64,7 @@ describe('NoticesWrapper hooks', () => {
expect(getNotices).toHaveBeenCalled();
const { onLoad } = getNotices.mock.calls[0][0];
const target = 'url-target';
onLoad({ results: [target] });
onLoad({ data: { results: [target] } });
expect(state.setState.isRedirected).toHaveBeenCalledWith(true);
expect(window.location.replace).toHaveBeenCalledWith(
`${target}?next=${window.location.href}`,