import gql from 'graphql-tag' import { graphql, compose } from 'react-apollo' const DeleteWithdraw = gql` mutation DeleteWithdraw($wdwid: Int) { deleteWithdraw(wdwid: $wdwid) { } }` const GetWithdraw = gql` query GetWithdraw($wdwid: Int, $depid: Int, $paymentMethod: String, $actorid: String, $refAccountid: Int, $operatorid: String, $amount: Float, $phone: Int, $pin: Int, $currency: String, $paymentContext: String) { getWithdraw(wdwid: $wdwid, depid: $depid, paymentMethod: $paymentMethod, actorid: $actorid, refAccountid: $refAccountid, operatorid: $operatorid, amount: $amount, phone: $phone, pin: $pin, currency: $currency, paymentContext: $paymentContext) { payid actorid amount ref_accountid payment_method operatorid phone pin currency payment_context } }` const GetWithdraw = gql` query GetWithdraw($payid: Int, $paymentMethod: String, $actorid: String, $refAccountid: Int, $operatorid: String, $amount: Float, $phone: Int, $pin: Int, $currency: String, $paymentContext: String) { getWithdraw(payid: $payid, paymentMethod: $paymentMethod, actorid: $actorid, refAccountid: $refAccountid, operatorid: $operatorid, amount: $amount, phone: $phone, pin: $pin, currency: $currency, paymentContext: $paymentContext) { } }` const withAppSyncWithdraw = compose( graphql(GetWithdraw, { name: 'getWithdraw', options: (ownProps) => ({ fetchPolicy: 'cache-and-network', variables: { wdwid: ownProps.wdwid, depid: ownProps.depid, paymentMethod: ownProps.paymentMethod, actorid: ownProps.actorid, refAccountid: ownProps.refAccountid, operatorid: ownProps.operatorid, amount: ownProps.amount, phone: ownProps.phone, pin: ownProps.pin, currency: ownProps.currency, paymentContext: ownProps.paymentContext } }), props: (props) => { if (props.getWithdraw.error) console.log(props.getWithdraw.error) return props } }) graphql(DeleteWithdraw, { props: (props) => ({ deleteWithdraw: ownProps => props.mutate({ variables: { wdwid: ownProps.wdwid }, optimisticResponse: () => ({ deleteWithdraw: { ...ownProps, __typename: 'Withdraw', version: 1 } }) }) }) }) ) export { DeleteWithdraw, GetWithdraw, GetWithdraw, withAppSyncWithdraw }