-
Notifications
You must be signed in to change notification settings - Fork 0
Save reports #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Save reports #16
Changes from all commits
397a1a3
6adc030
c24dbd9
79b00fa
7f4f45e
613ada1
8c6c2ea
2b87786
b40f548
dbe7a78
dc575eb
3d1c674
8c264eb
779db73
d28a4b0
e6c8279
c3cd39b
f3b0bdb
368c780
f385002
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,15 +12,29 @@ import ShowReportModal from "./CommentModals/ShowReportModal"; | |
| interface CommentProps { | ||
| comments: CommentSchema[] | undefined; | ||
| date: number; | ||
| updateComments: Function; | ||
| timesheetID: number; | ||
| } | ||
|
|
||
| export function CommentCell({ comments, date, timesheetID }: CommentProps) { | ||
| export function CommentCell({ | ||
| comments, | ||
| date, | ||
| updateComments, | ||
| timesheetID, | ||
| }: CommentProps) { | ||
| const [currentComments, setCurrentComments] = useState( | ||
| getAllActiveCommentsOfType(CommentType.Comment, comments) | ||
| ); | ||
| const [reports, setReports] = useState( | ||
| getAllActiveCommentsOfType(CommentType.Report, comments) as ReportSchema[] | ||
| getAllActiveCommentsOfType(CommentType.Report, comments).map((comment) => ({ | ||
| AuthorID: comment.AuthorID, | ||
| Type: comment.Type, | ||
| Content: comment.Content.split(",")[0], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be careful using ',' as a delimiter here, since it wouldn't surprise me for the |
||
| Notified: comment.Content.split(",")[1], | ||
| Explanation: comment.Content.split(",")[2], | ||
| State: comment.State, | ||
| Timestamp: comment.Timestamp, | ||
| })) as ReportSchema[] | ||
| ); | ||
| const [isEditable, setisEditable] = useState(false); | ||
| const user = useContext(UserContext); | ||
|
|
@@ -32,6 +46,21 @@ export function CommentCell({ comments, date, timesheetID }: CommentProps) { | |
| } | ||
| }, [user?.Type]); | ||
|
|
||
| const updateReports = (updatedReports: ReportSchema[]) => { | ||
| setReports(updatedReports); | ||
|
|
||
| const reportsToComments = updatedReports.map((report) => ({ | ||
| UUID: report.AuthorID, | ||
| AuthorID: report.AuthorID, | ||
| Type: report.Type, | ||
| Timestamp: report.Timestamp, | ||
| Content: `${report.Content},${report.Notified},${report.Explanation}`, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a reason why we need to try and turn reports into comments? Can we just fully separate out the reports and comments in the fields? |
||
| State: report.State, | ||
| })) as CommentSchema[]; | ||
|
|
||
| updateComments("Comment", currentComments.concat(reportsToComments)); | ||
| }; | ||
|
|
||
| return ( | ||
| <Stack direction="row"> | ||
| <ShowCommentModal | ||
|
|
@@ -42,7 +71,7 @@ export function CommentCell({ comments, date, timesheetID }: CommentProps) { | |
| /> | ||
| <ShowReportModal | ||
| date={date} | ||
| setReports={setReports} | ||
| setReports={updateReports} | ||
| reports={reports} | ||
| isEditable={isEditable} | ||
| timesheetID={timesheetID} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also have a UUID field in the report schema as well - it's an easy way to have a unique identifier for each comment/report. Otherwise, looks good!