Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refund view changes #1315

Merged
merged 26 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1348458
feat: payment operation revamp
gitanjli525 Aug 23, 2024
a0ac73f
chore: refactor
gitanjli525 Aug 28, 2024
076555d
chore: bugfix
gitanjli525 Aug 30, 2024
2f89bb5
chore: refactor
gitanjli525 Aug 30, 2024
c3c1de4
chore: restructure view files and filterkeys logic update
gitanjli525 Sep 2, 2024
0139821
chore: merge main & resolve conflict
gitanjli525 Sep 2, 2024
40062b6
chore: css change
gitanjli525 Sep 2, 2024
fb23cfe
Merge branch 'main' into payment-views
gitanjli525 Sep 2, 2024
04f0c61
chore: refactor
gitanjli525 Sep 2, 2024
dd32e4e
Merge branch 'payment-views' of https://github.com/juspay/hyperswitch…
gitanjli525 Sep 2, 2024
b3fad74
chore: minor css
gitanjli525 Sep 2, 2024
32b5e3c
chore: merge main & resolve conflict
gitanjli525 Sep 3, 2024
1d6a9b5
chore: refactor
gitanjli525 Sep 3, 2024
283c02e
chore: refactor
gitanjli525 Sep 4, 2024
f54d636
chore: refactor
gitanjli525 Sep 4, 2024
9245d75
refactor: refactor code
gitanjli525 Sep 5, 2024
965c28b
feat: refunds revamp
gitanjli525 Sep 5, 2024
bb50656
chore: merge main & resolve conflict
gitanjli525 Sep 16, 2024
3782dd5
chore: merge main & resolve conflict
gitanjli525 Sep 16, 2024
eae69b6
chore: removed comment
gitanjli525 Sep 16, 2024
5e66d50
chore: merge main & resolve conflict
gitanjli525 Sep 25, 2024
b51a346
chore: merge main & resolve conflict
gitanjli525 Sep 25, 2024
add6cd2
Merge branch 'main' into refund-view-changes
gitanjli525 Sep 25, 2024
955f70c
Merge branch 'main' into refund-view-changes
gitanjli525 Sep 25, 2024
b74d464
chore: transaction view feature flag
gitanjli525 Sep 25, 2024
28ae14b
chore: addressed comments
gitanjli525 Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/screens/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ let useGetURL = () => {
}
| _ => ""
}
| REFUNDS_AGGREGATE =>
switch methodType {
| Get =>
switch queryParamerters {
| Some(queryParams) =>
switch transactionEntity {
| #Merchant => `refunds/aggregate?${queryParams}`
| #Profile => `refunds/profile/aggregate?${queryParams}`
| _ => `refunds/aggregate?${queryParams}`
gitanjli525 marked this conversation as resolved.
Show resolved Hide resolved
}
| None => `refunds/aggregate`
}
| _ => `refunds/aggregate`
}
| DISPUTES =>
switch methodType {
| Get =>
Expand Down
1 change: 1 addition & 0 deletions src/screens/APIUtils/APIUtilsTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type entityName =
| ORDERS
| ORDER_FILTERS
| ORDERS_AGGREGATE
| REFUNDS_AGGREGATE
| DEFAULT_FALLBACK
| ANALYTICS_SYSTEM_METRICS
| SDK_EVENT_LOGS
Expand Down
29 changes: 18 additions & 11 deletions src/screens/Refunds/Refund.res
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,29 @@ let make = () => {
None
}, (offset, filters, searchText))

let {generateReport} = HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom
let {generateReport, transactionView} =
HyperswitchAtom.featureFlagAtom->Recoil.useRecoilValueFromAtom

