diff --git a/backend/clubs/views.py b/backend/clubs/views.py index d8a127c62..fb4c2bb10 100644 --- a/backend/clubs/views.py +++ b/backend/clubs/views.py @@ -1276,6 +1276,18 @@ def upload_file(self, request, *args, **kwargs): return file_upload_endpoint_helper(request, code=club.code) + @action(detail=True, methods=["get"]) + def history(self, request, *args, **kwargs): + """ + Return a simplified approval history for the club. + """ + club = self.get_object() + return Response( + club.history.order_by("approved_on").values( + "approved", "approved_on", "approved_by", "history_date" + ) + ) + @action(detail=True, methods=["get"]) def owned_badges(self, request, *args, **kwargs): """ diff --git a/frontend/components/ClubPage/ClubApprovalDialog.tsx b/frontend/components/ClubPage/ClubApprovalDialog.tsx index faa479759..facc2b159 100644 --- a/frontend/components/ClubPage/ClubApprovalDialog.tsx +++ b/frontend/components/ClubPage/ClubApprovalDialog.tsx @@ -30,9 +30,17 @@ type ConfirmParams = { message: ReactElement | string } +type HistoricItem = { + approved: boolean | null + approved_on: string | null + approved_by: string | null + history_date: string +} + const ClubApprovalDialog = ({ club }: Props): ReactElement | null => { const router = useRouter() const year = getCurrentSchoolYear() + const [history, setHistory] = useState([]) const [comment, setComment] = useState(club.approved_comment || '') const [loading, setLoading] = useState(false) const [confirmModal, setConfirmModal] = useState(null) @@ -62,6 +70,10 @@ const ClubApprovalDialog = ({ club }: Props): ReactElement | null => { doApiRequest('/templates/?format=json') .then((resp) => resp.json()) .then(setTemplates) + + doApiRequest(`/clubs/${club.code}/history/?format=json`) + .then((resp) => resp.json()) + .then(setHistory) } setComment(