@akinon/next 1.13.1 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,107 +1,107 @@
1
- import { buildClientRequestUrl } from '../../utils';
2
- import { api } from './api';
3
- import { address, misc } from '../urls';
4
- import { Address, City, Country, District, Township } from '../../types';
5
-
6
- interface GetResponse<T> {
7
- count: number;
8
- next: null;
9
- previous: null;
10
- results: T[];
11
- }
12
-
13
- const addressApi = api.injectEndpoints({
14
- endpoints: (builder) => ({
15
- getAddresses: builder.query<GetResponse<Address>, void>({
16
- query: () => buildClientRequestUrl(address.getAddresses),
17
- providesTags: ['Addresses']
18
- }),
19
- getCountries: builder.query<GetResponse<Country>, void>({
20
- query: () => buildClientRequestUrl(address.countries)
21
- }),
22
- getCities: builder.query<GetResponse<City>, string>({
23
- query: (country) => buildClientRequestUrl(address.getCities(country))
24
- }),
25
- getTownships: builder.query<GetResponse<Township>, string>({
26
- query: (city) => buildClientRequestUrl(address.getTownships(city))
27
- }),
28
- getDistricts: builder.query<GetResponse<District>, string>({
29
- query: (township) => buildClientRequestUrl(address.getDistricts(township))
30
- }),
31
- getRetailStore: builder.query<GetResponse<any>, void>({
32
- query: () => buildClientRequestUrl(address.getRetailStore)
33
- }),
34
- getRetailStoreCities: builder.query<GetResponse<any>, string>({
35
- query: (country) => buildClientRequestUrl(address.getRetailStoreCities(country))
36
- }),
37
- getRetailStoreTownships: builder.query<GetResponse<any>, string>({
38
- query: (city) => buildClientRequestUrl(address.getRetailStoreTownships(city))
39
- }),
40
- addAddress: builder.mutation<Address, Partial<Address>>({
41
- query: (body) => ({
42
- url: buildClientRequestUrl(address.base, {
43
- contentType: 'application/json'
44
- }),
45
- method: 'POST',
46
- body: {
47
- ...body,
48
- type: body.is_corporate === 'true' ? 'corporate' : 'personal'
49
- }
50
- }),
51
- invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
52
- }),
53
- editAddress: builder.mutation<Address, Partial<Address>>({
54
- query: ({ pk, ...body }) => ({
55
- url: buildClientRequestUrl(address.editAddress(pk), {
56
- contentType: 'application/json'
57
- }),
58
- method: 'PATCH',
59
- body: {
60
- ...body,
61
- user: body.user?.pk,
62
- type: body.is_corporate === 'true' ? 'corporate' : 'personal'
63
- }
64
- }),
65
- invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
66
- }),
67
- removeAddress: builder.mutation<void, number>({
68
- query: (id) => ({
69
- url: buildClientRequestUrl(address.removeAddress(id)),
70
- method: 'DELETE'
71
- }),
72
- invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
73
- }),
74
- setDefaultAddress: builder.mutation<Address, Partial<Address>>({
75
- query: ({ pk, primary }) => ({
76
- url: buildClientRequestUrl(address.setDefaultAddress(pk), {
77
- contentType: 'application/json'
78
- }),
79
- method: 'PATCH',
80
- body: { primary }
81
- }),
82
- invalidatesTags: ['Addresses']
83
- }),
84
- getStores: builder.query<GetResponse<Address>, void>({
85
- query: () => ({
86
- url: buildClientRequestUrl(misc.stores)
87
- })
88
- })
89
- }),
90
- overrideExisting: true
91
- });
92
-
93
- export const {
94
- useGetAddressesQuery,
95
- useGetCountriesQuery,
96
- useGetCitiesQuery,
97
- useGetTownshipsQuery,
98
- useGetDistrictsQuery,
99
- useGetRetailStoreQuery,
100
- useGetRetailStoreCitiesQuery,
101
- useGetRetailStoreTownshipsQuery,
102
- useAddAddressMutation,
103
- useEditAddressMutation,
104
- useRemoveAddressMutation,
105
- useSetDefaultAddressMutation,
106
- useGetStoresQuery
107
- } = addressApi;
1
+ import { buildClientRequestUrl } from '../../utils';
2
+ import { api } from './api';
3
+ import { address, misc } from '../urls';
4
+ import { Address, City, Country, District, Township } from '../../types';
5
+
6
+ interface GetResponse<T> {
7
+ count: number;
8
+ next: null;
9
+ previous: null;
10
+ results: T[];
11
+ }
12
+
13
+ const addressApi = api.injectEndpoints({
14
+ endpoints: (builder) => ({
15
+ getAddresses: builder.query<GetResponse<Address>, void>({
16
+ query: () => buildClientRequestUrl(address.getAddresses),
17
+ providesTags: ['Addresses']
18
+ }),
19
+ getCountries: builder.query<GetResponse<Country>, void>({
20
+ query: () => buildClientRequestUrl(address.countries)
21
+ }),
22
+ getCities: builder.query<GetResponse<City>, string>({
23
+ query: (country) => buildClientRequestUrl(address.getCities(country))
24
+ }),
25
+ getTownships: builder.query<GetResponse<Township>, string>({
26
+ query: (city) => buildClientRequestUrl(address.getTownships(city))
27
+ }),
28
+ getDistricts: builder.query<GetResponse<District>, string>({
29
+ query: (township) => buildClientRequestUrl(address.getDistricts(township))
30
+ }),
31
+ getRetailStore: builder.query<GetResponse<any>, void>({
32
+ query: () => buildClientRequestUrl(address.getRetailStore)
33
+ }),
34
+ getRetailStoreCities: builder.query<GetResponse<any>, string>({
35
+ query: (country) => buildClientRequestUrl(address.getRetailStoreCities(country))
36
+ }),
37
+ getRetailStoreTownships: builder.query<GetResponse<any>, string>({
38
+ query: (city) => buildClientRequestUrl(address.getRetailStoreTownships(city))
39
+ }),
40
+ addAddress: builder.mutation<Address, Partial<Address>>({
41
+ query: (body) => ({
42
+ url: buildClientRequestUrl(address.base, {
43
+ contentType: 'application/json'
44
+ }),
45
+ method: 'POST',
46
+ body: {
47
+ ...body,
48
+ type: body.is_corporate === 'true' ? 'corporate' : 'personal'
49
+ }
50
+ }),
51
+ invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
52
+ }),
53
+ editAddress: builder.mutation<Address, Partial<Address>>({
54
+ query: ({ pk, ...body }) => ({
55
+ url: buildClientRequestUrl(address.editAddress(pk), {
56
+ contentType: 'application/json'
57
+ }),
58
+ method: 'PATCH',
59
+ body: {
60
+ ...body,
61
+ user: body.user?.pk,
62
+ type: body.is_corporate === 'true' ? 'corporate' : 'personal'
63
+ }
64
+ }),
65
+ invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
66
+ }),
67
+ removeAddress: builder.mutation<void, number>({
68
+ query: (id) => ({
69
+ url: buildClientRequestUrl(address.removeAddress(id)),
70
+ method: 'DELETE'
71
+ }),
72
+ invalidatesTags: ['Addresses', 'Checkout'] // TODO: Invalidate one of these tags when necessary (e.g. Address page invalidates Addresses tag, Checkout page invalidates Checkout tag)
73
+ }),
74
+ setDefaultAddress: builder.mutation<Address, Partial<Address>>({
75
+ query: ({ pk, primary }) => ({
76
+ url: buildClientRequestUrl(address.setDefaultAddress(pk), {
77
+ contentType: 'application/json'
78
+ }),
79
+ method: 'PATCH',
80
+ body: { primary }
81
+ }),
82
+ invalidatesTags: ['Addresses']
83
+ }),
84
+ getStores: builder.query<GetResponse<Address>, void>({
85
+ query: () => ({
86
+ url: buildClientRequestUrl(misc.stores)
87
+ })
88
+ })
89
+ }),
90
+ overrideExisting: true
91
+ });
92
+
93
+ export const {
94
+ useGetAddressesQuery,
95
+ useGetCountriesQuery,
96
+ useGetCitiesQuery,
97
+ useGetTownshipsQuery,
98
+ useGetDistrictsQuery,
99
+ useGetRetailStoreQuery,
100
+ useGetRetailStoreCitiesQuery,
101
+ useGetRetailStoreTownshipsQuery,
102
+ useAddAddressMutation,
103
+ useEditAddressMutation,
104
+ useRemoveAddressMutation,
105
+ useSetDefaultAddressMutation,
106
+ useGetStoresQuery
107
+ } = addressApi;
@@ -74,7 +74,8 @@ export const api = createApi({
74
74
  'Checkout',
75
75
  'Favorite',
76
76
  'Addresses',
77
- 'Profile'
77
+ 'Profile',
78
+ 'StockAlert'
78
79
  ],
79
80
  endpoints: () => ({})
80
81
  });
