From ac1d11c7f5bf2f6da9471ab0b3895ffa695def36 Mon Sep 17 00:00:00 2001 From: Menaka Date: Fri, 28 Jun 2024 11:12:24 +0530 Subject: [PATCH] Update image upload , refresh and edit --- src/screens/Diary/DiaryCreate.tsx | 6 +++++- src/screens/Diary/DiaryView.tsx | 9 ++++++++- src/screens/NoticeBoard/NoticeBoardView.tsx | 10 +++++++++- src/screens/Student/StudentCreate.tsx | 6 +++++- src/screens/Student/StudentUpdate.tsx | 6 +++++- src/screens/Student/StudentView.tsx | 2 ++ src/screens/class/classView.tsx | 4 ++-- src/screens/school/schoolView.tsx | 4 ++-- 8 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/screens/Diary/DiaryCreate.tsx b/src/screens/Diary/DiaryCreate.tsx index 2a90e97..e1972d1 100644 --- a/src/screens/Diary/DiaryCreate.tsx +++ b/src/screens/Diary/DiaryCreate.tsx @@ -106,8 +106,12 @@ class DiaryCreate extends React.Component{ if (this.props.fileInfo.hasOwnProperty('data')) { if (this.props.fileInfo.data?.url) { + let image = this.props.fileInfo.data?.url; + if (Array.isArray(image)) { + image = image[0]; + } const imageURL: any = `${this.imageBaseUrl + this.props.fileInfo.data?.url[0]}` - this.setState({ isImageUploaded: true, image: this.props.fileInfo.data?.url[0], imagePreviewURL: imageURL }) + this.setState({ isImageUploaded: true, image: image, imagePreviewURL: imageURL }) if (this.state.image) { this.props.initDiaryImage() } diff --git a/src/screens/Diary/DiaryView.tsx b/src/screens/Diary/DiaryView.tsx index 4e90f67..f7bc6b5 100644 --- a/src/screens/Diary/DiaryView.tsx +++ b/src/screens/Diary/DiaryView.tsx @@ -45,7 +45,8 @@ class DiaryView extends React.PureComponent{ isVisible: false, images: [], reply: "", - academicYear: '' + academicYear: '', + isFetching: false }; constructor(props: any) { @@ -138,6 +139,7 @@ class DiaryView extends React.PureComponent{ page: this.state.page, token: this.token, academic_year: this.state.academicYear.toString(), class_id: this.props.route.params.info.class_id, sort_by: 'asc', order_by: 'created_at' }) + this.setState({isFetching: false,}) } hasLoadMore = () => { @@ -168,6 +170,9 @@ class DiaryView extends React.PureComponent{ } } + onRefresh() { + this.setState({isFetching: true,},() => {this.fetchDiaryDetailList()}); +} toDiaryCreate = () => { if(!this.props.loading) { @@ -338,6 +343,8 @@ class DiaryView extends React.PureComponent{ onEndReachedThreshold={0.1} removeClippedSubviews initialNumToRender={2} + onRefresh={() => this.onRefresh()} + refreshing={this.state.isFetching} />} {!this.props.loading && this.props.records.length === 0 && {common.noDataFound}} diff --git a/src/screens/NoticeBoard/NoticeBoardView.tsx b/src/screens/NoticeBoard/NoticeBoardView.tsx index ab8944f..0ad734a 100644 --- a/src/screens/NoticeBoard/NoticeBoardView.tsx +++ b/src/screens/NoticeBoard/NoticeBoardView.tsx @@ -31,7 +31,8 @@ class NoticeBoardView extends React.Component{ isVisible: false, images: [], webViewHeight: null, - academicYear: '' + academicYear: '', + isFetching: false }; constructor(props: any) { @@ -97,6 +98,7 @@ class NoticeBoardView extends React.Component{ page: this.state.page, token: this.token, academic_year: this.state.academicYear.toString(), class_id: this.props.route.params.info.class_id, sort_by: 'asc', order_by: 'created_at' }) + this.setState({isFetching: false,}) } setImageVisible = () => { @@ -124,6 +126,10 @@ class NoticeBoardView extends React.Component{ } } + onRefresh() { + this.setState({isFetching: true,},() => {this.fetchNoticeboardData()}); + } + renderRow = ({ item }: any) => { const renderers = { oembed: (attribs:any) => { @@ -227,6 +233,8 @@ class NoticeBoardView extends React.Component{ keyExtractor={(item, index) => index.toString()} onEndReached={this.hasLoadMore} onEndReachedThreshold={0.1} + onRefresh={() => this.onRefresh()} + refreshing={this.state.isFetching} />} {!this.props.loading && this.props.records.length === 0 && {common.noDataFound}} diff --git a/src/screens/Student/StudentCreate.tsx b/src/screens/Student/StudentCreate.tsx index f43ffa1..fb0e6dd 100644 --- a/src/screens/Student/StudentCreate.tsx +++ b/src/screens/Student/StudentCreate.tsx @@ -115,8 +115,12 @@ class StudentCreate extends React.Component{ if (this.props.fileInfo.hasOwnProperty('data')) { if (this.props.fileInfo.data?.url) { + let image = this.props.fileInfo.data?.url; + if (Array.isArray(image)) { + image = image[0]; + } const imageURL: any = `${this.imageBaseUrl + this.props.fileInfo.data?.url}` - this.setState({ isImageUploaded: true, image: this.props.fileInfo.data?.url, imagePreviewURL: imageURL }) + this.setState({ isImageUploaded: true, image: image, imagePreviewURL: imageURL }) if (this.state.image) { this.props.initStudentImage() } diff --git a/src/screens/Student/StudentUpdate.tsx b/src/screens/Student/StudentUpdate.tsx index 9b26f00..e4d2033 100644 --- a/src/screens/Student/StudentUpdate.tsx +++ b/src/screens/Student/StudentUpdate.tsx @@ -117,8 +117,12 @@ class StudentUpdate extends React.Component{ if (this.props.fileInfo.hasOwnProperty('data')) { if (this.props.fileInfo.data?.url) { + let image = this.props.fileInfo.data?.url; + if (Array.isArray(image)) { + image = image[0]; + } const imageURL: any = `${this.imageBaseUrl + this.props.fileInfo.data?.url}` - this.setState({ isImageUploaded: true, image: this.props.fileInfo.data?.url, imagePreviewURL: imageURL }) + this.setState({ isImageUploaded: true, image: image, imagePreviewURL: imageURL }) if (this.state.image) { this.props.initStudentImage() } diff --git a/src/screens/Student/StudentView.tsx b/src/screens/Student/StudentView.tsx index f504ad8..8b4b278 100644 --- a/src/screens/Student/StudentView.tsx +++ b/src/screens/Student/StudentView.tsx @@ -205,9 +205,11 @@ class StudentView extends React.Component{ {this.isLoggedinAs && ((this.isLoggedinAs === UserRoles.schoolAdmin)) && this.props.route.params.info?.class_active && + {item?.studentclass_details?.is_active && + } {/* {item?.studentclass_details?.is_active && } diff --git a/src/screens/class/classView.tsx b/src/screens/class/classView.tsx index c263e61..b1e687b 100644 --- a/src/screens/class/classView.tsx +++ b/src/screens/class/classView.tsx @@ -136,10 +136,10 @@ class ClassView extends React.Component{ - - + */} {item.is_active && } {!item.is_active && } diff --git a/src/screens/school/schoolView.tsx b/src/screens/school/schoolView.tsx index a2f31ba..c1a845a 100644 --- a/src/screens/school/schoolView.tsx +++ b/src/screens/school/schoolView.tsx @@ -230,9 +230,9 @@ class SchoolView extends React.Component{ } - + {/* - + */} )