forked from podkrepi-bg/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for the special user with the right credentials to mark a succe…
…ssfull donation as invalid. This would help us manually fix issues with stripe.
- Loading branch information
Showing
7 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react' | ||
import { useRouter } from 'next/router' | ||
import { useMutation } from '@tanstack/react-query' | ||
import { observer } from 'mobx-react' | ||
import { AxiosError, AxiosResponse } from 'axios' | ||
import { useTranslation } from 'next-i18next' | ||
|
||
import { DonationResponse } from 'gql/donations' | ||
import { ApiErrors } from 'service/apiErrors' | ||
import { AlertStore } from 'stores/AlertStore' | ||
import { routes } from 'common/routes' | ||
import DeleteDialog from 'components/admin/DeleteDialog' | ||
import { useInvalidateStripeDonation } from 'service/donation' | ||
|
||
import { InvalidateStore } from '../DonationsPage' | ||
|
||
type Props = { | ||
onUpdate: () => void | ||
} | ||
|
||
export default observer(function InvalidateModal({ onUpdate }: Props) { | ||
const router = useRouter() | ||
const { hideDelete, selectedRecord } = InvalidateStore | ||
const { t } = useTranslation() | ||
|
||
const mutationFn = useInvalidateStripeDonation() | ||
|
||
const invalidateMutation = useMutation< | ||
AxiosResponse<DonationResponse>, | ||
AxiosError<ApiErrors>, | ||
string | ||
>({ | ||
mutationFn, | ||
onError: () => AlertStore.show(t('donations:alerts:error'), 'error'), | ||
onSuccess: () => { | ||
hideDelete() | ||
AlertStore.show(t('donations:alerts:invalidate'), 'success') | ||
router.push(routes.admin.donations.index) | ||
onUpdate() | ||
}, | ||
}) | ||
|
||
function invalidateHandler() { | ||
invalidateMutation.mutate(selectedRecord.id) | ||
} | ||
|
||
return <DeleteDialog modalStore={InvalidateStore} deleteHandler={invalidateHandler} /> | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters