From 5ee794edf49cd8c6e8590904ab84a012ed15e0f8 Mon Sep 17 00:00:00 2001 From: rassadin11 Date: Tue, 30 Jun 2026 16:29:54 +0300 Subject: [PATCH] profile refactor --- payment.json | 1 + src/features/payment/api/paymentApi.ts | 58 +++++- src/features/payment/hooks/useOperations.ts | 15 ++ src/features/payment/hooks/useOrders.ts | 15 -- src/features/payment/index.ts | 18 +- .../model/sbpWithdrawalStatusLabels.ts | 14 ++ ...dule.css => OperationAccordion.module.css} | 12 ++ .../ui/OperationAccordion.tsx | 187 ++++++++++++++++++ .../transactions-list/ui/OrderAccordion.tsx | 120 ----------- .../transactions-list/ui/TransactionsList.tsx | 16 +- .../ui/WithdrawalStatusBadge.module.css | 42 ++++ .../ui/WithdrawalStatusBadge.tsx | 15 ++ 12 files changed, 361 insertions(+), 152 deletions(-) create mode 100644 payment.json create mode 100644 src/features/payment/hooks/useOperations.ts delete mode 100644 src/features/payment/hooks/useOrders.ts create mode 100644 src/widgets/transactions-list/model/sbpWithdrawalStatusLabels.ts rename src/widgets/transactions-list/ui/{OrderAccordion.module.css => OperationAccordion.module.css} (92%) create mode 100644 src/widgets/transactions-list/ui/OperationAccordion.tsx delete mode 100644 src/widgets/transactions-list/ui/OrderAccordion.tsx create mode 100644 src/widgets/transactions-list/ui/WithdrawalStatusBadge.module.css create mode 100644 src/widgets/transactions-list/ui/WithdrawalStatusBadge.tsx diff --git a/payment.json b/payment.json new file mode 100644 index 0000000..8d4e398 --- /dev/null +++ b/payment.json @@ -0,0 +1 @@ +{"openapi":"3.1.0","info":{"title":"Elcsa. Pay service Service","version":"0.1.0"},"paths":{"/order/create":{"post":{"tags":["orders"],"summary":"Create Order","operationId":"create_order_order_create_post","parameters":[{"name":"X-CSRF-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Csrf-Token"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrder"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrderResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/order/{order_id}/status":{"get":{"tags":["orders"],"summary":"Order Status","operationId":"order_status_order__order_id__status_get","parameters":[{"name":"order_id","in":"path","required":true,"schema":{"type":"string","title":"Order Id"}},{"name":"X-CSRF-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Csrf-Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderStatusResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/order/{order_id}":{"get":{"tags":["orders"],"summary":"Order Detail","operationId":"order_detail_order__order_id__get","parameters":[{"name":"order_id","in":"path","required":true,"schema":{"type":"string","title":"Order Id"}},{"name":"X-CSRF-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Csrf-Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderDetailResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/order/webhook/itpay":{"post":{"tags":["orders"],"summary":"Itpay Webhook","operationId":"itpay_webhook_order_webhook_itpay_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/orders":{"get":{"tags":["orders"],"summary":"List Orders","operationId":"list_orders_orders_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"default":20,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"X-CSRF-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Csrf-Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrdersResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/payment/config":{"get":{"tags":["payments"],"summary":"Payment Config","operationId":"payment_config_payment_config_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentConfigResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/payment/quote":{"get":{"tags":["payments"],"summary":"Payment Quote","operationId":"payment_quote_payment_quote_get","parameters":[{"name":"usdt_amount","in":"query","required":true,"schema":{"anyOf":[{"type":"number","exclusiveMinimum":0.0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,18}|(?=[\\d.]{1,21}0*$)\\d{0,18}\\.\\d{0,2}0*$)"}],"title":"Usdt Amount"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentQuoteResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/payment/quote/rub":{"get":{"tags":["payments"],"summary":"Payment Quote From Rub","operationId":"payment_quote_from_rub_payment_quote_rub_get","parameters":[{"name":"total_rub","in":"query","required":true,"schema":{"anyOf":[{"type":"number","exclusiveMinimum":0.0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,18}|(?=[\\d.]{1,21}0*$)\\d{0,18}\\.\\d{0,2}0*$)"}],"title":"Total Rub"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentQuoteResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/payment/orders":{"get":{"tags":["payments"],"summary":"Payment List Orders","operationId":"payment_list_orders_payment_orders_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"default":20,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"X-CSRF-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Csrf-Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrdersResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/payment/payments":{"get":{"tags":["payments"],"summary":"Payment List Payments","operationId":"payment_list_payments_payment_payments_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"default":20,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"X-CSRF-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Csrf-Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientOperationsResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/payment/payments/{payment_id}":{"get":{"tags":["payments"],"summary":"Payment Detail","operationId":"payment_detail_payment_payments__payment_id__get","parameters":[{"name":"payment_id","in":"path","required":true,"schema":{"type":"string","title":"Payment Id"}},{"name":"X-CSRF-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Csrf-Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentDetailResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/payments":{"get":{"tags":["payments"],"summary":"List Payments","operationId":"list_payments_payments_get","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"default":20,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"X-CSRF-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Csrf-Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientOperationsResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/sbp-payout/banks":{"get":{"tags":["sbp payouts"],"summary":"Sbp Banks","operationId":"sbp_banks_sbp_payout_banks_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SbpBanksResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/sbp-payout/withdrawals":{"post":{"tags":["sbp payouts"],"summary":"Create Sbp Withdrawal","operationId":"create_sbp_withdrawal_sbp_payout_withdrawals_post","parameters":[{"name":"X-CSRF-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Csrf-Token"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSbpWithdrawal"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSbpWithdrawalResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/sbp-payout/withdrawals/{withdraw_id}":{"get":{"tags":["sbp payouts"],"summary":"Sbp Withdrawal Detail","operationId":"sbp_withdrawal_detail_sbp_payout_withdrawals__withdraw_id__get","parameters":[{"name":"withdraw_id","in":"path","required":true,"schema":{"type":"string","title":"Withdraw Id"}},{"name":"X-CSRF-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Csrf-Token"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SbpWithdrawalDetailResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Too Many Requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Bad Gateway","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Service Unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/ping":{"post":{"summary":"Ping","operationId":"ping_ping_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Ping Ping Post"}}}}}}},"/health":{"get":{"summary":"Health","operationId":"health_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Health Health Get"}}}}}}}},"components":{"schemas":{"ClientOperationResponse":{"properties":{"type":{"type":"string","title":"Type"},"created_at":{"type":"string","title":"Created At"},"payment":{"anyOf":[{"$ref":"#/components/schemas/PaymentResponse"},{"type":"null"}]},"withdrawal":{"anyOf":[{"$ref":"#/components/schemas/SbpWithdrawalOperationResponse"},{"type":"null"}]}},"type":"object","required":["type","created_at"],"title":"ClientOperationResponse"},"ClientOperationsResponse":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"operations":{"items":{"$ref":"#/components/schemas/ClientOperationResponse"},"type":"array","title":"Operations"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["status_code","operations","limit","offset"],"title":"ClientOperationsResponse"},"CreateOrder":{"properties":{"usdt_amount":{"anyOf":[{"type":"number","exclusiveMinimum":0.0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,18}|(?=[\\d.]{1,21}0*$)\\d{0,18}\\.\\d{0,2}0*$)"}],"title":"Usdt Amount"},"usdt_exchange_rate":{"anyOf":[{"type":"number","exclusiveMinimum":0.0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,18}|(?=[\\d.]{1,21}0*$)\\d{0,18}\\.\\d{0,2}0*$)"}],"title":"Usdt Exchange Rate"},"gas_fee":{"anyOf":[{"type":"number","exclusiveMinimum":0.0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,18}|(?=[\\d.]{1,21}0*$)\\d{0,18}\\.\\d{0,2}0*$)"}],"title":"Gas Fee"},"total_price":{"anyOf":[{"type":"number","exclusiveMinimum":0.0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,18}|(?=[\\d.]{1,21}0*$)\\d{0,18}\\.\\d{0,2}0*$)"}],"title":"Total Price"}},"type":"object","required":["usdt_amount","usdt_exchange_rate","gas_fee","total_price"],"title":"CreateOrder"},"CreateOrderResponse":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"order":{"$ref":"#/components/schemas/OrderPaymentResponse"}},"type":"object","required":["status_code","order"],"title":"CreateOrderResponse"},"CreateSbpWithdrawal":{"properties":{"bank_id":{"type":"string","maxLength":32,"minLength":1,"title":"Bank Id"},"usdt_amount":{"anyOf":[{"type":"number","maximum":5000.0,"minimum":100.0},{"type":"string","pattern":"^(?!^[-+.]*$)[+-]?0*(?:\\d{0,18}|(?=[\\d.]{1,21}0*$)\\d{0,18}\\.\\d{0,2}0*$)"}],"title":"Usdt Amount"}},"type":"object","required":["bank_id","usdt_amount"],"title":"CreateSbpWithdrawal"},"CreateSbpWithdrawalResponse":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"withdrawal":{"$ref":"#/components/schemas/SbpWithdrawalResponse"}},"type":"object","required":["status_code","withdrawal"],"title":"CreateSbpWithdrawalResponse"},"ErrorResponse":{"properties":{"detail":{"type":"string","title":"Detail"},"status_code":{"type":"integer","title":"Status Code"}},"type":"object","required":["detail","status_code"],"title":"ErrorResponse"},"OrderDetailResponse":{"properties":{"order":{"$ref":"#/components/schemas/OrderPaymentResponse"},"payment":{"anyOf":[{"$ref":"#/components/schemas/PaymentResponse"},{"type":"null"}]},"status_code":{"type":"integer","title":"Status Code"}},"type":"object","required":["order","status_code"],"title":"OrderDetailResponse"},"OrderPaymentResponse":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"},"updated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated At"},"user_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User Id"},"usdt_amount":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usdt Amount"},"usdt_exchange_rate":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usdt Exchange Rate"},"gas_fee":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Gas Fee"},"total_price":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Total Price"},"service_fee":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Fee"},"status":{"anyOf":[{"$ref":"#/components/schemas/OrderStatus"},{"type":"null"}]},"client_payment_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Client Payment Id"},"itpay_payment_qr_url_desktop":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Payment Qr Url Desktop"},"itpay_payment_qr_url_android":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Payment Qr Url Android"},"itpay_payment_qr_url_ios":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Payment Qr Url Ios"},"itpay_payment_qr_image_desktop":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Payment Qr Image Desktop"},"itpay_payment_qr_image_android":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Payment Qr Image Android"},"itpay_payment_qr_image_ios":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Payment Qr Image Ios"},"itpay_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Id"},"itpay_qr_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Qr Id"},"itpay_amount":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Amount"},"itpay_created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Created At"}},"type":"object","title":"OrderPaymentResponse"},"OrderStatus":{"type":"string","enum":["pending","rejected","completed","cancelled","error"],"title":"OrderStatus"},"OrderStatusResponse":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"order_id":{"type":"string","title":"Order Id"},"order_status":{"anyOf":[{"$ref":"#/components/schemas/OrderStatus"},{"type":"null"}]},"payment_status":{"anyOf":[{"$ref":"#/components/schemas/PaymentStatus"},{"type":"null"}]},"receipt_cloudekassir_link":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Receipt Cloudekassir Link"},"web3_transaction_hash":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Web3 Transaction Hash"},"updated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated At"}},"type":"object","required":["status_code","order_id"],"title":"OrderStatusResponse"},"OrderWithPaymentResponse":{"properties":{"order":{"$ref":"#/components/schemas/OrderPaymentResponse"},"payment":{"anyOf":[{"$ref":"#/components/schemas/PaymentResponse"},{"type":"null"}]}},"type":"object","required":["order"],"title":"OrderWithPaymentResponse"},"OrdersResponse":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"orders":{"items":{"$ref":"#/components/schemas/OrderWithPaymentResponse"},"type":"array","title":"Orders"},"limit":{"type":"integer","title":"Limit"},"offset":{"type":"integer","title":"Offset"}},"type":"object","required":["status_code","orders","limit","offset"],"title":"OrdersResponse"},"PaymentConfigResponse":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"usdt_exchange_rate":{"type":"string","title":"Usdt Exchange Rate"},"gas_fee":{"type":"string","title":"Gas Fee"},"service_fee_rate":{"type":"string","title":"Service Fee Rate"},"one_usdt_service_fee":{"type":"string","title":"One Usdt Service Fee"},"one_usdt_total_price":{"type":"string","title":"One Usdt Total Price"},"created_at":{"type":"string","title":"Created At"}},"type":"object","required":["status_code","usdt_exchange_rate","gas_fee","service_fee_rate","one_usdt_service_fee","one_usdt_total_price","created_at"],"title":"PaymentConfigResponse"},"PaymentDetailResponse":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"payment":{"$ref":"#/components/schemas/PaymentResponse"}},"type":"object","required":["status_code","payment"],"title":"PaymentDetailResponse"},"PaymentQuoteResponse":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"usdt_amount":{"type":"string","title":"Usdt Amount"},"usdt_exchange_rate":{"type":"string","title":"Usdt Exchange Rate"},"gas_fee":{"type":"string","title":"Gas Fee"},"service_fee":{"type":"string","title":"Service Fee"},"total_price":{"type":"string","title":"Total Price"},"service_fee_rate":{"type":"string","title":"Service Fee Rate"},"created_at":{"type":"string","title":"Created At"}},"type":"object","required":["status_code","usdt_amount","usdt_exchange_rate","gas_fee","service_fee","total_price","service_fee_rate","created_at"],"title":"PaymentQuoteResponse"},"PaymentResponse":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"},"updated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated At"},"user_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User Id"},"order_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Order Id"},"status":{"anyOf":[{"$ref":"#/components/schemas/PaymentStatus"},{"type":"null"}]},"receipt_cloudekassir_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Receipt Cloudekassir Id"},"receipt_cloudekassir_link":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Receipt Cloudekassir Link"},"itpay_payment_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Payment Id"},"itpay_paid_amount":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Itpay Paid Amount"},"transaction_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Transaction Id"},"web3_transaction_hash":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Web3 Transaction Hash"},"paid_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Paid At"},"expired_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expired Date"}},"type":"object","title":"PaymentResponse"},"PaymentStatus":{"type":"string","enum":["pending","money_accepted","web3_processing","web3_hash_error","web3_balance_problem","usdt_delivered","receipt_error","completed"],"title":"PaymentStatus"},"SbpBankResponse":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"}},"type":"object","required":["id","name"],"title":"SbpBankResponse"},"SbpBanksResponse":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"banks":{"items":{"$ref":"#/components/schemas/SbpBankResponse"},"type":"array","title":"Banks"}},"type":"object","required":["status_code","banks"],"title":"SbpBanksResponse"},"SbpWithdrawalDetailResponse":{"properties":{"status_code":{"type":"integer","title":"Status Code"},"withdrawal":{"$ref":"#/components/schemas/SbpWithdrawalResponse"}},"type":"object","required":["status_code","withdrawal"],"title":"SbpWithdrawalDetailResponse"},"SbpWithdrawalOperationResponse":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"},"updated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated At"},"user_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User Id"},"bank_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bank Id"},"bank_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bank Name"},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone"},"usdt_amount":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usdt Amount"},"rub_amount":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Rub Amount"},"usdt_exchange_rate":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usdt Exchange Rate"},"service_fee_rate":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Fee Rate"},"service_fee_usdt":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Fee Usdt"},"mozen_order_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Mozen Order Id"},"trace_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Trace Id"},"status":{"anyOf":[{"$ref":"#/components/schemas/SbpWithdrawalStatus"},{"type":"null"}]},"provider_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Provider Error"},"usdt_received_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usdt Received At"},"payout_created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Payout Created At"},"payout_completed_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Payout Completed At"}},"type":"object","title":"SbpWithdrawalOperationResponse"},"SbpWithdrawalResponse":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id"},"created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created At"},"updated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated At"},"user_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User Id"},"bank_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bank Id"},"bank_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bank Name"},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone"},"usdt_amount":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usdt Amount"},"rub_amount":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Rub Amount"},"usdt_exchange_rate":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usdt Exchange Rate"},"service_fee_rate":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Fee Rate"},"service_fee_usdt":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Service Fee Usdt"},"mozen_order_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Mozen Order Id"},"trace_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Trace Id"},"status":{"anyOf":[{"$ref":"#/components/schemas/SbpWithdrawalStatus"},{"type":"null"}]},"provider_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Provider Error"},"usdt_received_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usdt Received At"},"payout_created_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Payout Created At"},"payout_completed_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Payout Completed At"}},"type":"object","title":"SbpWithdrawalResponse"},"SbpWithdrawalStatus":{"type":"string","enum":["created","waiting_usdt","usdt_underpaid","usdt_received","wallet_error","payout_processing","payout_completed","payout_failed","cancelled","expired"],"title":"SbpWithdrawalStatus"}}}} \ No newline at end of file diff --git a/src/features/payment/api/paymentApi.ts b/src/features/payment/api/paymentApi.ts index 6f33ddd..07fc79e 100644 --- a/src/features/payment/api/paymentApi.ts +++ b/src/features/payment/api/paymentApi.ts @@ -161,17 +161,61 @@ export interface Payment { expired_date: string } -export interface OrderWithPayment { - order: Order +export type SbpWithdrawalStatus = + | 'created' + | 'waiting_usdt' + | 'usdt_underpaid' + | 'usdt_received' + | 'wallet_error' + | 'payout_processing' + | 'payout_completed' + | 'payout_failed' + | 'cancelled' + | 'expired' + +export interface SbpWithdrawalOperation { + id: string | null + created_at: string | null + updated_at: string | null + user_id: string | null + bank_id: string | null + bank_name: string | null + phone: string | null + usdt_amount: string | null + rub_amount: string | null + usdt_exchange_rate: string | null + service_fee_rate: string | null + service_fee_usdt: string | null + mozen_order_id: string | null + trace_id: string | null + status: SbpWithdrawalStatus | null + provider_error: string | null + usdt_received_at: string | null + payout_created_at: string | null + payout_completed_at: string | null +} + +export type ClientOperationType = 'payment' | 'withdrawal' + +export interface ClientOperation { + type: ClientOperationType | string + created_at: string payment: Payment | null + withdrawal: SbpWithdrawalOperation | null } -export interface OrdersResponse { - orders: OrderWithPayment[] +export interface ClientOperationsResponse { + status_code: number + operations: ClientOperation[] + limit: number + offset: number } -export const ORDERS_LIMIT = 20 +export const OPERATIONS_LIMIT = 20 -export function getOrders(offset: number, limit: number = ORDERS_LIMIT): Promise { - return doPaymentRequest(`/payment/orders?offset=${offset}&limit=${limit}`, {}, true) +export function getClientOperations( + offset: number, + limit: number = OPERATIONS_LIMIT, +): Promise { + return doPaymentRequest(`/payment/payments?offset=${offset}&limit=${limit}`, {}, true) } diff --git a/src/features/payment/hooks/useOperations.ts b/src/features/payment/hooks/useOperations.ts new file mode 100644 index 0000000..80f1f8d --- /dev/null +++ b/src/features/payment/hooks/useOperations.ts @@ -0,0 +1,15 @@ +import { useInfiniteQuery } from '@tanstack/react-query' +import { getClientOperations, OPERATIONS_LIMIT } from '../api/paymentApi' + +export function useOperations() { + return useInfiniteQuery({ + queryKey: ['payment', 'operations'], + queryFn: ({ pageParam }) => getClientOperations(pageParam as number), + initialPageParam: 0, + getNextPageParam: (lastPage, allPages) => { + if (lastPage.operations.length < OPERATIONS_LIMIT) return undefined + return allPages.length * OPERATIONS_LIMIT + }, + staleTime: 30_000, + }) +} diff --git a/src/features/payment/hooks/useOrders.ts b/src/features/payment/hooks/useOrders.ts deleted file mode 100644 index 8c08d5a..0000000 --- a/src/features/payment/hooks/useOrders.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { useInfiniteQuery } from '@tanstack/react-query' -import { getOrders, ORDERS_LIMIT } from '../api/paymentApi' - -export function useOrders() { - return useInfiniteQuery({ - queryKey: ['payment', 'orders'], - queryFn: ({ pageParam }) => getOrders(pageParam as number), - initialPageParam: 0, - getNextPageParam: (lastPage, allPages) => { - if (lastPage.orders.length < ORDERS_LIMIT) return undefined - return allPages.length * ORDERS_LIMIT - }, - staleTime: 30_000, - }) -} diff --git a/src/features/payment/index.ts b/src/features/payment/index.ts index 946cb86..e902261 100644 --- a/src/features/payment/index.ts +++ b/src/features/payment/index.ts @@ -2,6 +2,20 @@ export { usePaymentConfig } from './hooks/usePaymentConfig' export { usePaymentQuote } from './hooks/usePaymentQuote' export { usePaymentQuoteByRub } from './hooks/usePaymentQuoteByRub' export { useCreateOrder } from './hooks/useCreateOrder' -export { useOrders } from './hooks/useOrders' +export { useOperations } from './hooks/useOperations' export { useCurrencyConversion } from './model/useCurrencyConversion' -export type { PaymentConfig, PaymentQuote, CreateOrderPayload, OrderResult, Order, Payment, OrderWithPayment, OrderStatus, PaymentStatus } from './api/paymentApi' +export type { + PaymentConfig, + PaymentQuote, + CreateOrderPayload, + OrderResult, + Order, + Payment, + OrderStatus, + PaymentStatus, + ClientOperation, + ClientOperationsResponse, + ClientOperationType, + SbpWithdrawalOperation, + SbpWithdrawalStatus, +} from './api/paymentApi' diff --git a/src/widgets/transactions-list/model/sbpWithdrawalStatusLabels.ts b/src/widgets/transactions-list/model/sbpWithdrawalStatusLabels.ts new file mode 100644 index 0000000..471c708 --- /dev/null +++ b/src/widgets/transactions-list/model/sbpWithdrawalStatusLabels.ts @@ -0,0 +1,14 @@ +import type { SbpWithdrawalStatus } from '@features/payment' + +export const SBP_WITHDRAWAL_STATUS_LABELS: Record = { + created: 'Создан', + waiting_usdt: 'Ожидание USDT', + usdt_underpaid: 'USDT недоплачен', + usdt_received: 'USDT получен', + wallet_error: 'Ошибка кошелька', + payout_processing: 'Выплата в обработке', + payout_completed: 'Выплата завершена', + payout_failed: 'Выплата не прошла', + cancelled: 'Отменён', + expired: 'Истёк', +} diff --git a/src/widgets/transactions-list/ui/OrderAccordion.module.css b/src/widgets/transactions-list/ui/OperationAccordion.module.css similarity index 92% rename from src/widgets/transactions-list/ui/OrderAccordion.module.css rename to src/widgets/transactions-list/ui/OperationAccordion.module.css index 427c1dd..ec0fa69 100644 --- a/src/widgets/transactions-list/ui/OrderAccordion.module.css +++ b/src/widgets/transactions-list/ui/OperationAccordion.module.css @@ -31,6 +31,18 @@ flex-wrap: wrap; } +.opType { + font-size: 11px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.6px; + color: var(--text-secondary); + background: rgba(255, 255, 255, 0.06); + border-radius: 6px; + padding: 2px 8px; + white-space: nowrap; +} + .summaryDate { font-size: 13px; color: var(--text-secondary); diff --git a/src/widgets/transactions-list/ui/OperationAccordion.tsx b/src/widgets/transactions-list/ui/OperationAccordion.tsx new file mode 100644 index 0000000..fa2632e --- /dev/null +++ b/src/widgets/transactions-list/ui/OperationAccordion.tsx @@ -0,0 +1,187 @@ +import { useState } from 'react' +import type { ClientOperation, Payment, SbpWithdrawalOperation } from '@features/payment' +import { formatDate, formatRub, truncateHash } from '../model/format' +import { StatusBadge } from './StatusBadge' +import { WithdrawalStatusBadge } from './WithdrawalStatusBadge' +import { CopyButton } from './CopyButton' +import styles from './OperationAccordion.module.css' + +interface Props { + op: ClientOperation +} + +export function OperationAccordion({ op }: Props) { + const [isOpen, setIsOpen] = useState(false) + + // type — основной признак, но опираемся и на наличие данных (защита от пустых полей). + const isWithdrawal = op.type === 'withdrawal' ? !!op.withdrawal : !op.payment && !!op.withdrawal + + if (isWithdrawal && op.withdrawal) { + return setIsOpen((v) => !v)} summary={withdrawalSummary(op.withdrawal)}> + {withdrawalBody(op.withdrawal)} + + } + + if (op.payment) { + return setIsOpen((v) => !v)} summary={paymentSummary(op.payment)}> + {paymentBody(op.payment)} + + } + + return null +} + +// --- Каркас аккордеона (общий для обоих типов операций) --- + +interface AccordionProps { + isOpen: boolean + onToggle: () => void + summary: React.ReactNode + children: React.ReactNode +} + +function Accordion({ isOpen, onToggle, summary, children }: AccordionProps) { + return ( +
+ + +
+
+
{children}
+
+
+
+ ) +} + +// --- Платёж --- + +function paymentSummary(payment: Payment) { + return ( + <> + + Платёж + {formatDate(payment.created_at)} + {payment.status && } + + + {payment.itpay_paid_amount && ( + {formatRub(payment.itpay_paid_amount)} ₽ + )} + + + ) +} + +function paymentBody(payment: Payment) { + return ( + <> +
+

Платёж

+
+ Статус + {payment.status ? : } +
+ + +
+ +
+

Транзакция

+
+ Хэш транзакции + + + {truncateHash(payment.web3_transaction_hash ?? '')} + + {payment.web3_transaction_hash && } + +
+
+ Чек + {payment.receipt_cloudekassir_link ? ( + + Открыть → + + ) : ( + + )} +
+
+ + ) +} + +// --- Вывод (СБП) --- + +function withdrawalSummary(w: SbpWithdrawalOperation) { + return ( + <> + + Вывод СБП + {formatDate(w.created_at ?? '')} + {w.status && } + + + {w.usdt_amount && {w.usdt_amount} USDT} + {w.rub_amount && {formatRub(w.rub_amount)} ₽} + + + ) +} + +function withdrawalBody(w: SbpWithdrawalOperation) { + return ( + <> +
+

Вывод (СБП)

+
+ Статус + {w.status ? : } +
+ + + + + {w.provider_error && } +
+ +
+

Суммы

+ + + + +
+ + ) +} + +function InfoRow({ label, value, emphasised }: { label: string; value: string; emphasised?: boolean }) { + return ( +
+ {label} + {value} +
+ ) +} diff --git a/src/widgets/transactions-list/ui/OrderAccordion.tsx b/src/widgets/transactions-list/ui/OrderAccordion.tsx deleted file mode 100644 index 8b770ee..0000000 --- a/src/widgets/transactions-list/ui/OrderAccordion.tsx +++ /dev/null @@ -1,120 +0,0 @@ -import { useState } from 'react' -import type { OrderWithPayment } from '@features/payment' -import { formatDate, formatRub, truncateHash } from '../model/format' -import { StatusBadge } from './StatusBadge' -import { CopyButton } from './CopyButton' -import styles from './OrderAccordion.module.css' - -interface Props { - item: OrderWithPayment -} - -export function OrderAccordion({ item }: Props) { - const [isOpen, setIsOpen] = useState(false) - const { order, payment } = item - - return ( -
- - -
-
-
-
-

Заказ

- - - - - -
- -
-

Платёж

- {payment ? ( - <> -
- Статус - -
- - -
- Хэш транзакции - - - {truncateHash(payment.web3_transaction_hash)} - - {payment.web3_transaction_hash && ( - - )} - -
-
- Чек - {payment.receipt_cloudekassir_link ? ( - - Открыть → - - ) : ( - - )} -
- - ) : ( -
- -
- )} -
-
-
-
-
- ) -} - -function InfoRow({ label, value, emphasised }: { label: string; value: string; emphasised?: boolean }) { - return ( -
- {label} - {value} -
- ) -} diff --git a/src/widgets/transactions-list/ui/TransactionsList.tsx b/src/widgets/transactions-list/ui/TransactionsList.tsx index 5188ecb..688a807 100644 --- a/src/widgets/transactions-list/ui/TransactionsList.tsx +++ b/src/widgets/transactions-list/ui/TransactionsList.tsx @@ -1,22 +1,22 @@ -import { useOrders } from '@features/payment' +import { useOperations } from '@features/payment' import { Spinner } from '@shared/ui' -import { OrderAccordion } from './OrderAccordion' +import { OperationAccordion } from './OperationAccordion' import styles from './TransactionsList.module.css' export function TransactionsList() { - const { data, isLoading, isError, fetchNextPage, hasNextPage, isFetchingNextPage } = useOrders() + const { data, isLoading, isError, fetchNextPage, hasNextPage, isFetchingNextPage } = useOperations() - const items = data?.pages.flatMap(p => p.orders) ?? [] + const items = data?.pages.flatMap(p => p.operations) ?? [] if (isLoading) return - if (isError) return

Не удалось загрузить транзакции. Попробуйте обновить страницу.

- if (items.length === 0) return

У вас пока нет транзакций.

+ if (isError) return

Не удалось загрузить операции. Попробуйте обновить страницу.

+ if (items.length === 0) return

У вас пока нет операций.

return ( <>
- {items.map(item => ( - + {items.map((op, i) => ( + ))}
diff --git a/src/widgets/transactions-list/ui/WithdrawalStatusBadge.module.css b/src/widgets/transactions-list/ui/WithdrawalStatusBadge.module.css new file mode 100644 index 0000000..9c749f6 --- /dev/null +++ b/src/widgets/transactions-list/ui/WithdrawalStatusBadge.module.css @@ -0,0 +1,42 @@ +.badge { + font-size: 12px; + font-weight: 600; + padding: 3px 10px; + border-radius: 999px; + white-space: nowrap; + flex-shrink: 0; +} + +/* Успех */ +.status_usdt_received, +.status_payout_completed { + background: rgba(0, 196, 140, 0.15); + color: var(--success, #00c48c); +} + +/* В процессе / ожидание */ +.status_created { + background: rgba(74, 109, 255, 0.15); + color: #4a6dff; +} + +.status_waiting_usdt, +.status_payout_processing { + background: rgba(155, 109, 255, 0.15); + color: #9b6dff; +} + +/* Ошибки */ +.status_usdt_underpaid, +.status_wallet_error, +.status_payout_failed, +.status_expired { + background: rgba(255, 77, 77, 0.15); + color: #ff4d4d; +} + +/* Нейтральное */ +.status_cancelled { + background: rgba(255, 255, 255, 0.08); + color: var(--text-secondary); +} diff --git a/src/widgets/transactions-list/ui/WithdrawalStatusBadge.tsx b/src/widgets/transactions-list/ui/WithdrawalStatusBadge.tsx new file mode 100644 index 0000000..cca90f8 --- /dev/null +++ b/src/widgets/transactions-list/ui/WithdrawalStatusBadge.tsx @@ -0,0 +1,15 @@ +import type { SbpWithdrawalStatus } from '@features/payment' +import { SBP_WITHDRAWAL_STATUS_LABELS } from '../model/sbpWithdrawalStatusLabels' +import styles from './WithdrawalStatusBadge.module.css' + +interface Props { + status: SbpWithdrawalStatus +} + +export function WithdrawalStatusBadge({ status }: Props) { + return ( + + {SBP_WITHDRAWAL_STATUS_LABELS[status] ?? status} + + ) +}