@akinon/pz-checkout-gift-pack 1.51.0 → 1.52.0-rc.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @akinon/pz-checkout-gift-pack
2
2
 
3
+ ## 1.52.0-rc.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 50b90692: ZERO-2767: update plugin readme files
8
+ - 64699d3: ZERO-2761: Fix invalid import for plugin module
9
+ - 69ca0801: ZERO-2780: add modal support for checkout gift pack
10
+
3
11
  ## 1.51.0
4
12
 
5
13
  ## 1.50.0
package/README.md CHANGED
@@ -1,29 +1,30 @@
1
- # pz-checkout-gift-package
1
+ # @akinon/pz-checkout-gift-package
2
2
 
3
3
  ### Install the npm package
4
4
 
5
5
  ```bash
6
6
  # For latest version
7
- yarn add ​git+ssh://git@bitbucket.org:akinonteam/pz-checkout-gift-package.git
7
+ yarn add @akinon/pz-checkout-gift-package
8
8
 
9
- # For specific version
10
- yarn add ​git+ssh://git@bitbucket.org:akinonteam/pz-checkout-gift-package.git#445a9da
11
- ```
12
-
13
- ### Next Config Configuration
14
-
15
- ##### apps/web/next.config.js**
16
-
17
- ```javascript
18
- const withTM = require("next-transpile-modules")(["pz-checkout-gift-package"]);
9
+ # Preferred installation method
10
+ npx @akinon/projectzero@latest --plugins
19
11
  ```
20
12
 
21
13
  ### Example Usage
22
- ##### File Path: src/views/checkout/summary.tsx
23
14
 
15
+ ##### File Path: src/views/checkout/summary.tsx
24
16
 
25
17
  ```javascript
26
18
  import { CheckoutGiftPackage } from 'pz-checkout-gift-package';
27
19
 
28
- <CheckoutGiftPackage />
20
+ <CheckoutGiftPackage />;
29
21
  ```
22
+
23
+ ### Props
24
+
25
+ | Properties | Type | Description |
26
+ | --- | --- | --- |
27
+ | useModal | `boolean` | This prop determines whether the gift pack form will be displayed inside a modal. When set to true, the form will open inside a modal. |
28
+ | modalClassName | `string` | This prop is used to customize the overall style of the modal. |
29
+ | modalTitle | `string` | This prop sets the title of the modal. |
30
+ | modalContentClassName | `string` | This prop is used to customize the style of the modal content. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-checkout-gift-pack",
3
- "version": "1.51.0",
3
+ "version": "1.52.0-rc.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "peerDependencies": {
package/src/index.tsx CHANGED
@@ -1,7 +1,8 @@
1
1
  import { useAppSelector } from '@akinon/next/redux/hooks';
2
2
  import { yupResolver } from '@hookform/resolvers/yup';
3
3
  import clsx from 'clsx';
4
- import { Accordion, Button, Icon } from '@akinon/next/components';
4
+ import { twMerge } from 'tailwind-merge';
5
+ import { Accordion, Button, Icon, Modal } from '@akinon/next/components';
5
6
  import { useEffect, useState } from 'react';
6
7
  import { SubmitHandler, useForm } from 'react-hook-form';
7
8
  import { RootState } from 'redux/store';
