Skip to content

Commit 57e2318

Browse files
committed
Merge branch 'develop' into EBE-565-Report-page
# Conflicts: # openApi/openapi.merchants.portal.yml # src/App.tsx # src/api/MerchantsApiClient.ts # src/routes.tsx # src/services/merchantService.ts # src/utils/__tests__/formatUtils.test.ts
2 parents 3d80b22 + e44b124 commit 57e2318

28 files changed

+2832
-1574
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ definitions/*
55
src/react-app-env.d.ts
66
Dangerfile.ts
77
src/reportWebVitals.ts
8-
**/generated/**
8+
**/generated/**
9+
openApi/scripts/**

openApi/openapi.merchants.portal.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,18 +1915,7 @@ paths:
19151915
content:
19161916
multipart/form-data:
19171917
schema:
1918-
allOf:
1919-
- $ref: "#/components/schemas/InvoiceDTO"
1920-
- type: object
1921-
properties:
1922-
file:
1923-
type: string
1924-
format: binary
1925-
description: Invoice file
1926-
docNumber:
1927-
type: string
1928-
maxLength: 255
1929-
description: Invoice document number
1918+
$ref: "#/components/schemas/InvoiceDTO"
19301919
responses:
19311920
"204":
19321921
description: Ok - no content
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Post generation fix for merchants client
3+
*
4+
* This script fixes incorrect multipart generation for:
5+
* updateInvoiceTransaction
6+
*
7+
* It replaces the broken body mapper:
8+
* body: ({ ["docNumber"]: docNumber }) => docNumber_.uri
9+
*
10+
* With proper FormData handling.
11+
*/
12+
13+
const fs = require("fs");
14+
const path = require("path");
15+
16+
const clientPath = path.resolve(
17+
__dirname,
18+
"../../src/api/generated/merchants/client.ts"
19+
);
20+
21+
if (!fs.existsSync(clientPath)) {
22+
console.log("Merchants client not found, skipping fixPostGen.");
23+
process.exit(0);
24+
}
25+
26+
let content = fs.readFileSync(clientPath, "utf8");
27+
28+
// Fix broken multipart body mapping
29+
content = content.replace(
30+
/body:\s*\(\{\s*\["docNumber"\]:\s*docNumber\s*\}\)\s*=>\s*docNumber_\.uri,/g,
31+
`body: (bodyParams) => {
32+
const formData = new FormData();
33+
if (bodyParams?.file) {
34+
formData.append("file", bodyParams.file);
35+
}
36+
if (bodyParams?.docNumber) {
37+
formData.append("docNumber", bodyParams.docNumber);
38+
}
39+
return formData;
40+
},`
41+
);
42+
43+
// Remove unused destructuring if present
44+
content = content.replace(
45+
/\(\{\s*\["docNumber"\]:\s*docNumber\s*\}\)/g,
46+
"(bodyParams)"
47+
);
48+
49+
fs.writeFileSync(clientPath, content);
50+
51+
console.log("✅ Merchants client multipart fix applied.");

src/App.tsx

Lines changed: 79 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import RefundRequests from './pages/refundRequests/RefundRequests';
2929
import ROUTES from './routes';
3030
import { useInitiativesList } from './hooks/useInitiativesList';
3131
import ShopDetails from './pages/refundRequests/detail/ShopDetails';
32+
import ModifyDocument from './pages/modifyDocument/ModifyDocument';
3233
import ExportReport from './pages/exportReport/ExportReport';
3334

3435
const SecuredRoutes = withLogin(
@@ -39,80 +40,94 @@ const SecuredRoutes = withLogin(
3940
useEffect(() => {
4041
setMatch(
4142
matchPath(location.pathname, {
42-
path: [ROUTES.HOME, ROUTES.DISCOUNTS, ROUTES.OVERVIEW, ROUTES.STORES, ROUTES.REPORTED_USERS, ROUTES.STORES_DETAIL, ROUTES.REFUND_REQUESTS, ROUTES.REFUND_REQUESTS_STORE],
43+
path: [
44+
ROUTES.HOME,
45+
ROUTES.DISCOUNTS,
46+
ROUTES.OVERVIEW,
47+
ROUTES.STORES,
48+
ROUTES.REPORTED_USERS,
49+
ROUTES.STORES_DETAIL,
50+
ROUTES.REFUND_REQUESTS,
51+
ROUTES.REFUND_REQUESTS_STORE,
52+
],
4353
exact: true,
4454
strict: false,
45-
}));
55+
})
56+
);
4657
}, [location]);
4758

