Skip to content

Commit

Permalink
bring back verify manual
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Szewczyk committed Dec 23, 2024
1 parent 41b3dba commit ed9fe9c
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 27 deletions.
7 changes: 6 additions & 1 deletion src/frontend/data/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2285,9 +2285,10 @@ type Mutations {
discardPaymentVerificationPlan(paymentVerificationPlanId: ID!, version: BigInt): DiscardPaymentVerificationPlan
invalidPaymentVerificationPlan(paymentVerificationPlanId: ID!, version: BigInt): InvalidPaymentVerificationPlan
deletePaymentVerificationPlan(paymentVerificationPlanId: ID!, version: BigInt): DeletePaymentVerificationPlan
updatePaymentVerificationStatusAndReceivedAmount(paymentVerificationId: ID!, receivedAmount: Decimal!, status: PaymentVerificationStatusForUpdate, version: BigInt): UpdatePaymentVerificationStatusAndReceivedAmount
markPaymentAsFailed(paymentId: ID!): MarkPaymentAsFailedMutation
revertMarkPaymentAsFailed(deliveredQuantity: Decimal!, deliveryDate: Date!, paymentId: ID!): RevertMarkPaymentAsFailedMutation
updatePaymentVerificationStatusAndReceivedAmount(paymentVerificationId: ID!, receivedAmount: Decimal!, status: PaymentVerificationStatusForUpdate, version: BigInt): UpdatePaymentVerificationStatusAndReceivedAmount
updatePaymentVerificationReceivedAndReceivedAmount(paymentVerificationId: ID!, received: Boolean!, receivedAmount: Decimal!, version: BigInt): UpdatePaymentVerificationReceivedAndReceivedAmount
actionPaymentPlanMutation(input: ActionPaymentPlanInput!, version: BigInt): ActionPaymentPlanMutation
createPaymentPlan(input: CreatePaymentPlanInput!): CreatePaymentPlanMutation
openPaymentPlan(input: OpenPaymentPlanInput!, version: BigInt): OpenPaymentPlanMutation
Expand Down Expand Up @@ -4413,6 +4414,10 @@ type UpdatePaymentPlanMutation {
paymentPlan: PaymentPlanNode
}

type UpdatePaymentVerificationReceivedAndReceivedAmount {
paymentVerification: PaymentVerificationNode
}

type UpdatePaymentVerificationStatusAndReceivedAmount {
paymentVerification: PaymentVerificationNode
}
Expand Down
83 changes: 83 additions & 0 deletions src/frontend/src/__generated__/graphql.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { gql } from '@apollo/client';

export const UPDATE_PAYMENT_VERIFICATION_STATUS_AND_RECEIVED_AMOUNT = gql`
mutation updatePaymentVerificationReceivedAndReceivedAmount(
$paymentVerificationId: ID!
$receivedAmount: Decimal!
$received: Boolean!
) {
updatePaymentVerificationReceivedAndReceivedAmount(
paymentVerificationId: $paymentVerificationId
receivedAmount: $receivedAmount
received: $received
) {
paymentVerification {
id
status
receivedAmount
paymentVerificationPlan {
id
receivedCount
notReceivedCount
respondedCount
receivedCount
receivedWithProblemsCount
}
}
}
}
`;
54 changes: 28 additions & 26 deletions src/frontend/src/components/payments/VerifyManual.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import { DialogActions } from '@containers/dialogs/DialogActions';
import { DialogContainer } from '@containers/dialogs/DialogContainer';
import { DialogFooter } from '@containers/dialogs/DialogFooter';
import { DialogTitleWrapper } from '@containers/dialogs/DialogTitleWrapper';
import { useSnackbar } from '@hooks/useSnackBar';
import { FormikRadioGroup } from '@shared/Formik/FormikRadioGroup';
import { FormikTextField } from '@shared/Formik/FormikTextField';
import { PaymentVerificationStatus } from '@generated/graphql';
import {
PaymentVerificationStatus,
useUpdatePaymentVerificationReceivedAndReceivedAmountMutation,
} from '@generated/graphql';
import { AutoSubmitFormOnEnter } from '@core/AutoSubmitFormOnEnter';

export interface Props {
Expand All @@ -27,32 +31,30 @@ export function VerifyManual({
}: Props): ReactElement {
const { t } = useTranslation();
const [verifyManualDialogOpen, setVerifyManualDialogOpen] = useState(false);
// const { showMessage } = useSnackbar();
//TODO: WE DONT KNOW NOW
// const [mutate, { error }] =
// useUpdatePaymentVerificationReceivedAndReceivedAmountMutation();
const { showMessage } = useSnackbar();
const [mutate, { error }] =
useUpdatePaymentVerificationReceivedAndReceivedAmountMutation();

const submit = (values): void => {
console.log(values);
// try {
// await mutate({
// variables: {
// paymentVerificationId,
// received: values.status === 'RECEIVED',
// receivedAmount:
// values.status === 'RECEIVED'
// ? parseFloat(values.receivedAmount).toFixed(2)
// : 0,
// },
// });
// } catch (e) {
// e.graphQLErrors.map((x) => showMessage(x.message));
// return;
// }
// if (!error) {
// setVerifyManualDialogOpen(false);
// showMessage(t('Payment has been verified.'));
// }
const submit = async (values): Promise<void> => {
try {
await mutate({
variables: {
paymentVerificationId,
received: values.status === 'RECEIVED',
receivedAmount:
values.status === 'RECEIVED'
? parseFloat(values.receivedAmount).toFixed(2)
: 0,
},
});
} catch (e) {
e.graphQLErrors.map((x) => showMessage(x.message));
return;
}
if (!error) {
setVerifyManualDialogOpen(false);
showMessage(t('Payment has been verified.'));
}
};

const initialValues = {
Expand Down

0 comments on commit ed9fe9c

Please sign in to comment.