From e26581d42511159e394cdbb04e63ee8b13059a55 Mon Sep 17 00:00:00 2001 From: Boonkarit Date: Tue, 26 Aug 2025 15:47:41 +0700 Subject: [PATCH] fix don't get news list when user don't have project id --- src/navigation/AppStack.js | 16 ++-- src/navigation/MainNav.js | 6 +- src/screens/news/News.js | 129 ++++++++++++++++++--------------- src/screens/news/NewsDetail.js | 2 +- 4 files changed, 80 insertions(+), 73 deletions(-) diff --git a/src/navigation/AppStack.js b/src/navigation/AppStack.js index ede1746..d11d0ac 100644 --- a/src/navigation/AppStack.js +++ b/src/navigation/AppStack.js @@ -334,14 +334,9 @@ const MainTitle = connect(state => ({ userText = `${name[0]}`; projectName = props.user.project_name } - return - - {t('charoensin_asset')} {projectName} - - - 2.0 - - + return + {t('charoensin_asset')} {projectName} + }) const MainHeader = ({ navigation }) => { @@ -368,7 +363,7 @@ const MainHeader = ({ navigation }) => { }, []) return + 2.0 navigation.navigate('LanguageSelect')} style={{marginRight: 8}}> @@ -467,7 +463,7 @@ const AppStack = createStackNavigator({ ), headerLeftContainerStyle: { - width: '80%', + width: '75%', alignItems: 'center', justifyContent: 'center', }, diff --git a/src/navigation/MainNav.js b/src/navigation/MainNav.js index 26ea8ca..1011440 100644 --- a/src/navigation/MainNav.js +++ b/src/navigation/MainNav.js @@ -1,4 +1,4 @@ -import { createSwitchNavigator, createAppContainer } from 'react-navigation' +import { createSwitchNavigator, createAppContainer, SafeAreaView } from 'react-navigation' import AuthStack from './AuthStack' import AppStack from './AppStack' import React from 'react' @@ -19,9 +19,9 @@ export class AppNavContainer extends React.Component { } render () { - return + return {NavigationService.setTopLevelNavigator(navigatorRef)}}/> - + } } diff --git a/src/screens/news/News.js b/src/screens/news/News.js index 2fc48d9..7382d31 100644 --- a/src/screens/news/News.js +++ b/src/screens/news/News.js @@ -242,8 +242,24 @@ class NewsScreen extends Component { console.log('project id >>>> ', res.data.project_id) this.checkNotifiedPopup() if(res.data.project_id){ - await this.getAllNewsByProject(res.data.project_id) - + this.setState({ + loadPage: 1, + last_page: 1, + news_head: [{ + title: t('loading_news'), + content: t('loading_news'), + date: t('loading_news'), + is_new: false + }], + new_all: [{ + title: t('loading_news'), + content: t('loading_news'), + date: t('loading_news'), + is_new: false + }], + },async () => { + await this.getAllNewsByProject(res.data.project_id) + }) } this.setState({ noti_count: res.data.count_noti, @@ -328,20 +344,6 @@ class NewsScreen extends Component { console.log('initData >>> ') this.setState({ isLoading: true, - loadPage: 1, - last_page: 1, - news_head: [{ - title: t('loading_news'), - content: t('loading_news'), - date: t('loading_news'), - is_new: false - }], - new_all: [{ - title: t('loading_news'), - content: t('loading_news'), - date: t('loading_news'), - is_new: false - }], }, () => { Promise.all([ this.getUser(), @@ -594,24 +596,28 @@ class NewsScreen extends Component { } }} > - - this.renderNativeItemImages(item)} - horizontal={true} - showsHorizontalScrollIndicator={false} - pagingEnabled={true} - keyExtractor={this._keyExtractorNewHead} - onScroll={this._onCarouselScroll} - /> - - { - this.state.news_head ? - (this.state.news_head).map((item, i) => ) - : - } - - + { + this.state.user_project_id ? + + this.renderNativeItemImages(item)} + horizontal={true} + showsHorizontalScrollIndicator={false} + pagingEnabled={true} + keyExtractor={this._keyExtractorNewHead} + onScroll={this._onCarouselScroll} + /> + + { + this.state.news_head ? + (this.state.news_head).map((item, i) => ) + : + } + + : + } + { this.state.auth !== null && ( @@ -817,31 +823,36 @@ class NewsScreen extends Component { )) } - - { - return - }} - ListFooterComponent={() => { - if (!this.state.isLoadmore) return null - return () - }} - /> - + + { + this.state.user_project_id ? + + { + return + }} + ListFooterComponent={() => { + if (!this.state.isLoadmore) return null + return () + }} + /> + : + } + diff --git a/src/screens/news/NewsDetail.js b/src/screens/news/NewsDetail.js index 8637ee2..bbbe81a 100644 --- a/src/screens/news/NewsDetail.js +++ b/src/screens/news/NewsDetail.js @@ -97,7 +97,7 @@ export default class NewsDetailScreen extends Component { source_webview = { baseUrl: '', // uri: `${Config.API_BASE_URL_POWER_CONDO_PROD}/news/${this.state.news_id}/detail`, - uri: `${Config.API_BASE_URL_POWER_CONDO_DEV}/news/${this.state.news_id}/detail` + uri: `${Config.API_BASE_URL_POWER_CONDO_PROD}/news/${this.state.news_id}/detail` } // if(Platform.OS === 'android'){