48-
useInitiativesList(match);
59+
useInitiativesList(match);
4960

50-
return(
51-
<AlertProvider>
52-
<Layout>
53-
<Switch>
54-
<Route path={routes.HOME} exact={true}>
55-
<InitiativesList />
56-
</Route>
57-
<Route path={routes.ASSISTANCE} exact={true}>
58-
<Assistance />
59-
</Route>
61+
return (
62+
<AlertProvider>
63+
<Layout>
64+
<Switch>
65+
<Route path={routes.HOME} exact={true}>
66+
<InitiativesList />
67+
</Route>
68+
<Route path={routes.ASSISTANCE} exact={true}>
69+
<Assistance />
70+
</Route>
6071

61-
<Route path={routes.TOS} exact={true}>
62-
<TOS />
63-
</Route>
72+
<Route path={routes.TOS} exact={true}>
73+
<TOS />
74+
</Route>
6475

65-
<Route path={routes.PRIVACY_POLICY} exact={true}>
66-
<PrivacyPolicy />
67-
</Route>
76+
<Route path={routes.PRIVACY_POLICY} exact={true}>
77+
<PrivacyPolicy />
78+
</Route>
6879

69-
{/* <Route path={routes.DISCOUNTS} exact={true}>
80+
{/* <Route path={routes.DISCOUNTS} exact={true}>
7081
<InitiativeDiscounts />
7182
</Route> */}
72-
<Route path={routes.OVERVIEW} exact={true}>
73-
<InitiativeOverview />
74-
</Route>
75-
<Route path={routes.STORES_UPLOAD} exact={true}>
76-
<InitiativeStoresUpload />
77-
</Route>
78-
<Route path={routes.STORES} exact={true}>
79-
<InitiativeStores />
80-
</Route>
81-
<Route path={routes.REPORTED_USERS} exact={true}>
82-
<ReportedUsers />
83-
</Route>
84-
<Route path={routes.EXPORT_REPORT} exact={true}>
85-
<ExportReport />
86-
</Route>
87-
<Route path={routes.REPORTED_USERS_INSERT} exact={true}>
88-
<InsertReportedUser />
89-
</Route>
90-
<Route path={routes.STORES_DETAIL} exact={true}>
91-
<StoreProvider>
92-
<InitiativeStoreDetail />
93-
</StoreProvider>
94-
</Route>
95-
<Route path={routes.NEW_DISCOUNT} exact={true}>
96-
<NewDiscount />
97-
</Route>
98-
<Route path={routes.ACCEPT_NEW_DISCOUNT} exact={true}>
99-
<AcceptNewDiscount />
100-
</Route>
101-
<Route path={routes.REFUND_REQUESTS} exact={true}>
102-
<RefundRequests />
103-
</Route>
104-
<Route path={routes.REFUND_REQUESTS_STORE} exact={true}>
105-
<StoreProvider>
106-
<ShopDetails />
107-
</StoreProvider>
108-
</Route>
109-
<Route path="*">
110-
<Redirect to={routes.HOME} />
111-
</Route>
112-
</Switch>
113-
</Layout>
114-
</AlertProvider>
115-
);})
83+
<Route path={routes.OVERVIEW} exact={true}>
84+
<InitiativeOverview />
85+
</Route>
86+
<Route path={routes.STORES_UPLOAD} exact={true}>
87+
<InitiativeStoresUpload />
88+
</Route>
89+
<Route path={routes.STORES} exact={true}>
90+
<InitiativeStores />
91+
</Route>
92+
<Route path={routes.REPORTED_USERS} exact={true}>
93+
<ReportedUsers />
94+
</Route>
95+
<Route path={routes.REPORTED_USERS_INSERT} exact={true}>
96+
<InsertReportedUser />
97+
</Route>
98+
<Route path={routes.EXPORT_REPORT} exact={true}>
99+
<ExportReport />
100+
</Route>
101+
<Route path={routes.STORES_DETAIL} exact={true}>
102+
<StoreProvider>
103+
<InitiativeStoreDetail />
104+
</StoreProvider>
105+
</Route>
106+
<Route path={routes.NEW_DISCOUNT} exact={true}>
107+
<NewDiscount />
108+
</Route>
109+
<Route path={routes.ACCEPT_NEW_DISCOUNT} exact={true}>
110+
<AcceptNewDiscount />
111+
</Route>
112+
<Route path={routes.REFUND_REQUESTS} exact={true}>
113+
<RefundRequests />
114+
</Route>
115+
<Route path={routes.REFUND_REQUESTS_STORE} exact={true}>
116+
<StoreProvider>
117+
<ShopDetails />
118+
</StoreProvider>
119+
</Route>
120+
<Route path={routes.MODIFY_DOCUMENT} exact={true}>
121+
<ModifyDocument />
122+
</Route>
123+
<Route path="*">
124+
<Redirect to={routes.HOME} />
125+
</Route>
126+
</Switch>
127+
</Layout>
128+
</AlertProvider>
129+
);
130+
})
116131
);
117132

