Skip to content

Commit

Permalink
Merge pull request Aspen-Discovery#1789 from catsoup11789/24.05.00
Browse files Browse the repository at this point in the history
LiDA updates
  • Loading branch information
mdnoble73 authored Apr 30, 2024
2 parents 6241689 + 5dcc106 commit 775b32e
Show file tree
Hide file tree
Showing 31 changed files with 725 additions and 803 deletions.
6 changes: 1 addition & 5 deletions code/aspen_app/src/components/Action/CheckOut/CheckOut.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, ButtonSpinner, ButtonGroup, ButtonIcon, ButtonText } from '@gluestack-ui/themed';
import { Box, Button, ButtonSpinner, ButtonGroup, ButtonIcon, ButtonText, Text } from '@gluestack-ui/themed';
import React from 'react';
import _ from 'lodash';
import { useQueryClient } from '@tanstack/react-query';
Expand Down Expand Up @@ -56,10 +56,6 @@ export const CheckOut = (props) => {
size="md"
bgColor={theme['colors']['primary']['500']}
variant="solid"
style={{
flex: 1,
flexWrap: 'wrap',
}}
onPress={async () => {
setLoading(true);
await completeAction(record, type, user.id, null, null, null, library.baseUrl).then(async (eContentResponse) => {
Expand Down
2 changes: 1 addition & 1 deletion code/aspen_app/src/components/Action/Holds/HoldPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export const HoldPrompt = (props) => {
}
});
}}>
{loading ? <ButtonSpinner /> : <ButtonText color={theme['colors']['primary']['500-text']}>{title}</ButtonText>}
{loading ? <ButtonSpinner color={theme['colors']['primary']['500-text']} /> : <ButtonText color={theme['colors']['primary']['500-text']}>{title}</ButtonText>}
</Button>
</ButtonGroup>
</ModalFooter>
Expand Down
2 changes: 1 addition & 1 deletion code/aspen_app/src/components/Action/Holds/PlaceHold.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const PlaceHold = (props) => {
});
}}>
{loading ? (
<ButtonSpinner />
<ButtonSpinner color={theme['colors']['primary']['500-text']} />
) : (
<ButtonText color={theme['colors']['primary']['500-text']} textAlign="center">
{title}
Expand Down
51 changes: 21 additions & 30 deletions code/aspen_app/src/components/Action/LoadOverDriveSample.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,29 @@
import React from 'react';
import { Button } from 'native-base';
import { ButtonSpinner, Button, ButtonText } from '@gluestack-ui/themed';

// custom components and helper files
import {LibrarySystemContext, UserContext} from '../../context/initialContext';
import { LibrarySystemContext, ThemeContext, UserContext } from '../../context/initialContext';
import { completeAction } from '../../util/recordActions';

export const LoadOverDriveSample = (props) => {
const { user } = React.useContext(UserContext);
const { library } = React.useContext(LibrarySystemContext);
const [loading, setLoading] = React.useState(false);
const { user } = React.useContext(UserContext);
const { library } = React.useContext(LibrarySystemContext);
const [loading, setLoading] = React.useState(false);
const { theme } = React.useContext(ThemeContext);

return (
<Button
size="xs"
colorScheme="primary"
variant="outline"
_text={{
padding: 0,
textAlign: 'center',
fontSize: 12,
}}
style={{
flex: 1,
flexWrap: 'wrap',
}}
isLoading={loading}
isLoadingText="Opening..."
onPress={() => {
setLoading(true);
completeAction(props.id, props.type, user.id, props.formatId, props.sampleNumber, null, library.baseUrl, null, null).then((r) => {
setLoading(false);
});
}}>
{props.title}
</Button>
);
return (
<Button
size="xs"
variant="link"
borderWidth={1}
borderColor={theme['colors']['primary']['500']}
onPress={() => {
setLoading(true);
completeAction(props.id, props.type, user.id, props.formatId, props.sampleNumber, null, library.baseUrl, null, null).then((r) => {
setLoading(false);
});
}}>
{loading ? <ButtonSpinner color={theme['colors']['primary']['500']} /> : <ButtonText color={theme['colors']['primary']['500']}>{props.title}</ButtonText>}
</Button>
);
};
49 changes: 24 additions & 25 deletions code/aspen_app/src/components/Action/OpenSideLoad.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
import { Button, ButtonText, ButtonSpinner } from '@gluestack-ui/themed';
import React from 'react';
import { Button } from 'native-base';
import { ThemeContext } from '../../context/initialContext';

// custom components and helper files
import {openSideLoad} from '../../util/recordActions';
import { openSideLoad } from '../../util/recordActions';

export const OpenSideLoad = (props) => {
const [loading, setLoading] = React.useState(false);
const [loading, setLoading] = React.useState(false);
const { theme } = React.useContext(ThemeContext);

return (
<Button
size="md"
colorScheme="primary"
variant="solid"
_text={{
padding: 0,
textAlign: 'center',
}}
style={{
flex: 1,
flexWrap: 'wrap',
}}
isLoading={loading}
isLoadingText="Opening..."
onPress={async () => {
setLoading(true);
await openSideLoad(props.url).then((r) => setLoading(false));
}}>
{props.title}
</Button>
);
return (
<Button
size="md"
_text={{
padding: 0,
textAlign: 'center',
}}
style={{
flex: 1,
flexWrap: 'wrap',
}}
bgColor={theme['colors']['primary']['500']}
onPress={async () => {
setLoading(true);
await openSideLoad(props.url).then((r) => setLoading(false));
}}>
{loading ? <ButtonSpinner color={theme['colors']['primary']['500-text']} /> : <ButtonText color={theme['colors']['primary']['500-text']}>{props.title}</ButtonText>}
</Button>
);
};
4 changes: 2 additions & 2 deletions code/aspen_app/src/components/LibraryCardScanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { StyleSheet } from 'react-native';
import BarcodeMask from 'react-native-barcode-mask';
import { navigate } from '../helpers/RootNavigator';
import { loadError } from './loadError';
import { loadingSpinner } from './loadingSpinner';
import { LoadingSpinner, loadingSpinner } from './loadingSpinner';

export default function LibraryCardScanner() {
const navigation = useNavigation();
Expand Down Expand Up @@ -35,7 +35,7 @@ export default function LibraryCardScanner() {
};

if (hasPermission === null) {
return loadingSpinner('Requesting for camera permissions');
return LoadingSpinner('Requesting for camera permissions');
}

if (hasPermission === false) {
Expand Down
39 changes: 23 additions & 16 deletions code/aspen_app/src/components/NotificationsOnboard.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { useFocusEffect } from '@react-navigation/native';
import { useQueryClient } from '@tanstack/react-query';
import { AlertDialog, Button } from 'native-base';
import { Text, CheckIcon, Heading, HStack, VStack, Badge, BadgeText, FlatList, Button, ButtonGroup, ButtonText, ButtonIcon, Box, Icon, Center, AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogBody, AlertDialogFooter, AlertDialogBackdrop, Select, SelectTrigger, SelectInput, SelectIcon, SelectPortal, SelectBackdrop, SelectContent, SelectDragIndicatorWrapper, SelectDragIndicator, SelectItem, SelectScrollView, ButtonSpinner } from '@gluestack-ui/themed';
import React from 'react';
import { LanguageContext, LibrarySystemContext, UserContext } from '../context/initialContext';
import { LanguageContext, LibrarySystemContext, ThemeContext, UserContext } from '../context/initialContext';
import { navigateStack } from '../helpers/RootNavigator';
import { getTermFromDictionary } from '../translations/TranslationService';
import { refreshProfile, updateNotificationOnboardingStatus } from '../util/api/user';

export const NotificationsOnboard = (props) => {
const queryClient = useQueryClient();
const { setAlreadyCheckedNotifications, setShowNotificationsOnboarding } = props;
const { setPromptOpen } = props;
const { language } = React.useContext(LanguageContext);
const { library } = React.useContext(LibrarySystemContext);
const { user, notificationSettings, expoToken, notificationOnboard, updateNotificationOnboard, updateNotificationSettings } = React.useContext(UserContext);
Expand All @@ -18,6 +18,7 @@ export const NotificationsOnboard = (props) => {
const [onboardingButton, setOnboardingButton] = React.useState('');
const [isLoading, setIsLoading] = React.useState(false);
const [isCanceling, setIsCanceling] = React.useState(false);
const { colorMode, theme, textColor } = React.useContext(ThemeContext);
const onClose = async () => {
await updateNotificationOnboardingStatus(false, expoToken, library.baseUrl, language);
await refreshProfile(library.baseUrl).then((profile) => {
Expand All @@ -28,6 +29,7 @@ export const NotificationsOnboard = (props) => {
updateNotificationOnboard(0);
setIsLoading(false);
setIsCanceling(false);
setPromptOpen('');
//setAlreadyCheckedNotifications(true);
//setShowNotificationsOnboarding(false);
};
Expand Down Expand Up @@ -65,36 +67,41 @@ export const NotificationsOnboard = (props) => {

return (
<AlertDialog leastDestructiveRef={cancelRef} isOpen={isOpen} onClose={() => onClose()}>
<AlertDialog.Content>
<AlertDialog.Header>{getTermFromDictionary(language, 'onboard_notifications_title')}</AlertDialog.Header>
<AlertDialog.Body>{onboardingBody}</AlertDialog.Body>
<AlertDialog.Footer>
<Button.Group space={2}>
<AlertDialogBackdrop />
<AlertDialogContent bgColor={colorMode === 'light' ? theme['colors']['warmGray']['50'] : theme['colors']['coolGray']['700']}>
<AlertDialogHeader>
<Heading color={textColor}>{getTermFromDictionary(language, 'onboard_notifications_title')}</Heading>
</AlertDialogHeader>
<AlertDialogBody>
<Text color={textColor}>{onboardingBody}</Text>
</AlertDialogBody>
<AlertDialogFooter>
<ButtonGroup space="md">
<Button
isLoading={isCanceling}
isLoadingText={getTermFromDictionary(language, 'canceling', true)}
variant="unstyled"
colorScheme="coolGray"
variant="link"
bgColor={colorMode === 'light' ? theme['colors']['warmGray']['50'] : theme['colors']['coolGray']['700']}
onPress={() => {
setIsCanceling(true);
onClose();
}}
ref={cancelRef}>
{getTermFromDictionary(language, 'onboard_notifications_button_cancel')}
{isCanceling ? <ButtonSpinner color={textColor} /> : <ButtonText color={textColor}>{getTermFromDictionary(language, 'onboard_notifications_button_cancel')}</ButtonText>}
</Button>
<Button
isLoading={isLoading}
isLoadingText={getTermFromDictionary(language, 'updating', true)}
colorScheme="danger"
bgColor={theme['colors']['danger']['700']}
onPress={() => {
setIsLoading(true);
onClose().then(() => navigateStack('MoreTab', 'PermissionNotificationDescription', { prevRoute: 'notifications_onboard' }));
}}>
{onboardingButton}
{isLoading ? <ButtonSpinner color={theme['colors']['white']} /> : <ButtonText color={theme['colors']['white']}>{onboardingButton}</ButtonText>}
</Button>
</Button.Group>
</AlertDialog.Footer>
</AlertDialog.Content>
</ButtonGroup>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
};
46 changes: 29 additions & 17 deletions code/aspen_app/src/context/initialContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ export const LibrarySystemProvider = ({ children }) => {
};

const updateCatalogStatus = (data) => {
console.log(data);

if (data.status) {
setCatalogStatus(data.status);
console.log('updated catalog status');
Expand Down Expand Up @@ -364,26 +366,31 @@ export const UserProvider = ({ children }) => {
const [notificationOnboard, setNotificationOnboard] = useState(0);
const [expoToken, setExpoToken] = useState(false);
const [aspenToken, setAspenToken] = useState(false);
const [seenNotificationOnboardPrompt, setSeenNotificationOnboardPrompt] = useState(true);

const updateUser = (data) => {
if (_.isObject(data) && !_.isUndefined(data.lastListUsed)) {
PATRON.listLastUsed = data.lastListUsed;
}
if (user !== data) {
if (_.isObject(data) && !_.isUndefined(data.lastListUsed)) {
PATRON.listLastUsed = data.lastListUsed;
}

if (_.isObject(data) && !_.isUndefined(data.numHolds)) {
PATRON.num.holds = data.numHolds;
}
if (_.isObject(data) && !_.isUndefined(data.numHolds)) {
PATRON.num.holds = data.numHolds;
}

if (_.isObject(data) && !_.isUndefined(data.notification_preferences)) {
updateNotificationSettings(data.notification_preferences, data.interfaceLanguage ?? 'en', data.onboardAppNotifications);
}
if (_.isObject(data) && !_.isUndefined(data.notification_preferences)) {
updateNotificationSettings(data.notification_preferences, data.interfaceLanguage ?? 'en', data.onboardAppNotifications);
}

if (_.isObject(data) && !_.isUndefined(data.onboardAppNotifications)) {
updateNotificationOnboard(data.onboardAppNotifications);
}
if (_.isObject(data) && !_.isUndefined(data.onboardAppNotifications)) {
updateNotificationOnboard(data.onboardAppNotifications);
}

setUser(data);
console.log('updated UserContext');
setUser(data);
console.log('updated UserContext');
} else {
console.log("User data hasn't changed");
}
};

const resetUser = () => {
Expand Down Expand Up @@ -487,13 +494,11 @@ export const UserProvider = ({ children }) => {
setExpoToken(false);
setAspenToken(false);

// let's not intentionally bombard the user with prompts at every boot without knowing their preferences
setNotificationOnboard(0);

const deviceSettings = _.filter(data, { device: 'Unknown' });
if (deviceSettings && _.isObject(deviceSettings)) {
if (_.isObject(deviceSettings[0])) {
const settings = deviceSettings[0];
console.log(settings);
if (!_.isUndefined(settings.onboardStatus)) {
setNotificationOnboard(settings.onboardStatus);
}
Expand Down Expand Up @@ -547,6 +552,11 @@ export const UserProvider = ({ children }) => {
console.log('updated notification settings in UserContext');
};

const updateSeenNotificationOnboardPrompt = (data) => {
setSeenNotificationOnboardPrompt(data);
console.log('updated seenNotificationOnboardPrompt UserContext');
};

const updateExpoToken = (data) => {
setExpoToken(data);
console.log('updated expo token UserContext');
Expand Down Expand Up @@ -592,6 +602,8 @@ export const UserProvider = ({ children }) => {
updateAspenToken,
notificationOnboard,
updateNotificationOnboard,
seenNotificationOnboardPrompt,
updateSeenNotificationOnboardPrompt,
}}>
{children}
</UserContext.Provider>
Expand Down
Loading

0 comments on commit 775b32e

Please sign in to comment.