Skip to content

Commit

Permalink
fix: 馃悰 fix existing if checking
Browse files Browse the repository at this point in the history
  • Loading branch information
yeukfei02 committed Dec 12, 2020
1 parent cc10014 commit 30ceb67
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/common/Common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getFirebaseConfig = (): FirebaseConfig => {
export const getStripeApiKey = (): string | undefined => {
let result: string | undefined = '';

if (window.location.href.includes('localhost')) {
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
result = process.env['REACT_APP_STRIPE_TEST_API_KEY'];
} else {
result = process.env['REACT_APP_STRIPE_API_KEY'];
Expand All @@ -39,7 +39,7 @@ export const getStripeApiKey = (): string | undefined => {

export const getRootUrl = (): string => {
let ROOT_URL = '';
if (window.location.href.includes('localhost')) {
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
ROOT_URL = 'http://localhost:3000/api';
} else {
ROOT_URL = 'https://www.lunch-picker-api.com/api';
Expand Down
4 changes: 2 additions & 2 deletions src/components/cardView/CardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function CardView(props: any): JSX.Element {
const [message, setMessage] = useState<string>('');

useEffect(() => {
if (openSuccessAlert === true) {
if (openSuccessAlert) {
setOpenSuccessAlert(false);
}
if (!_.isEmpty(message)) {
Expand Down Expand Up @@ -110,7 +110,7 @@ function CardView(props: any): JSX.Element {
const handleExpandClick = () => {
setExpanded(!expanded);

if (expanded === false) getRestaurantsDetailsReviewById(id);
if (!expanded) getRestaurantsDetailsReviewById(id);
};

const getRestaurantsDetailsReviewById = async (id: string) => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/favourites/Favourites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Favourites(): JSX.Element {
}, []);

useEffect(() => {
if (openSuccessAlert === true) {
if (openSuccessAlert) {
setOpenSuccessAlert(false);
}
if (!_.isEmpty(message)) {
Expand All @@ -49,7 +49,7 @@ function Favourites(): JSX.Element {
}, [openSuccessAlert, message]);

useEffect(() => {
if (deleteAllFavouritesStatus === true) {
if (deleteAllFavouritesStatus) {
setTimeout(() => {
getFavourites();
setDeleteAllFavouritesStatus(false);
Expand All @@ -75,7 +75,7 @@ function Favourites(): JSX.Element {
const renderDeleteAllFavouritesButton = () => {
let deleteAllFavouritesButton: any = null;

if (deleteAllFavouritesButtonClicked === true) {
if (deleteAllFavouritesButtonClicked) {
deleteAllFavouritesButton = (
<div className="mt-3 d-flex justify-content-end" style={{ marginRight: '2.5em' }}>
<Button variant="contained" color="primary" disabled={true} onClick={handleDeleteAllFavourites}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function FloatingActionButton(): JSX.Element {
const renderFab = () => {
let fab: any = null;

if (showFab === true) {
if (showFab) {
fab = (
<Fab className={classes.fab} style={{ zIndex: 999 }} color="primary" aria-label="up" onClick={scrollToTop}>
<UpIcon />
Expand Down
6 changes: 3 additions & 3 deletions src/components/mainPage/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ function MainPage(): JSX.Element {

if (_.isEqual(radioButtonValue, 'places')) {
if (!_.isEmpty(location)) {
if (submitButtonClicked === true) {
if (submitButtonClicked) {
submitButton = (
<Button className="w-100" variant="outlined" color="secondary" disabled={true} onClick={handleSubmit}>
{t('loading...')}
Expand All @@ -534,7 +534,7 @@ function MainPage(): JSX.Element {
}

if (_.isEqual(radioButtonValue, 'useCurrentLocation')) {
if (submitButtonClicked === true) {
if (submitButtonClicked) {
submitButton = (
<Button className="w-100" variant="outlined" color="secondary" disabled={true} onClick={handleSubmit}>
{t('loading...')}
Expand Down Expand Up @@ -565,7 +565,7 @@ function MainPage(): JSX.Element {
const renderRandomButton = () => {
let randomButton: any = null;

if (randomButtonClicked === true) {
if (randomButtonClicked) {
randomButton = (
<Bounce>
<Tooltip title="Let's eat" placement="bottom">
Expand Down
4 changes: 2 additions & 2 deletions src/components/myStoreCheckout/CheckoutForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ function CheckoutForm(props: any) {
}, [amount, currency, token, card]);

useEffect(() => {
if (openSuccessAlert === true) {
if (openSuccessAlert) {
setOpenSuccessAlert(false);
}
if (openErrorAlert === true) {
if (openErrorAlert) {
setOpenErrorAlert(false);
}
if (!_.isEmpty(message)) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/randomFood/RandomFood.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function RandomFood(): JSX.Element {
}, [useRandomFoodCategory, randomFoodList, latitude, longitude]);

useEffect(() => {
if (openSuccessAlert === true) {
if (openSuccessAlert) {
setOpenSuccessAlert(false);
}
if (!_.isEmpty(message)) {
Expand Down Expand Up @@ -130,7 +130,7 @@ function RandomFood(): JSX.Element {
) => {
const response = await axios.get(`${ROOT_URL}/restaurant/find-restaurants-by-lat-long`, {
params: {
term: useRandomFoodCategory === true ? selectedTerm : '',
term: useRandomFoodCategory ? selectedTerm : '',
latitude: latitude,
longitude: longitude,
},
Expand All @@ -150,7 +150,7 @@ function RandomFood(): JSX.Element {
const renderRefreshButton = () => {
let refreshButton: any = null;

if (refreshButtonClicked === true) {
if (refreshButtonClicked) {
refreshButton = (
<div className="d-flex justify-content-end" style={{ marginRight: '2.5em' }}>
<Button variant="contained" color="primary" disabled={true} onClick={handleRefresh}>
Expand Down Expand Up @@ -253,7 +253,7 @@ function RandomFood(): JSX.Element {
<div>
<div className="mt-4 d-flex justify-content-end" style={{ marginRight: '2.5em' }}>
<Typography component={'span'}>
{useRandomFoodCategory === true && !_.isEmpty(selectedTerm) ? (
{useRandomFoodCategory && !_.isEmpty(selectedTerm) ? (
<div>
<b>{t('currentFoodCategory')}</b> {selectedTerm}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/randomFoodMapView/RandomFoodMapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function RandomFoodMapView(): JSX.Element {
}, [randomFoodList, latitude, longitude]);

useEffect(() => {
if (openSuccessAlert === true) {
if (openSuccessAlert) {
setOpenSuccessAlert(false);
}
if (!_.isEmpty(message)) {
Expand Down Expand Up @@ -148,7 +148,7 @@ function RandomFoodMapView(): JSX.Element {
const renderRefreshButton = () => {
let refreshButton: any = null;

if (refreshButtonClicked === true) {
if (refreshButtonClicked) {
refreshButton = (
<div className="mt-3 d-flex justify-content-end" style={{ marginRight: '2.5em' }}>
<Button variant="contained" color="primary" disabled={true} onClick={handleRefresh}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/restaurantDetails/RestaurantDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function RestaurantDetails(props: any) {
}, [props.match.params.id]);

useEffect(() => {
if (openSuccessAlert === true) {
if (openSuccessAlert) {
setOpenSuccessAlert(false);
}
if (!_.isEmpty(message)) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ function Settings(): JSX.Element {

useEffect(() => {
if (!_.isEmpty(currentToken)) {
if (subscribeStatus === true) subscribeTopic(currentToken);
if (subscribeStatus) subscribeTopic(currentToken);
else unsubscribeTopic(currentToken);
}
}, [subscribeStatus, currentToken]);

useEffect(() => {
if (openSuccessAlert === true) {
if (openSuccessAlert) {
setOpenSuccessAlert(false);
}
if (!_.isEmpty(message)) {
Expand All @@ -98,7 +98,7 @@ function Settings(): JSX.Element {
setSubscribeStatus(e.target.checked);

setOpenSuccessAlert(true);
if (e.target.checked === true) {
if (e.target.checked) {
setMessage('Subscribe message success!');
} else {
setMessage('Unsubscribe message success!');
Expand Down
8 changes: 4 additions & 4 deletions src/components/snackBar/SnackBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ function SnackBar(props: any): JSX.Element {
const [message, setMessage] = useState<string>('');

useEffect(() => {
if (props.openSuccessAlert === true) {
if (props.openSuccessAlert) {
setOpenSuccessAlert(true);
}
}, [props.openSuccessAlert]);

useEffect(() => {
if (props.openErrorAlert === true) {
if (props.openErrorAlert) {
setOpenErrorAlert(true);
}
}, [props.openErrorAlert]);
Expand All @@ -105,7 +105,7 @@ function SnackBar(props: any): JSX.Element {
const renderSnackBar = () => {
let snackBar: any = null;

if (openSuccessAlert === true) {
if (openSuccessAlert) {
snackBar = (
<Snackbar
anchorOrigin={{
Expand All @@ -120,7 +120,7 @@ function SnackBar(props: any): JSX.Element {
</Snackbar>
);
}
if (openErrorAlert === true) {
if (openErrorAlert) {
snackBar = (
<Snackbar
anchorOrigin={{
Expand Down

0 comments on commit 30ceb67

Please sign in to comment.