118133
const App = () => (

src/api/MerchantsApiClient.ts

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,24 @@ export const MerchantApi = {
7878
return extractResponse(result, 200, onRedirectToLogin);
7979
},
8080

81-
getMerchantTransactionsProcessed: async (params: {
82-
initiativeId: string;
83-
page?: number;
84-
size?: number;
85-
sort?: string;
86-
fiscalCode?: string;
87-
status?: string;
88-
rewardBatchId?: string;
89-
rewardBatchTrxStatus?: string;
90-
pointOfSaleId?: string;
91-
trxCode?: string;
92-
}): Promise<MerchantTransactionsListDTO> => {
81+
getMerchantTransactionsProcessed: async (
82+
params: {
83+
initiativeId: string;
84+
page?: number;
85+
size?: number;
86+
sort?: string;
87+
fiscalCode?: string;
88+
status?: string;
89+
rewardBatchId?: string;
90+
rewardBatchTrxStatus?: string;
91+
pointOfSaleId?: string;
92+
trxCode?: string;
93+
}
94+
): Promise<MerchantTransactionsListDTO> => {
9395
const result = await apiClient.getMerchantTransactionsProcessed({
94-
...params,
96+
...params
9597
});
96-
console.log('[DEBUG] getMerchantTransactionsProcessed:', result);
98+
console.log("[DEBUG] getMerchantTransactionsProcessed:", result);
9799
return extractResponse(result, 200, onRedirectToLogin);
98100
},
99101

@@ -352,6 +354,33 @@ export const MerchantApi = {
352354
});
353355
return extractResponse(result, 200, onRedirectToLogin);
354356
},
357+
358+
updateInvoiceTransaction: async (
359+
transactionId: string,
360+
file: File,
361+
pointOfSaleId: string,
362+
docNumber?: string
363+
): Promise<{ code: string; message: string }> => {
364+
const result = await apiClient.updateInvoiceTransaction({
365+
transactionId,
366+
file,
367+
docNumber,
368+
'x-point-of-sale-id': pointOfSaleId,
369+
} as any);
370+
371+
if (!isRight(result)) {
372+
return {
373+
code:
374+
(result.left as any)?.at?.(0)?.value ??
375+
(result.left as any)?.at?.(0)?.actual,
376+
message:
377+
(result.left as any)?.at?.(0)?.context?.[1]?.actual?.message,
378+
};
379+
} else {
380+
return extractResponse(result, 204, onRedirectToLogin);
381+
}
382+
},
383+
355384
};
356385

357386

0 commit comments

Comments
 (0)