diff --git a/src/screens/Diary/DiaryView.tsx b/src/screens/Diary/DiaryView.tsx
index 8614102..3ece377 100644
--- a/src/screens/Diary/DiaryView.tsx
+++ b/src/screens/Diary/DiaryView.tsx
@@ -14,6 +14,7 @@ import ImageView from "react-native-image-viewing"
import RenderHtml, { IGNORED_TAGS } from "react-native-render-html"
import { WebView } from 'react-native-webview'
import AutoHeightWebView from 'react-native-autoheight-webview'
+import { RadioButton } from 'react-native-paper'
const Sepator = ({ style }: any) =>
const contentWidth = Dimensions.get('window').width
@@ -43,7 +44,8 @@ class DiaryView extends React.PureComponent{
images: [],
reply: "",
academicYear: '',
- isFetching: false
+ isFetching: false,
+ records:[]
};
constructor(props: any) {
@@ -108,7 +110,7 @@ class DiaryView extends React.PureComponent{
this.fetchDiaryDetailList()
}
- componentDidUpdate() {
+ componentDidUpdate(prevProps:any) {
if (this.props.replyData.hasOwnProperty('status')) {
if (this.props.replyData.status) {
this.setState({ page: 1, reply: '' })
@@ -119,6 +121,9 @@ class DiaryView extends React.PureComponent{
})
}
}
+ if(prevProps.records != this.props.records){
+ this.setState({ records: this.props.records })
+ }
}
setImageVisible = () => {
@@ -161,9 +166,10 @@ class DiaryView extends React.PureComponent{
toDiaryReply = (data: any, item: any) => {
const diaryResponse: any = {
- reply: data
+ reply: data,
+ is_completed: item.is_completed
}
- if (item?.id && data) {
+ if ((item?.id && data && !item.is_homework) || (item.is_homework && this.isLoggedinAs === UserRoles.parent) || (item.is_homework && data)) {
this.props.sendReplyDiary({
token: this.token, id: item?.id, data: diaryResponse
})
@@ -180,6 +186,16 @@ class DiaryView extends React.PureComponent{
this.props.navigation.navigate("DiaryCreate", { info: this.props.route.params.info })
}
}
+
+ handleOptionChange = (id:any, selectedOption:any) => {
+ const is_completed = selectedOption == "true" ? true : false
+ const updatedData = this.state.records.map((item:any) =>
+ item.id === id ? { ...item, is_completed } : item
+ );
+ this.setState({ records: updatedData})
+
+ };
+
renderRow = ({ item }: any) => {
const renderers = {
oembed: (attribs:any) => {
@@ -261,6 +277,22 @@ class DiaryView extends React.PureComponent{
by {item?.posted_by} {item?.created_at && {moment(item?.created_at).fromNow()}}
+ {item?.is_homework && (this.isLoggedinAs === UserRoles.parent) &&
+
+ this.handleOptionChange(item.id, value)}
+ value={item.is_completed ? "true" : "false"}
+ >
+
+
+ Completed
+
+
+
+ Incomplete
+
+
+ }
{
- {item?.reply && item?.reply.map((replyInfo: any, index: any) => (
- (this.signedUserId === replyInfo?.parent_id) ?
+
+ {! (item.is_homework && item.is_homework) ?
+ item?.reply && item?.reply.map((replyInfo: any, index: any) => (
+ (this.signedUserId === replyInfo?.parent_id) ?
+
+
+ {replyInfo?.username && replyInfo?.username.charAt(0) || 'NA'}
+
+
+
+ {replyInfo?.username || 'NA'}
+ {moment(replyInfo?.reply_date).fromNow()}
+ {replyInfo?.message}
+
+ :
+
+
+ {replyInfo?.username && replyInfo?.username.charAt(0) || 'NA'}
+
+
+ {replyInfo?.username || 'NA'}
+ {moment(replyInfo?.reply_date).fromNow()}
+ {replyInfo?.message}
+
+
+ ))
+ :
+
+
+ No of Students: {item.class_list[0].no_of_assessments}
+ No of completed: {item.class_list[0].no_of_completed}
+ No of incompleted: {item.class_list[0].no_of_incompleted}
+
+ {item?.student_list.map((student: any, index: any) => (
- {replyInfo?.username && replyInfo?.username.charAt(0) || 'NA'}
+ {student?.student_name && student?.student_name.charAt(0) || 'NA'}
+
- {replyInfo?.username || 'NA'}
- {moment(replyInfo?.reply_date).fromNow()}
- {replyInfo?.message}
-
- :
-
-
- {replyInfo?.username && replyInfo?.username.charAt(0) || 'NA'}
-
-
- {replyInfo?.username || 'NA'}
- {moment(replyInfo?.reply_date).fromNow()}
- {replyInfo?.message}
+ {student.student_name}
+ {student?.reply_date && moment(student?.reply_date).fromNow()}
+
+ {student.is_completed ? "Completed" : "Incompleted"}
+ {student?.reply && student?.reply}
-
- ))}
-
-
-
+ ))}
+ {item?.others_reply && item?.others_reply.map((replyInfo: any, index: any) => (
+ (this.signedUserId === replyInfo?.parent_id) ?
+
+
+ {replyInfo?.username && replyInfo?.username.charAt(0) || 'NA'}
+
+
+
+ {replyInfo?.username || 'NA'}
+ {moment(replyInfo?.reply_date).fromNow()}
+ {replyInfo?.message}
+
+ :
+
+
+ {replyInfo?.username && replyInfo?.username.charAt(0) || 'NA'}
+
+
+ {replyInfo?.username || 'NA'}
+ {moment(replyInfo?.reply_date).fromNow()}
+ {replyInfo?.message}
+
+
+ ))}
+
+ }
)
}
-
+
render() {
- if (this.props.records.length) {
+ if (this.state.records.length) {
let diaryCategoryList: any = []
if (this.props.categoryList.hasOwnProperty('status')) {
@@ -316,7 +395,7 @@ class DiaryView extends React.PureComponent{
}
}
- this.props.records.forEach((diaryInfo: any) => {
+ this.state.records.forEach((diaryInfo: any) => {
if (diaryCategoryList.length) {
const findDiaryType: any = diaryCategoryList.find((item: any) => item.id === parseInt(diaryInfo.diary_type))
if (findDiaryType) {
@@ -334,9 +413,9 @@ class DiaryView extends React.PureComponent{
return (
- {this.props.records && index.toString()}
onEndReached={this.hasLoadMore}
@@ -346,7 +425,7 @@ class DiaryView extends React.PureComponent{
onRefresh={() => this.onRefresh()}
refreshing={this.state.isFetching}
/>}
- {!this.props.loading && this.props.records.length === 0 &&
+ {!this.props.loading && this.state.records.length === 0 &&
{common.noDataFound}}
{this.props.loading &&
@@ -394,8 +473,15 @@ const styles = StyleSheet.create({
width: 35,
height: 35,
borderRadius: 50,
-
- }
+ },
+ radioContainer: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ marginBottom: 10,
+ },
+ radioLabel: {
+ marginLeft: 8,
+ },
})