@@ -14,6 +15,10 @@ interface GiftPackForm {
14
15
 
15
16
  interface CheckoutGiftPackProps {
16
17
  className?: string;
18
+ useModal?: boolean;
19
+ modalClassName?: string;
20
+ modalTitle?: string;
21
+ modalContentClassName?: string;
17
22
  translations: {
18
23
  addGiftPackText: string;
19
24
  giftPackAdded: string;
@@ -31,6 +36,10 @@ interface CheckoutGiftPackProps {
31
36
 
32
37
  export const CheckoutGiftPack = ({
33
38
  className,
39
+ useModal = false,
40
+ modalClassName,
41
+ modalContentClassName,
42
+ modalTitle = 'Gift Note',
34
43
  translations
35
44
  }: CheckoutGiftPackProps) => {
36
45
  const [isNoteFormOpen, setIsNoteFormOpen] = useState(false);
@@ -102,6 +111,51 @@ export const CheckoutGiftPack = ({
102
111
  resetField('message');
103
112
  };
104
113
 
114
+ const formContent = (
115
+ <form
116
+ className={clsx({
117
+ hidden: !isNoteFormOpen
118
+ })}
119
+ onSubmit={handleSubmit(onSubmit)}
120
+ >
121
+ <textarea
122
+ className={clsx(
123
+ 'w-full border border-solid p-4 placeholder:text-[0.75rem] placeholder:text-[#9c9d9d] outline-none text-[0.75rem]',
124
+ noteLength > 160 ? 'border-[#e85150]' : 'border-[#7b9d75]'
125
+ )}
126
+ rows={4}
127
+ placeholder={_translations.placeholderInput}
128
+ {...register('message')}
129
+ />
130
+ {errors.message && (
131
+ <span className="text-sm text-[#d72a04] text-[0.875rem]">
132
+ {errors.message.message}
133
+ </span>
134
+ )}
135
+ <div className="text-[0.75rem]">
136
+ {noteLength} / 160 {_translations.charactersLength}
137
+ </div>
138
+ <div className="flex justify-end items-end gap-2">
139
+ {giftBox?.note !== DEFAULT_NOTE && (
140
+ <Button
141
+ appearance="ghost"
142
+ className="text-[0.75rem] underline cursor-pointer border-0 px-0 py-0 h-auto hover:bg-transparent hover:text-[#e95151]"
143
+ onClick={removeGiftNote}
144
+ >
145
+ {_translations.removeGiftNoteText}
146
+ </Button>
147
+ )}
148
+ <Button
149
+ type="submit"
150
+ className="w-[7rem] h-[1.75rem] font-[0.75rem] uppercase"
151
+ appearance="outlined"
152
+ >
153
+ {_translations.save}
154
+ </Button>
155
+ </div>
156
+ </form>
157
+ );
158
+
105
159
  useEffect(() => {
106
160
  if (giftBox?.note !== DEFAULT_NOTE) {
107
161
  setValue('message', giftBox?.note);
@@ -166,54 +220,33 @@ export const CheckoutGiftPack = ({
166
220
  </Button>
167
221
  </div>
168
222
  </div>
169
- <form
170
- className={clsx('py-2 px-5', {
171
- hidden: !isNoteFormOpen
172
- })}
173
- onSubmit={handleSubmit(onSubmit)}
174
- >
175
- <Accordion
176
- title={_translations.accordionTitle}
177
- titleClassName="text-[0.75rem]"
178
- isCollapse={true}
179
- >
180
- <textarea
181
- className={clsx(
182
- 'w-full border border-solid p-4 placeholder:text-[0.75rem] placeholder:text-[#9c9d9d] outline-none text-[0.75rem]',
183
- noteLength > 160 ? 'border-[#e85150]' : 'border-[#7b9d75]'
184
- )}
185
- rows={4}
186
- placeholder={_translations.placeholderInput}
187
- {...register('message')}
188
- />
189
- {errors.message && (
190
- <span className="text-sm text-[#d72a04] text-[0.875rem]">
191
- {errors.message.message}
192
- </span>
223
+
224
+ {useModal ? (
225
+ <Modal
226
+ portalId="checkout-gift-pack-modal"
227
+ title={modalTitle}
228
+ className={twMerge(
229
+ 'w-full sm:w-[28rem] max-h-[90vh] overflow-y-auto',
230
+ modalClassName
193
231
  )}
194
- <div className="text-[0.75rem]">
195
- {noteLength} / 160 {_translations.charactersLength}
196
- </div>
197
- <div className="flex justify-end items-end gap-2">
198
- {giftBox?.note !== DEFAULT_NOTE && (
199
- <Button
200
- appearance="ghost"
201
- className="text-[0.75rem] underline cursor-pointer border-0 px-0 py-0 h-auto hover:bg-transparent hover:text-[#e95151]"
202
- onClick={removeGiftNote}
203
- >
204
- {_translations.removeGiftNoteText}
205
- </Button>
206
- )}
207
- <Button
208
- type="submit"
209
- className="w-[7rem] h-[1.75rem] font-[0.75rem] uppercase"
210
- appearance="outlined"
211
- >
212
- {_translations.save}
213
- </Button>
232
+ open={isNoteFormOpen}
233
+ setOpen={setIsNoteFormOpen}
234
+ >
235
+ <div className={twMerge('px-6 py-4', modalContentClassName)}>
236
+ {formContent}
214
237
  </div>
215
- </Accordion>
216
- </form>
238
+ </Modal>
239
+ ) : (
240
+ <div className={clsx('py-2 px-5', { hidden: !isNoteFormOpen })}>
241
+ <Accordion
242
+ title={_translations.accordionTitle}
243
+ titleClassName="text-[0.75rem]"
244
+ isCollapse={true}
245
+ >
246
+ {formContent}
247
+ </Accordion>
248
+ </div>
249
+ )}
217
250
  </div>
218
251
  );
219
252
  };