Skip to content

Commit

Permalink
Fix pit report comment removal in scouter management
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso committed Feb 17, 2025
1 parent 8b29ceb commit cf7020b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pages/[teamSlug]/[seasonSlug]/[competitonSlug]/scouters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Scouters(props: {
const team = props.team;
const comp = props.competition;

const { session, status } = useCurrentSession();
const { session } = useCurrentSession();
const isManager = session?.user?._id
? team?.owners.includes(session.user?._id)
: false;
Expand Down Expand Up @@ -141,9 +141,9 @@ export default function Scouters(props: {
setReports((reports) => {
if (!reports) return reports;

const { _id, ...updated } = reports[comment.dbId];
const { _id, ...old } = reports[comment.dbId];
promise = api.updateReport(
{ data: { ...updated.data, comments: "" } },
{ data: { ...old.data, comments: "" } },
comment.dbId,
);

Expand All @@ -154,7 +154,12 @@ export default function Scouters(props: {
}

function removePitComment(comment: Comment) {
return api.updatePitreport(comment.dbId, { comments: "" });
const { _id, ...old } = data.pitReports.find(
(r) => r._id === comment.dbId,
)!;
return api.updatePitreport(comment.dbId, {
data: { ...old.data, comments: "" },
});
}

function removeSubjectiveComment(comment: Comment) {
Expand Down

0 comments on commit cf7020b

Please sign in to comment.