Skip to content

Commit

Permalink
fix linting problems in checkInScreen.jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
mbastian93 committed Aug 31, 2021
1 parent 84bf273 commit 35cb1d4
Showing 1 changed file with 138 additions and 96 deletions.
234 changes: 138 additions & 96 deletions src/screens/checkIn/checkInScreen.jsx
Original file line number Diff line number Diff line change
@@ -1,118 +1,160 @@

// (C) Copyright IBM Deutschland GmbH 2021. All rights reserved.

/***********************************************************************************************
imports
***********************************************************************************************/

import React, { Component } from 'react'
import { View, StyleSheet } from 'react-native'
import React, { PureComponent } from "react";
import { View, StyleSheet } from "react-native";

import config from "../../config/configProvider";
import Banner from "../../components/banner/banner";
import Spinner from "../../components/spinner/spinner";
import CheckInTiles from "../../components/checkIn/checkInTiles";
import CheckInWelcomeText from "../../components/checkIn/welcomeText";
import CheckInListView from "../../components/checkIn/checkInListView";
import ScrollIndicatorWrapper from "../../components/scrollIndicatorWrapper/scrollIndicatorWrapper";

import config from '../../config/configProvider'
import Banner from '../../components/banner/banner'
import Spinner from '../../components/spinner/spinner'
import CheckInTiles from '../../components/checkIn/checkInTiles'
import CheckInWelcomeText from '../../components/checkIn/welcomeText'
import CheckInListView from '../../components/checkIn/checkInListView'
import ScrollIndicatorWrapper from '../../components/scrollIndicatorWrapper/scrollIndicatorWrapper'
let localStyle;

/***********************************************************************************************
component:
renders the checkIn-screen
***********************************************************************************************/

class CheckInScreen extends Component {

/**
* @param {object} props
* @param {boolean} props.loading if true, shows the loading screen
* @param {boolean} props.error401 is true if there is a 401 error
* @param {object} props.navigation the navigation object provided by 'react-navigation'
* @param {Function} props.updateUser function to update the user
* @param {boolean} props.categoriesLoaded is set to true as soon as the questionnaire was completely loaded
* @param {object} props.questionnaireError holds the las error object
*/
constructor(props) {
super(props)
}

// rendering
/*-----------------------------------------------------------------------------------*/

render() {
return (
<View style={localStyle.wrapper}>

{/* loading spinner */}
<Spinner visible={this.props.loading} />

{/* banner at the top */}
<Banner
nav={this.props.navigation}
title={config.text.survey.titleCheckIn}
subTitle={config.text.survey.subTitleCheckIn}
updateUser={this.props.updateUser}
isCheckIn
noWayBack
categoriesLoaded={this.props.categoriesLoaded}
/>

{/* center content */}
<View style={{ ...localStyle.flexi, ...localStyle.wrapper }}>
<ScrollIndicatorWrapper
contentData={(
<View>
{/* if there is a questionnaire and no 401-error */}
{
!this.props.error401 && this.props.questionnaireError === null
&&
(<View style={{...localStyle.wrapper, ...localStyle.firstItem}}>
{/* renders the listview item representing the questionnaire */}
<CheckInListView {...this.props}></CheckInListView>
{/* welcome text with due-date information */}
<CheckInWelcomeText {...this.props}></CheckInWelcomeText>
{/* renders the button at the bottom */}
<CheckInTiles {...this.props}></CheckInTiles>
</View>)
}

{/* if there is an error */}
{
this.props.questionnaireError
&&
(<View style={{...localStyle.wrapper, ...localStyle.firstItem}}>
{/* displays the welcome text */}
<CheckInWelcomeText {...this.props}></CheckInWelcomeText>
</View>)
}
</View>
)}
/>
</View>
</View>
)
}
class CheckInScreen extends PureComponent {
/**
* @param {object} props
* @param {boolean} props.loading if true, shows the loading screen
* @param {boolean} props.error401 is true if there is a 401 error
* @param {object} props.navigation the navigation object provided by 'react-navigation'
* @param {Function} props.updateUser function to update the user
* @param {boolean} props.categoriesLoaded is set to true as soon as the questionnaire was completely loaded
* @param {object} props.questionnaireError holds the las error object
*/
// rendering
/*-----------------------------------------------------------------------------------*/

render() {
const {
navigation,
loading,
updateUser,
categoriesLoaded,
error401,
questionnaireError,
questionnaireItemMap,
user,
sendReport,
noNewQuestionnaireAvailableYet,
formatDateString,
} = this.props;
return (
<View style={localStyle.wrapper}>
{/* loading spinner */}
<Spinner visible={loading} />

{/* banner at the top */}
<Banner
nav={navigation}
title={config.text.survey.titleCheckIn}
subTitle={config.text.survey.subTitleCheckIn}
updateUser={updateUser}
isCheckIn
noWayBack
categoriesLoaded={categoriesLoaded}
/>

{/* center content */}
<View style={{ ...localStyle.flexi, ...localStyle.wrapper }}>
<ScrollIndicatorWrapper
contentData={
<View>
{/* if there is a questionnaire and no 401-error */}
{!error401 && questionnaireError === null && (
<View
style={{ ...localStyle.wrapper, ...localStyle.firstItem }}
>
{/* renders the listview item representing the questionnaire */}
<CheckInListView
user={user}
navigation={navigation}
categoriesLoaded={categoriesLoaded}
formatDateString={formatDateString}
questionnaireItemMap={questionnaireItemMap}
noNewQuestionnaireAvailableYet={
noNewQuestionnaireAvailableYet
}
/>
{/* welcome text with due-date information */}
<CheckInWelcomeText
error={error401}
questionnaireError={questionnaireError}
firstTime={user.firstTime}
noNewQuestionnaireAvailableYet={
noNewQuestionnaireAvailableYet
}
formatDateString={formatDateString}
user={user}
/>
{/* renders the button at the bottom */}
<CheckInTiles
user={user}
loading={loading}
categoriesLoaded={categoriesLoaded}
sendReport={sendReport}
questionnaireItemMap={questionnaireItemMap}
noNewQuestionnaireAvailableYet={
noNewQuestionnaireAvailableYet
}
/>
</View>
)}

{/* if there is an error */}
{questionnaireError && (
<View
style={{ ...localStyle.wrapper, ...localStyle.firstItem }}
>
{/* displays the welcome text */}
<CheckInWelcomeText
user={user}
error401={error401}
questionnaireError={questionnaireError}
noNewQuestionnaireAvailableYet={
noNewQuestionnaireAvailableYet
}
formatDateString={formatDateString}
/>
</View>
)}
</View>
}
/>
</View>
</View>
);
}
}

/***********************************************************************************************
localStyle
***********************************************************************************************/

const localStyle = StyleSheet.create({

wrapper: {
height: '100%',
flexDirection: 'column',
backgroundColor: config.theme.values.defaultBackgroundColor
},
localStyle = StyleSheet.create({
wrapper: {
height: "100%",
flexDirection: "column",
backgroundColor: config.theme.values.defaultBackgroundColor,
},

firstItem: {
marginTop: config.appConfig.scaleUiFkt(30),
},
firstItem: {
marginTop: config.appConfig.scaleUiFkt(30),
},

flexi: {
flex: 1
}
})
flexi: {
flex: 1,
},
});

export default CheckInScreen
export default CheckInScreen;

0 comments on commit 35cb1d4

Please sign in to comment.