@akinon/next 1.0.0

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.
Files changed (98) hide show
  1. package/.prettierrc +13 -0
  2. package/api/auth.ts +217 -0
  3. package/api/cache.ts +44 -0
  4. package/api/client.ts +157 -0
  5. package/api/logout.ts +42 -0
  6. package/assets/styles/index.scss +24 -0
  7. package/bin/pz-install-plugins.js +33 -0
  8. package/components/client-root.tsx +69 -0
  9. package/components/image.tsx +133 -0
  10. package/components/mobile-app-toggler.tsx +15 -0
  11. package/components/oauth-login.tsx +24 -0
  12. package/components/plugin-module.tsx +78 -0
  13. package/components/pz-providers.tsx +24 -0
  14. package/components/pz-root.tsx +21 -0
  15. package/components/redirect-three-d/content/index.tsx +64 -0
  16. package/components/redirect-three-d/index.tsx +17 -0
  17. package/components/selected-payment-option-view.tsx +66 -0
  18. package/components/trans.tsx +39 -0
  19. package/data/client/account.ts +188 -0
  20. package/data/client/address.ts +107 -0
  21. package/data/client/api.ts +42 -0
  22. package/data/client/basket.ts +85 -0
  23. package/data/client/checkout.ts +477 -0
  24. package/data/client/misc.ts +101 -0
  25. package/data/client/product.ts +90 -0
  26. package/data/client/user.ts +83 -0
  27. package/data/client/wishlist.ts +79 -0
  28. package/data/server/category.ts +121 -0
  29. package/data/server/flatpage.ts +21 -0
  30. package/data/server/index.ts +8 -0
  31. package/data/server/list.ts +56 -0
  32. package/data/server/menu.ts +35 -0
  33. package/data/server/product.ts +86 -0
  34. package/data/server/seo.ts +48 -0
  35. package/data/server/special-page.ts +42 -0
  36. package/data/server/widget.ts +27 -0
  37. package/data/urls.ts +184 -0
  38. package/hocs/client/index.ts +1 -0
  39. package/hocs/client/with-segment-defaults.tsx +26 -0
  40. package/hocs/server/index.ts +1 -0
  41. package/hocs/server/with-segment-defaults.tsx +83 -0
  42. package/hooks/index.ts +8 -0
  43. package/hooks/use-captcha.tsx +76 -0
  44. package/hooks/use-common-product-attributes.ts +36 -0
  45. package/hooks/use-debounce.ts +20 -0
  46. package/hooks/use-localization.ts +63 -0
  47. package/hooks/use-media-query.ts +36 -0
  48. package/hooks/use-on-click-outside.tsx +28 -0
  49. package/hooks/use-router.ts +45 -0
  50. package/hooks/use-translation.ts +14 -0
  51. package/lib/cache.ts +185 -0
  52. package/localization/index.ts +5 -0
  53. package/localization/provider.tsx +58 -0
  54. package/middlewares/currency.ts +55 -0
  55. package/middlewares/default.ts +224 -0
  56. package/middlewares/index.ts +29 -0
  57. package/middlewares/locale.ts +61 -0
  58. package/middlewares/oauth-login.ts +78 -0
  59. package/middlewares/pretty-url.ts +94 -0
  60. package/middlewares/redirection-payment.ts +117 -0
  61. package/middlewares/three-d-redirection.ts +122 -0
  62. package/middlewares/url-redirection.ts +61 -0
  63. package/package.json +20 -0
  64. package/plugins.js +7 -0
  65. package/redux/hooks.ts +7 -0
  66. package/redux/middlewares/checkout.ts +231 -0
  67. package/redux/middlewares/index.ts +50 -0
  68. package/redux/reducers/checkout.ts +164 -0
  69. package/redux/reducers/config.ts +28 -0
  70. package/redux/reducers/header.ts +59 -0
  71. package/redux/reducers/index.ts +15 -0
  72. package/redux/reducers/root.ts +61 -0
  73. package/tailwind/rtl.js +137 -0
  74. package/types/commerce/account.ts +68 -0
  75. package/types/commerce/address.ts +94 -0
  76. package/types/commerce/basket.ts +43 -0
  77. package/types/commerce/category.ts +114 -0
  78. package/types/commerce/checkout.ts +132 -0
  79. package/types/commerce/flatpage.ts +7 -0
  80. package/types/commerce/index.ts +10 -0
  81. package/types/commerce/misc.ts +127 -0
  82. package/types/commerce/order.ts +108 -0
  83. package/types/commerce/product.ts +110 -0
  84. package/types/commerce/widget.ts +28 -0
  85. package/types/gtm.ts +16 -0
  86. package/types/index.ts +207 -0
  87. package/types/next-auth.d.ts +24 -0
  88. package/utils/app-fetch.ts +62 -0
  89. package/utils/generate-commerce-search-params.ts +22 -0
  90. package/utils/get-currency.ts +29 -0
  91. package/utils/image-loader.ts +31 -0
  92. package/utils/index.ts +132 -0
  93. package/utils/localization.ts +29 -0
  94. package/utils/log.ts +138 -0
  95. package/utils/menu-generator.ts +27 -0
  96. package/utils/mobile-3d-iframe.ts +58 -0
  97. package/utils/server-translation.ts +57 -0
  98. package/utils/server-variables.ts +9 -0