<ErrorBoundary>
<div className="min-h-[50vh]">
<div className="flex justify-between items-center">
<PageUtils.PageHeading title="Refunds" subTitle="View and manage all refunds" />
<OMPSwitchHelper.OMPViews
views={OMPSwitchUtils.transactionViewList(~checkUserEntity)}
selectedEntity={transactionEntity}
onChange={updateTransactionEntity}
/>
<PageUtils.PageHeading title="Refunds" subTitle="" />
gitanjli525 marked this conversation as resolved.
Show resolved Hide resolved
<div className="flex gap-4">
<OMPSwitchHelper.OMPViews
views={OMPSwitchUtils.transactionViewList(~checkUserEntity)}
selectedEntity={transactionEntity}
onChange={updateTransactionEntity}
/>
<RenderIf condition={generateReport && refundData->Array.length > 0}>
<GenerateReport entityName={REFUND_REPORT} />
</RenderIf>
</div>
</div>
<RenderIf condition={transactionView}>
<div className="flex gap-6 justify-around">
<TransactionView entity=TransactionViewTypes.Refunds />
</div>
</RenderIf>
<div className="flex justify-between gap-3">
<div className="flex-1">
<RemoteTableFilters
Expand All @@ -91,10 +102,6 @@ let make = () => {
entityName=REFUND_FILTERS
/>
</div>
<RenderIf condition={generateReport && refundData->Array.length > 0}>
<GenerateReport entityName={REFUND_REPORT} />
</RenderIf>
<PortalCapture key={`RefundsCustomizeColumn`} name={`RefundsCustomizeColumn`} />
</div>
<PageLoaderWrapper screenState customUI>
<LoadedTableWithCustomColumns
Expand Down
12 changes: 10 additions & 2 deletions src/screens/TransactionViews/TransactionView.res
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ let make = (~entity=TransactionViewTypes.Orders) => {
let updateViewsFilterValue = (view: TransactionViewTypes.viewTypes) => {
let customFilterKey = switch entity {
| Orders => "status"
| Refunds => "refund_status"
| _ => ""
}
let customFilter = `[${view->getViewsString(countRes)}]`
let customFilter = `[${view->getViewsString(countRes, entity)}]`

updateExistingKeys(Dict.fromArray([(customFilterKey, customFilter)]))

Expand Down Expand Up @@ -75,6 +76,12 @@ let make = (~entity=TransactionViewTypes.Orders) => {
~methodType=Get,
~queryParamerters=Some(`start_time=${startTime}&end_time=${endTime}`),
)
| Refunds =>
getURL(
~entityName=REFUNDS_AGGREGATE,
~methodType=Get,
~queryParamerters=Some(`start_time=${startTime}&end_time=${endTime}`),
)
| _ => ""
}

Expand Down Expand Up @@ -112,6 +119,7 @@ let make = (~entity=TransactionViewTypes.Orders) => {

let viewsArray = switch entity {
| Orders => paymentViewsArray
| Refunds => refundViewsArray
| _ => []
}

Expand All @@ -120,7 +128,7 @@ let make = (~entity=TransactionViewTypes.Orders) => {
<TransactionViewCard
key={i->Int.toString}
view={item}
count={getViewCount(item, countRes)->Int.toString}
count={getViewCount(item, countRes, entity)->Int.toString}
onViewClick
isActiveView={item == activeView}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/screens/TransactionViews/TransactionViewTypes.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
type operationsTypes = Orders | Refunds | Disputes

type viewTypes = All | Succeeded | Failed | Dropoffs | Cancelled
type viewTypes = All | Succeeded | Failed | Dropoffs | Cancelled | Pending
35 changes: 26 additions & 9 deletions src/screens/TransactionViews/TransactionViewUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ open TransactionViewTypes

let paymentViewsArray: array<viewTypes> = [All, Succeeded, Failed, Dropoffs, Cancelled]

let refundViewsArray: array<viewTypes> = [All, Succeeded, Failed, Pending]

let getViewsDisplayName = (view: viewTypes) => {
switch view {
| All => "All"
| Succeeded => "Succeeded"
| Failed => "Failed"
| Dropoffs => "Dropoffs"
| Cancelled => "Cancelled"
| Pending => "Pending"
}
}

Expand All @@ -18,6 +21,7 @@ let getViewTypeFromString = view => {
| "cancelled" => Cancelled
| "failed" => Failed
| "requires_payment_method" => Dropoffs
| "pending" => Pending
| _ => All
}
}
Expand All @@ -31,13 +35,26 @@ let getAllViewsString = obj => {
->Array.joinWith(",")
}

let getViewsString = (view, obj) => {
switch view {
| All => getAllViewsString(obj)
| Succeeded => "succeeded"
| Failed => "failed"
| Dropoffs => "requires_payment_method"
| Cancelled => "cancelled"
let getViewsString = (view, obj, entity) => {
switch entity {
| Orders =>
switch view {
| All => getAllViewsString(obj)
| Succeeded => "succeeded"
| Failed => "failed"
| Dropoffs => "requires_payment_method"
| Cancelled => "cancelled"
| Pending => "pending"
}
| Refunds =>
switch view {
| All => getAllViewsString(obj)
| Succeeded => "success"
| Failed => "failure"
| Pending => "pending"
gitanjli525 marked this conversation as resolved.
Show resolved Hide resolved
| _ => ""
}
| _ => ""
}
}

Expand All @@ -53,14 +70,14 @@ let getAllViewCount = obj => {
)
}

let getViewCount = (view, obj) => {
let getViewCount = (view, obj, entity) => {
open LogicUtils
switch view {
| All => getAllViewCount(obj)
| _ =>
obj
->getDictFromJsonObject
->getDictfromDict("status_with_count")
->getInt(view->getViewsString(obj), 0)
->getInt(view->getViewsString(obj, entity), 0)
}
}
Loading