Skip to content

Commit 254e472

Browse files
committed
[to remove] wip with create serializer
1 parent 12614aa commit 254e472

File tree

11 files changed

+40
-47
lines changed

11 files changed

+40
-47
lines changed

src/frontend/js/api/joanie/gen/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ export type { CertificationDefinition } from './models/CertificationDefinition';
1515
export type { Course } from './models/Course';
1616
export type { CourseRun } from './models/CourseRun';
1717
export type { CreditCard } from './models/CreditCard';
18+
export type { EmptyResponse } from './models/EmptyResponse';
1819
export { Enrollment } from './models/Enrollment';
20+
export type { ErrorResponse } from './models/ErrorResponse';
1921
export { Order } from './models/Order';
22+
export type { OrderAbortBody } from './models/OrderAbortBody';
2023
export { OrderCreateBody } from './models/OrderCreateBody';
21-
export { OrderCreateResponse } from './models/OrderCreateResponse';
24+
export type { OrderCreateResponse } from './models/OrderCreateResponse';
2225
export type { Payment } from './models/Payment';
2326
export { Product } from './models/Product';
2427

src/frontend/js/api/joanie/gen/models/Order.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type Order = {
1010
readonly created_on?: string;
1111
readonly certificate?: string;
1212
readonly enrollments?: string;
13-
readonly id?: string;
13+
id: string;
1414
readonly main_invoice?: string;
1515
organization?: string;
1616
readonly owner?: string;

src/frontend/js/api/joanie/gen/models/OrderCreateBody.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type OrderCreateBody = {
1212
readonly created_on?: string;
1313
readonly certificate?: string;
1414
readonly enrollments?: string;
15-
readonly id?: string;
15+
id: string;
1616
readonly main_invoice?: string;
1717
organization?: string;
1818
readonly owner?: string;

src/frontend/js/api/joanie/gen/models/OrderCreateResponse.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,11 @@
22
/* tslint:disable */
33
/* eslint-disable */
44

5+
import type { Order } from './Order';
56
import type { Payment } from './Payment';
67

78
export type OrderCreateResponse = {
8-
course: string;
9-
/**
10-
* date and time at which a record was created
11-
*/
12-
readonly created_on?: string;
13-
readonly certificate?: string;
14-
readonly enrollments?: string;
15-
id: string;
16-
readonly main_invoice?: string;
17-
organization?: string;
18-
readonly owner?: string;
19-
readonly total?: number;
20-
readonly total_currency?: string;
21-
product: string;
22-
readonly state?: OrderCreateResponse.state;
23-
readonly target_courses?: string;
9+
order: Order;
2410
payment_info?: Payment;
2511
};
2612

27-
export namespace OrderCreateResponse {
28-
29-
export enum state {
30-
PENDING = 'pending',
31-
CANCELED = 'canceled',
32-
FAILED = 'failed',
33-
VALIDATED = 'validated',
34-
}
35-
36-
37-
}
38-

src/frontend/js/api/joanie/gen/services/CertificatesService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ export class CertificatesService {
6666
/**
6767
* Retrieve a certificate through its id if it is owned by the authenticated user.
6868
* @param id
69-
* @returns Certificate
69+
* @returns binary File Attachment
7070
* @throws ApiError
7171
*/
7272
public certificatesDownload(
7373
id: string,
74-
): CancelablePromise<Certificate> {
74+
): CancelablePromise<Blob> {
7575
return this.httpRequest.request({
7676
method: 'GET',
7777
url: '/certificates/{id}/download/',

src/frontend/js/api/joanie/gen/services/OrdersService.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* tslint:disable */
33
/* eslint-disable */
44
import type { Order } from '../models/Order';
5+
import type { OrderAbortBody } from '../models/OrderAbortBody';
56
import type { OrderCreateBody } from '../models/OrderCreateBody';
67
import type { OrderCreateResponse } from '../models/OrderCreateResponse';
78

@@ -101,13 +102,13 @@ export class OrdersService {
101102
* Abort a pending order and the related payment if there is one.
102103
* @param id
103104
* @param data
104-
* @returns Order
105+
* @returns void
105106
* @throws ApiError
106107
*/
107108
public ordersAbort(
108109
id: string,
109-
data: Order,
110-
): CancelablePromise<Order> {
110+
data: OrderAbortBody,
111+
): CancelablePromise<void> {
111112
return this.httpRequest.request({
112113
method: 'POST',
113114
url: '/orders/{id}/abort/',
@@ -122,18 +123,23 @@ export class OrdersService {
122123
* Retrieve an invoice through its reference if it is related to
123124
* the order instance and owned by the authenticated user.
124125
* @param id
125-
* @returns Order
126+
* @param reference
127+
* @returns binary File Attachment
126128
* @throws ApiError
127129
*/
128130
public ordersInvoice(
129131
id: string,
130-
): CancelablePromise<Order> {
132+
reference: string,
133+
): CancelablePromise<Blob> {
131134
return this.httpRequest.request({
132135
method: 'GET',
133136
url: '/orders/{id}/invoice/',
134137
path: {
135138
'id': id,
136139
},
140+
query: {
141+
'reference': reference,
142+
},
137143
});
138144
}
139145

src/frontend/js/api/joanie/gen/services/ProductsService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class ProductsService {
1919
*/
2020
public productsRead(
2121
id: string,
22-
course?: string,
22+
course: string,
2323
): CancelablePromise<Product> {
2424
return this.httpRequest.request({
2525
method: 'GET',

src/frontend/js/components/PaymentButton/index.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { act, fireEvent, render, screen, waitFor, cleanup } from '@testing-library/react';
1+
simport { act, fireEvent, render, screen, waitFor, cleanup } from '@testing-library/react';
22
import fetchMock from 'fetch-mock';
33
import { PropsWithChildren } from 'react';
44
import { IntlProvider } from 'react-intl';

src/frontend/js/components/PaymentButton/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ const PaymentButton = ({ product, billingAddress, creditCard, onSuccess }: Payme
122122
product: product.id!,
123123
},
124124
{
125-
onSuccess: (order) => {
125+
onSuccess: ({ order, payment_info }) => {
126126
paymentInfos = {
127-
...order.payment_info,
127+
...payment_info,
128128
order_id: order.id,
129129
};
130130
setPayment(paymentInfos);

src/frontend/js/hooks/useOrders.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import { defineMessages } from 'react-intl';
22
import { ApiResourceInterface } from 'types/Joanie';
3-
import { Order, Product, Course, OrderCreateResponse, OrderCreateBody } from 'api/joanie/gen';
3+
import {
4+
Order,
5+
Product,
6+
Course,
7+
OrderCreateResponse,
8+
OrderCreateBody,
9+
OrderAbortBody,
10+
} from 'api/joanie/gen';
411
import { useSessionMutation } from 'utils/react-query/useSessionMutation';
512
import { joanieApi, isCourse } from 'api/joanie';
613
import {
714
QueryOptions,
8-
Resource,
915
ResourcesQuery,
1016
useResource,
1117
useResourcesCustom,
@@ -72,10 +78,14 @@ const props: UseResourcesProps<Order, OrderResourcesQuery, OrderApiResourceInter
7278
session: true,
7379
};
7480

81+
interface OrderAbordData extends OrderAbortBody {
82+
id: string;
83+
}
84+
7585
export const useOrders = (filters?: OrderResourcesQuery, queryOptions?: QueryOptions<Order>) => {
7686
const custom = useResourcesCustom({ ...props, filters, queryOptions });
7787

78-
const abortHandler = useSessionMutation((data: Order) => {
88+
const abortHandler = useSessionMutation((data: OrderAbordData) => {
7989
const { id, ...updatedData } = data;
8090
if (id) {
8191
return joanieApi.orders.ordersAbort(id, updatedData);

0 commit comments

Comments
 (0)