@@ -1,106 +1,106 @@
1
- import { buildClientRequestUrl } from '../../utils';
2
- import { api } from './api';
3
- import { b2b } from '../urls';
4
- import {
5
- Basket,
6
- BasketParams,
7
- BasketResponse,
8
- Division,
9
- DraftResponse,
10
- GetResponse,
11
- LoadBasketParams,
12
- SaveBasketParams,
13
- UpdateProductParams,
14
- DeleteProductParams,
15
- CreateQuotationParams
16
- } from '../../types';
17
-
18
- const b2bApi = api.injectEndpoints({
19
- endpoints: (build) => ({
20
- getBasketB2b: build.query<BasketResponse, void>({
21
- query: () =>
22
- buildClientRequestUrl(b2b.basket, {
23
- contentType: 'application/json'
24
- }),
25
- providesTags: ['BasketB2b']
26
- }),
27
- getDivisions: build.query<GetResponse<Division>, void>({
28
- query: () => buildClientRequestUrl(b2b.divisions)
29
- }),
30
- addToBasket: build.mutation<BasketResponse, BasketParams>({
31
- query: (body) => ({
32
- url: buildClientRequestUrl(b2b.basket, {
33
- contentType: 'application/json'
34
- }),
35
- method: 'POST',
36
- body
37
- })
38
- }),
39
- saveBasket: build.mutation<BasketResponse, SaveBasketParams>({
40
- query: (body) => ({
41
- url: buildClientRequestUrl(b2b.saveBasket, {
42
- contentType: 'application/json'
43
- }),
44
- method: 'POST',
45
- body
46
- }),
47
- invalidatesTags: ['BasketB2b', 'DraftsB2b']
48
- }),
49
- getDrafts: build.query<DraftResponse[], void>({
50
- query: () => buildClientRequestUrl(b2b.draftBaskets),
51
- providesTags: ['DraftsB2b']
52
- }),
53
- loadBasket: build.mutation<string, number>({
54
- query: (id) => ({
55
- url: buildClientRequestUrl(b2b.loadBasket(id), {
56
- contentType: 'application/json'
57
- }),
58
- method: 'POST'
59
- }),
60
- invalidatesTags: ['BasketB2b']
61
- }),
62
- updateProduct: build.mutation<Basket, UpdateProductParams>({
63
- query: (body) => ({
64
- url: buildClientRequestUrl(b2b.basket, {
65
- contentType: 'application/json'
66
- }),
67
- method: 'PUT',
68
- body
69
- }),
70
- invalidatesTags: ['BasketB2b']
71
- }),
72
- deleteProduct: build.mutation<Basket, DeleteProductParams>({
73
- query: (body) => ({
74
- url: buildClientRequestUrl(b2b.basket, {
75
- contentType: 'application/json'
76
- }),
77
- method: 'DELETE',
78
- body
79
- }),
80
- invalidatesTags: ['BasketB2b']
81
- }),
82
- createQuotation: build.mutation<BasketResponse, CreateQuotationParams>({
83
- query: (body) => ({
84
- url: buildClientRequestUrl(b2b.myQuotations, {
85
- contentType: 'application/json'
86
- }),
87
- method: 'POST',
88
- body
89
- }),
90
- invalidatesTags: ['BasketB2b', 'DraftsB2b']
91
- }),
92
- }),
93
- overrideExisting: true
94
- });
95
-
96
- export const {
97
- useGetBasketB2bQuery,
98
- useLazyGetDivisionsQuery,
99
- useAddToBasketMutation,
100
- useSaveBasketMutation,
101
- useGetDraftsQuery,
102
- useLoadBasketMutation,
103
- useUpdateProductMutation,
104
- useDeleteProductMutation,
105
- useCreateQuotationMutation
106
- } = b2bApi;
1
+ import { buildClientRequestUrl } from '../../utils';
2
+ import { api } from './api';
3
+ import { b2b } from '../urls';
4
+ import {
5
+ Basket,
6
+ BasketParams,
7
+ BasketResponse,
8
+ Division,
9
+ DraftResponse,
10
+ GetResponse,
11
+ LoadBasketParams,
12
+ SaveBasketParams,
13
+ UpdateProductParams,
14
+ DeleteProductParams,
15
+ CreateQuotationParams
16
+ } from '../../types';
17
+
18
+ const b2bApi = api.injectEndpoints({
19
+ endpoints: (build) => ({
20
+ getBasketB2b: build.query<BasketResponse, void>({
21
+ query: () =>
22
+ buildClientRequestUrl(b2b.basket, {
23
+ contentType: 'application/json'
24
+ }),
25
+ providesTags: ['BasketB2b']
26
+ }),
27
+ getDivisions: build.query<GetResponse<Division>, void>({
28
+ query: () => buildClientRequestUrl(b2b.divisions)
29
+ }),
30
+ addToBasket: build.mutation<BasketResponse, BasketParams>({
31
+ query: (body) => ({
32
+ url: buildClientRequestUrl(b2b.basket, {
33
+ contentType: 'application/json'
34
+ }),
35
+ method: 'POST',
36
+ body
37
+ })
38
+ }),
39
+ saveBasket: build.mutation<BasketResponse, SaveBasketParams>({
40
+ query: (body) => ({
41
+ url: buildClientRequestUrl(b2b.saveBasket, {
42
+ contentType: 'application/json'
43
+ }),
44
+ method: 'POST',
45
+ body
46
+ }),
47
+ invalidatesTags: ['BasketB2b', 'DraftsB2b']
48
+ }),
49
+ getDrafts: build.query<DraftResponse[], void>({
50
+ query: () => buildClientRequestUrl(b2b.draftBaskets),
51
+ providesTags: ['DraftsB2b']
52
+ }),
53
+ loadBasket: build.mutation<string, number>({
54
+ query: (id) => ({
55
+ url: buildClientRequestUrl(b2b.loadBasket(id), {
56
+ contentType: 'application/json'
57
+ }),
58
+ method: 'POST'
59
+ }),
60
+ invalidatesTags: ['BasketB2b']
61
+ }),
62
+ updateProduct: build.mutation<Basket, UpdateProductParams>({
63
+ query: (body) => ({
64
+ url: buildClientRequestUrl(b2b.basket, {
65
+ contentType: 'application/json'
66
+ }),
67
+ method: 'PUT',
68
+ body
69
+ }),
70
+ invalidatesTags: ['BasketB2b']
71
+ }),
72
+ deleteProduct: build.mutation<Basket, DeleteProductParams>({
73
+ query: (body) => ({
74
+ url: buildClientRequestUrl(b2b.basket, {
75
+ contentType: 'application/json'
76
+ }),
77
+ method: 'DELETE',
78
+ body
79
+ }),
80
+ invalidatesTags: ['BasketB2b']
81
+ }),
82
+ createQuotation: build.mutation<BasketResponse, CreateQuotationParams>({
83
+ query: (body) => ({
84
+ url: buildClientRequestUrl(b2b.myQuotations, {
85
+ contentType: 'application/json'
86
+ }),
87
+ method: 'POST',
88
+ body
89
+ }),
90
+ invalidatesTags: ['BasketB2b', 'DraftsB2b']
91
+ }),
92
+ }),
93
+ overrideExisting: true
94
+ });
95
+
96
+ export const {
97
+ useGetBasketB2bQuery,
98
+ useLazyGetDivisionsQuery,
99
+ useAddToBasketMutation,
100
+ useSaveBasketMutation,
101
+ useGetDraftsQuery,
102
+ useLoadBasketMutation,
103
+ useUpdateProductMutation,
104
+ useDeleteProductMutation,
105
+ useCreateQuotationMutation
106
+ } = b2bApi;