fix typescript errors
This commit is contained in:
parent
742643b9e2
commit
ae1e2fcdc0
3 changed files with 24 additions and 32 deletions
|
@ -63,7 +63,7 @@ const styles = StyleSheet.create({
|
|||
* This screen allows the user to get and modify information on the app/device.
|
||||
*/
|
||||
class DebugScreen extends React.Component<PropsType, StateType> {
|
||||
modalRef: Modalize | null;
|
||||
modalRef: { current: Modalize | null };
|
||||
|
||||
modalInputValue: string;
|
||||
|
||||
|
@ -74,7 +74,7 @@ class DebugScreen extends React.Component<PropsType, StateType> {
|
|||
*/
|
||||
constructor(props: PropsType) {
|
||||
super(props);
|
||||
this.modalRef = null;
|
||||
this.modalRef = React.createRef<Modalize>();
|
||||
this.modalInputValue = '';
|
||||
const currentPreferences: Array<PreferenceItemType> = [];
|
||||
Object.values(AsyncStorageManager.PREFERENCES).forEach((object: any) => {
|
||||
|
@ -154,15 +154,6 @@ class DebugScreen extends React.Component<PropsType, StateType> {
|
|||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback used when receiving the modal ref
|
||||
*
|
||||
* @param ref
|
||||
*/
|
||||
onModalRef = (ref: Modalize) => {
|
||||
this.modalRef = ref;
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows the edit modal
|
||||
*
|
||||
|
@ -172,8 +163,8 @@ class DebugScreen extends React.Component<PropsType, StateType> {
|
|||
this.setState({
|
||||
modalCurrentDisplayItem: item,
|
||||
});
|
||||
if (this.modalRef) {
|
||||
this.modalRef.open();
|
||||
if (this.modalRef.current) {
|
||||
this.modalRef.current.open();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,8 +201,8 @@ class DebugScreen extends React.Component<PropsType, StateType> {
|
|||
return { currentPreferences };
|
||||
});
|
||||
AsyncStorageManager.set(key, value);
|
||||
if (this.modalRef) {
|
||||
this.modalRef.close();
|
||||
if (this.modalRef.current) {
|
||||
this.modalRef.current.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,9 +210,7 @@ class DebugScreen extends React.Component<PropsType, StateType> {
|
|||
const { state } = this;
|
||||
return (
|
||||
<View>
|
||||
<CustomModal onRef={this.onModalRef}>
|
||||
{this.getModalContent()}
|
||||
</CustomModal>
|
||||
<CustomModal ref={this.modalRef}>{this.getModalContent()}</CustomModal>
|
||||
<CollapsibleFlatList
|
||||
data={state.currentPreferences}
|
||||
extraData={state.currentPreferences}
|
||||
|
|
|
@ -25,13 +25,14 @@ import { StackNavigationProp } from '@react-navigation/stack';
|
|||
import { getDateOnlyString, getTimeOnlyString } from '../../utils/Planning';
|
||||
import DateManager from '../../managers/DateManager';
|
||||
import BasicLoadingScreen from '../../components/Screens/BasicLoadingScreen';
|
||||
import { apiRequest, ERROR_TYPE } from '../../utils/WebData';
|
||||
import { ApiRejectType, apiRequest } from '../../utils/WebData';
|
||||
import ErrorView from '../../components/Screens/ErrorView';
|
||||
import CustomHTML from '../../components/Overrides/CustomHTML';
|
||||
import { TAB_BAR_HEIGHT } from '../../components/Tabbar/CustomTabBar';
|
||||
import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
|
||||
import type { PlanningEventType } from '../../utils/Planning';
|
||||
import ImageGalleryButton from '../../components/Media/ImageGalleryButton';
|
||||
import { API_REQUEST_CODES, REQUEST_STATUS } from '../../utils/Requests';
|
||||
|
||||
type PropsType = {
|
||||
navigation: StackNavigationProp<any>;
|
||||
|
@ -67,7 +68,7 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
|||
|
||||
eventId: number;
|
||||
|
||||
errorCode: number;
|
||||
error: ApiRejectType;
|
||||
|
||||
/**
|
||||
* Generates data depending on whether the screen was opened from the planning or from a link
|
||||
|
@ -81,7 +82,7 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
|||
this.displayData = props.route.params.data;
|
||||
this.eventId = this.displayData.id;
|
||||
this.shouldFetchData = false;
|
||||
this.errorCode = 0;
|
||||
this.error = { status: REQUEST_STATUS.SUCCESS };
|
||||
this.state = {
|
||||
loading: false,
|
||||
};
|
||||
|
@ -89,7 +90,7 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
|||
this.displayData = null;
|
||||
this.eventId = props.route.params.eventId;
|
||||
this.shouldFetchData = true;
|
||||
this.errorCode = 0;
|
||||
this.error = { status: REQUEST_STATUS.SUCCESS };
|
||||
this.state = {
|
||||
loading: true,
|
||||
};
|
||||
|
@ -112,8 +113,8 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
|||
*
|
||||
* @param error
|
||||
*/
|
||||
onFetchError = (error: number) => {
|
||||
this.errorCode = error;
|
||||
onFetchError = (error: ApiRejectType) => {
|
||||
this.error = error;
|
||||
this.setState({ loading: false });
|
||||
};
|
||||
|
||||
|
@ -161,7 +162,7 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
|||
* @returns {*}
|
||||
*/
|
||||
getErrorView() {
|
||||
if (this.errorCode === ERROR_TYPE.BAD_INPUT) {
|
||||
if (this.error.code === API_REQUEST_CODES.BAD_INPUT) {
|
||||
return (
|
||||
<ErrorView
|
||||
message={i18n.t('screens.planning.invalidEvent')}
|
||||
|
@ -171,7 +172,8 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
|||
}
|
||||
return (
|
||||
<ErrorView
|
||||
status={this.errorCode}
|
||||
status={this.error.status}
|
||||
code={this.error.code}
|
||||
button={{
|
||||
icon: 'refresh',
|
||||
text: i18n.t('general.retry'),
|
||||
|
@ -196,7 +198,10 @@ class PlanningDisplayScreen extends React.Component<PropsType, StateType> {
|
|||
if (loading) {
|
||||
return <BasicLoadingScreen />;
|
||||
}
|
||||
if (this.errorCode === 0) {
|
||||
if (
|
||||
this.error.status === REQUEST_STATUS.SUCCESS &&
|
||||
this.error.code === undefined
|
||||
) {
|
||||
return this.getContent();
|
||||
}
|
||||
return this.getErrorView();
|
||||
|
|
|
@ -119,12 +119,12 @@ function ProximoListScreen(props: Props) {
|
|||
const navigation = useNavigation();
|
||||
const theme = useTheme();
|
||||
const { articles, setArticles } = useCachedProximoArticles();
|
||||
const modalRef = useRef<Modalize>();
|
||||
const modalRef = useRef<Modalize>(null);
|
||||
|
||||
const [currentSearchString, setCurrentSearchString] = useState('');
|
||||
const [currentSortMode, setCurrentSortMode] = useState(2);
|
||||
const [modalCurrentDisplayItem, setModalCurrentDisplayItem] = useState<
|
||||
React.ReactNode | undefined
|
||||
React.ReactChild | undefined
|
||||
>();
|
||||
|
||||
const sortModes = [sortPrice, sortPriceReverse, sortName, sortNameReverse];
|
||||
|
@ -361,9 +361,7 @@ function ProximoListScreen(props: Props) {
|
|||
|
||||
return (
|
||||
<View style={GENERAL_STYLES.flex}>
|
||||
<CustomModal onRef={(ref) => (modalRef.current = ref)}>
|
||||
{modalCurrentDisplayItem}
|
||||
</CustomModal>
|
||||
<CustomModal ref={modalRef}>{modalCurrentDisplayItem}</CustomModal>
|
||||
<WebSectionList
|
||||
request={() => readData<ArticlesType>(Urls.proximo.articles)}
|
||||
createDataset={createDataset}
|
||||
|
|
Loading…
Reference in a new issue