@@ -0,0 +1,137 @@
1
+ const plugin = require('tailwindcss/plugin');
2
+
3
+ module.exports = plugin(({ addUtilities, matchUtilities, theme, e }) => {
4
+ const spacingUtilities = Object.entries(theme('spacing')).map(
5
+ ([key, value]) => {
6
+ return {
7
+ [`[dir="rtl"] .${e(`pl-${key}`)}`]: {
8
+ 'padding-right': `${value}`
9
+ },
10
+ [`[dir="rtl"] .${e(`pr-${key}`)}`]: {
11
+ 'padding-left': `${value}`
12
+ },
13
+ [`[dir="rtl"] .${e(`ml-${key}`)}`]: {
14
+ 'margin-right': `${value}`
15
+ },
16
+ [`[dir="rtl"] .${e(`mr-${key}`)}`]: {
17
+ 'margin-left': `${value}`
18
+ },
19
+ [`[dir="rtl"] .${e(`pl-${key}`)}:not([class*="px-"])`]: {
20
+ 'padding-left': '0'
21
+ },
22
+ [`[dir="rtl"] .${e(`pr-${key}`)}:not([class*="px-"])`]: {
23
+ 'padding-right': '0'
24
+ },
25
+ [`[dir="rtl"] .${e(`ml-${key}`)}:not([class*="mx-"])`]: {
26
+ 'margin-left': '0'
27
+ },
28
+ [`[dir="rtl"] .${e(`mr-${key}`)}:not([class*="mx-"])`]: {
29
+ 'margin-right': '0'
30
+ },
31
+ [`[dir="rtl"] .${e(
32
+ `space-x-${key}`
33
+ )} > :not([hidden]) ~ :not([hidden])`]: {
34
+ '--tw-space-x-reverse': '0',
35
+ 'margin-right':
36
+ 'calc(' + `${value}` + ' * calc(1 - var(--tw-space-x-reverse)))',
37
+ 'margin-left': 'calc(' + `${value}` + ' * var(--tw-space-x-reverse))'
38
+ }
39
+ };
40
+ }
41
+ );
42
+
43
+ addUtilities(spacingUtilities);
44
+
45
+ const borderUtilities = Object.entries(theme('borderWidth')).map(
46
+ ([key, value]) => {
47
+ return {
48
+ [`[dir="rtl"] .${e(`border-l-${key}`)}`]: {
49
+ 'border-right-width': `${value}`,
50
+ 'border-left-width': '0'
51
+ }
52
+ };
53
+ }
54
+ );
55
+
56
+ addUtilities({
57
+ [`[dir="rtl"] .${e(`border`)}`]: {
58
+ 'border-right-width': '1px',
59
+ 'border-left-width': '1px'
60
+ },
61
+ [`[dir="rtl"] .${e(`border-l`)}`]: {
62
+ 'border-right-width': '1px',
63
+ 'border-left-width': '0'
64
+ },
65
+ [`[dir="rtl"] .${e(`border-r`)}`]: {
66
+ 'border-left-width': '1px',
67
+ 'border-right-width': '0'
68
+ },
69
+ ...borderUtilities
70
+ });
71
+
72
+ const insetUtilities = Object.entries(theme('inset')).map(([key, value]) => {
73
+ return {
74
+ [`[dir="rtl"] .${e(`left-${key}`)}`]: {
75
+ right: `${value}`
76
+ },
77
+ [`[dir="rtl"] .${e(`right-${key}`)}`]: {
78
+ left: `${value}`
79
+ },
80
+ [`[dir="rtl"] .${e(`left-${key}`)}:not([class*="right-"])`]: {
81
+ left: 'initial'
82
+ },
83
+ [`[dir="rtl"] .${e(`right-${key}`)}:not([class*="left-"])`]: {
84
+ right: 'initial'
85
+ }
86
+ };
87
+ });
88
+
89
+ addUtilities(insetUtilities);
90
+
91
+ const transformUtilities = Object.entries(theme('translate')).map(
92
+ ([key, value]) => {
93
+ let val = value;
94
+ let negativeVal = value;
95
+
96
+ if (value.startsWith('-')) {
97
+ val = value.slice(1);
98
+ } else {
99
+ negativeVal = '-'.concat('', value);
100
+ }
101
+
102
+ return {
103
+ [`[dir="rtl"] .${e(`-translate-x-${key}`)}`]: {
104
+ '--tw-translate-x': `${val}`
105
+ },
106
+ [`[dir="rtl"] .${e(`translate-x-${key}`)}`]: {
107
+ '--tw-translate-x': `${negativeVal}`
108
+ }
109
+ };
110
+ }
111
+ );
112
+
113
+ addUtilities(transformUtilities);
114
+
115
+ const divideUtilities = Object.entries(theme('divideWidth')).map(
116
+ ([key, value]) => {
117
+ return {
118
+ [`[dir="rtl"] .${e(
119
+ `divide-x-${key}`
120
+ )} > :not([hidden]) ~ :not([hidden])`]: {
121
+ '--tw-divide-x-reverse': '0',
122
+ 'border-right-width': `calc(${value} * calc(1 - var(--tw-divide-x-reverse)))`,
123
+ 'border-left-width': `calc(${value} * var(--tw-divide-x-reverse))`
124
+ }
125
+ };
126
+ }
127
+ );
128
+
129
+ addUtilities({
130
+ [`[dir="rtl"] .${e(`divide-x`)} > :not([hidden]) ~ :not([hidden])`]: {
131
+ '--tw-divide-x-reverse': '0',
132
+ 'border-right-width': 'calc(1px * calc(1 - var(--tw-divide-x-reverse)))',
133
+ 'border-left-width': 'calc(1px * var(--tw-divide-x-reverse))'
134
+ },
135
+ ...divideUtilities
136
+ });
137
+ });
@@ -0,0 +1,68 @@
1
+ export type AccountCancellationReason = {
2
+ id: number;
3
+ uuid: string;
4
+ cancellation_type: string;
5
+ created_date: string;
6
+ extra_information_needed: boolean;
7
+ is_active: boolean;
8
+ modified_date: string;
9
+ order: number;
10
+ subject: string;
11
+ translations: object;
12
+ };
13
+
14
+ export type AccountOrderCancellation = {
15
+ return_policy: boolean;
16
+ id: string;
17
+ cancel_order_items: Array<{
18
+ cancellation_type: string;
19
+ description: string;
20
+ order_item: string;
21
+ reason: string;
22
+ }>;
23
+ };
24
+
25
+ export type AccountOrderCancellationReason = {
26
+ count: number;
27
+ next: string;
28
+ previous: null | string;
29
+ results: AccountCancellationReason[];
30
+ };
31
+
32
+ export type AccountChangeEmailFormType = {
33
+ email: string;
34
+ emailConfirm: string;
35
+ password: string;
36
+ };
37
+
38
+ export type AccountChangePasswordFormType = {
39
+ old_password: string;
40
+ new_password1: string;
41
+ new_password2: string;
42
+ };
43
+
44
+ export type AccountProfileFormType = {
45
+ first_name: string;
46
+ last_name: string;
47
+ phone: string;
48
+ email_allowed: boolean;
49
+ sms_allowed: boolean;
50
+ gender: string;
51
+ email: string;
52
+ birthdate_day: string;
53
+ birthdate_month: string;
54
+ birthdate_year: string;
55
+ country_code: string;
56
+ date_of_birth: string;
57
+ };
58
+
59
+ export type ContactFormType = {
60
+ full_name: string;
61
+ email: string;
62
+ phone: string;
63
+ subject: string;
64
+ message: string;
65
+ order?: string;
66
+ country_code?: string;
67
+ order_needed?: boolean;
68
+ };
@@ -0,0 +1,94 @@
1
+ export enum AddressType {
2
+ individual = 'false',
3
+ company = 'true'
4
+ }
5
+
6
+ export type AddressFormType = {
7
+ type: string;
8
+ is_corporate: AddressType;
9
+ title: string;
10
+ first_name: string;
11
+ last_name: string;
12
+ phone_number: string;
13
+ country: string;
14
+ city: string;
15
+ township: string;
16
+ district: string;
17
+ line: string;
18
+ postcode: string;
19
+ company_name?: string;
20
+ tax_no?: number;
21
+ tax_office?: string;
22
+ e_bill_taxpayer?: boolean;
23
+ country_code?: string;
24
+ };
25
+
26
+ export type Country = {
27
+ code: string;
28
+ is_active: boolean;
29
+ name: string;
30
+ pk: number;
31
+ translations: string | null;
32
+ };
33
+
34
+ export type City = {
35
+ country: Country;
36
+ is_active: boolean;
37
+ name: string;
38
+ pk: number;
39
+ postcode: number;
40
+ priority: null;
41
+ translations: string | null;
42
+ };
43
+
44
+ export type Township = {
45
+ city: City;
46
+ is_active: boolean;
47
+ name: string;
48
+ pk: number;
49
+ postcode: number;
50
+ };
51
+
52
+ export type District = {
53
+ city: number;
54
+ is_active: boolean;
55
+ name: string;
56
+ pk: number;
57
+ postcode: number;
58
+ township: number;
59
+ };
60
+
61
+ export interface Address {
62
+ address_type: string;
63
+ city: City;
64
+ company_name: string;
65
+ country: Country;
66
+ district: District;
67
+ e_bill_taxpayer: boolean;
68
+ email: string;
69
+ extra_field: null;
70
+ first_name: string;
71
+ hash_data: string;
72
+ identity_number: number | null;
73
+ is_corporate: 'true' | 'false';
74
+ last_name: string;
75
+ line: string;
76
+ notes: string | null;
77
+ phone_number: string;
78
+ pk: number;
79
+ postcode: string;
80
+ primary: boolean;
81
+ remote_id: null;
82
+ retail_store: null;
83
+ tax_no: string;
84
+ tax_office: string;
85
+ title: string;
86
+ township: Township;
87
+ user: { pk: number };
88
+ latitude: string;
89
+ longitude: string;
90
+ name: string;
91
+ address: string;
92
+ fax_phone_number: string;
93
+ image: string;
94
+ }
@@ -0,0 +1,43 @@
1
+ import { Discount, UpsellDetail } from './misc';
2
+ import { Product } from './product';
3
+
4
+ export interface Basket {
5
+ segment: { pk: number; price_list: number; stock_list: number };
6
+ unavailable_basket_products: any[];
7
+ upsell_details: UpsellDetail[];
8
+ voucher_code: string | null;
9
+ total_amount: string;
10
+ total_quantity: number;
11
+ basketitem_set: BasketItem[];
12
+ created_date: string;
13
+ discounts: Discount[];
14
+ modified_date: string;
15
+ pk: number;
16
+ total_discount_amount: string;
17
+ total_product_amount: string;
18
+ upsell_messages: any[];
19
+ }
20
+
21
+ export interface BasketItem {
22
+ attributes: object;
23
+ attributes_kwargs: object;
24
+ discount_amount: string;
25
+ offer_badges: {
26
+ description: string;
27
+ discount: string;
28
+ }[];
29
+ parent: any | null;
30
+ price: string;
31
+ retail_price: string;
32
+ stock: number;
33
+ id: number;
34
+ quantity: number;
35
+ product: Product;
36
+ currency_type: string;
37
+ currency_type_label: string;
38
+ image: string;
39
+ shipping_discount: string;
40
+ tax_rate: string;
41
+ total_amount: string;
42
+ unit_price: string;
43
+ }
@@ -0,0 +1,114 @@
1
+ import { Pagination } from './misc';
2
+ import { Product } from './product';
3
+
4
+ export type SortOption = {
5
+ is_selected: boolean;
6
+ label: string;
7
+ value: string;
8
+ };
9
+
10
+ export interface Category {
11
+ pk: number;
12
+ name: string;
13
+ menuitemmodel: string;
14
+ absolute_url: string;
15
+ sort_option: number;
16
+ uuid: string;
17
+ depth: number;
18
+ attributes: {
19
+ category_seo_title?: {
20
+ value: {
21
+ page_break_desc: null | string;
22
+ text: null | string;
23
+ };
24
+ kwargs: {
25
+ value: object;
26
+ data_type: 'nested';
27
+ };
28
+ };
29
+ [key: string]: any;
30
+ };
31
+ }
32
+
33
+ export type FacetChoice = {
34
+ label: string;
35
+ value: string | number;
36
+ quantity: number;
37
+ is_selected: boolean;
38
+ url?: string;
39
+ [key: string]: any;
40
+ };
41
+
42
+ export type Facet = {
43
+ data: {
44
+ choices: Array<FacetChoice>;
45
+ key: string;
46
+ name: string;
47
+ order: number;
48
+ search_key: string;
49
+ widget_type: string;
50
+ };
51
+ extra_params: any;
52
+ key: string;
53
+ name: string;
54
+ order: number | null;
55
+ search_key: string;
56
+ widget_type: 'category' | 'multiselect';
57
+ };
58
+
59
+ export interface SpecialPageType {
60
+ banner: string;
61
+ banner_mobile: string;
62
+ banner_description: string;
63
+ video_embedded_code: string;
64
+ banner_url: string;
65
+ name: string;
66
+ pretty_url: {
67
+ pk: number;
68
+ new_path: string;
69
+ old_path: string;
70
+ parent: string | null;
71
+ language: string;
72
+ func_module: string;
73
+ func_name: string;
74
+ func_initkwargs: any;
75
+ args: any[];
76
+ kwargs: {
77
+ [key: string]: any;
78
+ };
79
+ query_params: any;
80
+ viewname: string;
81
+ created_date: string;
82
+ modified_date: string;
83
+ prettyurl_set: any[];
84
+ };
85
+ [key: string]: any;
86
+ }
87
+
88
+ export interface GetCategoryResponse {
89
+ category: Category;
90
+ facets: Facet[];
91
+ pagination: Pagination;
92
+ products: Product[];
93
+ search_text: string | null;
94
+ sorters: SortOption[];
95
+ special_page: SpecialPageType;
96
+ }
97
+
98
+ export type BreadcrumbResultType = {
99
+ label: string;
100
+ url: string;
101
+ level: number;
102
+ pk: string;
103
+ sort_order: number;
104
+ path: string;
105
+ parent_pk: null | string;
106
+ parent: null | BreadcrumbResultType;
107
+ generator_name: string;
108
+ extra_context: {
109
+ attributes: {
110
+ category_id: number;
111
+ };
112
+ numchild: number;
113
+ };
114
+ };
@@ -0,0 +1,132 @@
1
+ import { Address } from './address';
2
+ import { Basket } from './basket';
3
+ import { RetailStore } from './misc';
4
+ import { PaymentOption } from './order';
5
+
6
+ export enum CheckoutStep {
7
+ Shipping = 'shipping',
8
+ Payment = 'payment',
9
+ Confirmation = 'confirmation'
10
+ }
11
+
12
+ export interface CreditCardType {
13
+ logo: string;
14
+ name: string;
15
+ slug: string;
16
+ }
17
+
18
+ export interface DeliveryOption {
19
+ delivery_option_type: string;
20
+ name: string;
21
+ pk: number;
22
+ slug: string;
23
+ sort_order: number;
24
+ }
25
+
26
+ export interface ShippingOption {
27
+ description: string;
28
+ kwargs: any;
29
+ logo: null;
30
+ name: string;
31
+ pk: number;
32
+ shipping_amount: string;
33
+ slug: string;
34
+ }
35
+
36
+ export interface CheckoutAddressType {
37
+ label: string;
38
+ text: string;
39
+ value: number;
40
+ requestParam: string;
41
+ }
42
+
43
+ export interface CheckoutPaymentOption {
44
+ pk: number;
45
+ view?: (...args) => JSX.Element;
46
+ viewProps?: any;
47
+ }
48
+
49
+ export interface GiftBox {
50
+ note: string;
51
+ gift_video: boolean;
52
+ gift_video_notification_sent: boolean;
53
+ price: string;
54
+ }
55
+
56
+ export interface PreOrder {
57
+ basket?: Basket;
58
+ payment_option?: PaymentOption;
59
+ payment_choice?: PaymentChoice;
60
+ delivery_option?: DeliveryOption;
61
+ shipping_address?: Address;
62
+ billing_address?: Address;
63
+ billing_and_shipping_same?: boolean;
64
+ shipping_option?: ShippingOption;
65
+ shipping_amount?: string;
66
+ total_amount?: string;
67
+ total_amount_with_interest?: string;
68
+ unpaid_amount?: string;
69
+ user_phone_number?: string;
70
+ loyalty_money?: string;
71
+ currency_type_label?: string;
72
+ is_guest?: boolean;
73
+ is_post_order?: boolean;
74
+ installment: InstallmentOption;
75
+ retail_store?: RetailStore;
76
+ gift_box?: GiftBox;
77
+ }
78
+
79
+ export interface GuestLoginFormParams {
80
+ user_email: string;
81
+ phone_number: string;
82
+ sms_allowed: boolean;
83
+ kvkk_confirm: boolean;
84
+ }
85
+
86
+ export interface PaymentChoice {
87
+ label: string;
88
+ price: string;
89
+ value: string;
90
+ }
91
+
92
+ export interface CheckoutContext {
93
+ page_name: string;
94
+ page_slug: string;
95
+ page_context: {
96
+ has_gift_box?: boolean;
97
+ can_guest_purchase?: boolean;
98
+ delivery_options?: DeliveryOption[];
99
+ addresses?: Address[];
100
+ shipping_options?: ShippingOption[];
101
+ payment_options?: PaymentOption[];
102
+ payment_choices?: PaymentChoice[];
103
+ card_type: CreditCardType;
104
+ installments?: InstallmentOption[];
105
+ bank_accounts?: BankAccount[];
106
+ redirect_url?: string;
107
+ context_data?: any;
108
+ balance?: string;
109
+ };
110
+ }
111
+
112
+ export interface InstallmentOption {
113
+ installment_count: number;
114
+ label: string;
115
+ monthly_price_with_accrued_interest: string;
116
+ pk: number;
117
+ price_with_accrued_interest: string;
118
+ }
119
+
120
+ export interface BankAccount {
121
+ bank: {
122
+ logo: string;
123
+ name: string;
124
+ pk: number;
125
+ slug: string;
126
+ };
127
+ description: string;
128
+ holder_name: string;
129
+ iban: string;
130
+ pk: number;
131
+ sort_order: number;
132
+ }
@@ -0,0 +1,7 @@
1
+ export interface FlatPage {
2
+ flat_page: {
3
+ url: string;
4
+ title: string;
5
+ content: string;
6
+ };
7
+ }
@@ -0,0 +1,10 @@
1
+ export * from './account';
2
+ export * from './address';
3
+ export * from './basket';
4
+ export * from './category';
5
+ export * from './checkout';
6
+ export * from './misc';
7
+ export * from './product';
8
+ export * from './widget';
9
+ export * from './flatpage';
10
+ export * from './order';