richie-education 3.3.2-dev16 → 3.3.2-dev25
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.
- package/.eslintrc.json +0 -3
- package/.storybook/preview.tsx +49 -24
- package/cunningham.cjs +1 -0
- package/i18n/compile-translations.js +12 -10
- package/i18n/locales/ar-SA.json +20 -0
- package/i18n/locales/es-ES.json +20 -0
- package/i18n/locales/fa-IR.json +20 -0
- package/i18n/locales/fr-CA.json +20 -0
- package/i18n/locales/fr-FR.json +21 -1
- package/i18n/locales/ko-KR.json +20 -0
- package/i18n/locales/pt-PT.json +42 -22
- package/i18n/locales/ru-RU.json +20 -0
- package/i18n/locales/vi-VN.json +20 -0
- package/jest.config.js +5 -0
- package/js/components/AddressesManagement/AddressForm/index.stories.tsx +1 -1
- package/js/components/AddressesManagement/AddressForm/index.tsx +4 -3
- package/js/components/AddressesManagement/index.stories.tsx +1 -1
- package/js/components/AddressesManagement/index.tsx +5 -3
- package/js/components/Badge/index.stories.tsx +1 -1
- package/js/components/Badge/index.tsx +1 -1
- package/js/components/Banner/index.stories.tsx +1 -1
- package/js/components/CourseGlimpse/index.stories.tsx +1 -1
- package/js/components/CourseGlimpseList/index.stories.tsx +1 -1
- package/js/components/CreditCardSelector/index.tsx +11 -3
- package/js/components/DownloadCertificateButton/index.tsx +2 -1
- package/js/components/DownloadContractButton/index.tsx +7 -1
- package/js/components/Form/Form/index.tsx +4 -2
- package/js/components/Icon/index.stories.tsx +2 -1
- package/js/components/Modal/index.stories.tsx +1 -1
- package/js/components/Modal/index.tsx +2 -1
- package/js/components/OpenEdxFullNameForm/index.stories.tsx +1 -1
- package/js/components/OpenEdxFullNameForm/index.tsx +2 -2
- package/js/components/PurchaseButton/index.stories.tsx +1 -1
- package/js/components/RegisteredAddress/index.stories.tsx +1 -1
- package/js/components/RegisteredAddress/index.tsx +4 -2
- package/js/components/SaleTunnel/AddressSelector/CreateAddressFormModal.tsx +1 -1
- package/js/components/SaleTunnel/AddressSelector/EditAddressFormModal.tsx +1 -1
- package/js/components/SaleTunnel/AddressSelector/index.tsx +4 -2
- package/js/components/SaleTunnel/SaleTunnelInformation/SaleTunnelInformationGroup.tsx +4 -3
- package/js/components/SaleTunnel/SaleTunnelInformation/SaleTunnelInformationSingular.tsx +8 -2
- package/js/components/SaleTunnel/index.stories.tsx +1 -1
- package/js/components/Spinner/index.stories.tsx +1 -1
- package/js/components/Tabs/index.stories.tsx +1 -1
- package/js/components/Tabs/index.tsx +2 -1
- package/js/components/TeacherDashboardCourseList/index.tsx +2 -1
- package/js/hooks/useAddressesManagement.tsx +4 -2
- package/js/hooks/useCreditCards/index.ts +6 -4
- package/js/hooks/useDashboardAddressForm.tsx +3 -3
- package/js/hooks/useMatchMedia.ts +1 -1
- package/js/hooks/useResources/useResourcesRoot.ts +1 -1
- package/js/hooks/useUnionResource/index.ts +6 -2
- package/js/hooks/useUnionResource/utils/fetchEntity.ts +1 -0
- package/js/pages/DashboardAddressesManagement/DashboardAddressBox.tsx +3 -3
- package/js/pages/DashboardAddressesManagement/DashboardCreateAddress.stories.tsx +1 -1
- package/js/pages/DashboardAddressesManagement/DashboardCreateAddress.tsx +1 -1
- package/js/pages/DashboardAddressesManagement/DashboardEditAddress.stories.tsx +1 -1
- package/js/pages/DashboardAddressesManagement/DashboardEditAddress.tsx +3 -2
- package/js/pages/DashboardAddressesManagement/index.stories.tsx +1 -1
- package/js/pages/DashboardAddressesManagement/index.tsx +1 -1
- package/js/pages/DashboardCourses/index.tsx +2 -1
- package/js/pages/DashboardCreditCardsManagement/CreditCardBrandLogo.stories.tsx +1 -1
- package/js/pages/DashboardCreditCardsManagement/DashboardCreditCardBox.tsx +3 -3
- package/js/pages/DashboardCreditCardsManagement/DashboardEditCreditCard.stories.tsx +1 -1
- package/js/pages/DashboardCreditCardsManagement/DashboardEditCreditCard.tsx +3 -2
- package/js/pages/DashboardCreditCardsManagement/index.stories.tsx +1 -1
- package/js/pages/DashboardOpenEdxProfile/index.stories.tsx +1 -1
- package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.tsx +4 -2
- package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.tsx +2 -1
- package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.spec.tsx +4 -4
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.spec.tsx +8 -9
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.tsx +14 -3
- package/js/pages/TeacherDashboardCourseLearnersLayout/components/CourseLearnerDataGrid/index.tsx +6 -1
- package/js/pages/TeacherDashboardCourseLoader/CourseRunList/utils.tsx +2 -1
- package/js/pages/TeacherDashboardOrganizationAgreements/BulkAgreementContractButton.tsx +4 -2
- package/js/pages/TeacherDashboardOrganizationAgreements/SignOrganizationAgreementButton.tsx +2 -1
- package/js/pages/TeacherDashboardOrganizationQuotes/index.tsx +2 -1
- package/js/translations/ar-SA.json +1 -1
- package/js/translations/es-ES.json +1 -1
- package/js/translations/fa-IR.json +1 -1
- package/js/translations/fr-CA.json +1 -1
- package/js/translations/fr-FR.json +1 -1
- package/js/translations/ko-KR.json +1 -1
- package/js/translations/pt-PT.json +1 -1
- package/js/translations/ru-RU.json +1 -1
- package/js/translations/vi-VN.json +1 -1
- package/js/utils/ProductHelper/index.spec.ts +1 -1
- package/js/utils/StorybookHelper/index.tsx +3 -6
- package/js/utils/cunningham-tokens.ts +1111 -142
- package/js/utils/errors/handle.spec.ts +3 -3
- package/js/utils/react-query/useSessionMutation/index.ts +8 -3
- package/js/widgets/Dashboard/components/DashboardAvatar/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardBox/index.stories.tsx +13 -5
- package/js/widgets/Dashboard/components/DashboardBreadcrumbs/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardBreadcrumbs/index.tsx +3 -2
- package/js/widgets/Dashboard/components/DashboardCard/index.spec.tsx +13 -2
- package/js/widgets/Dashboard/components/DashboardCard/index.stories.tsx +12 -4
- package/js/widgets/Dashboard/components/DashboardCard/index.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/BatchOrder/BatchOrderPaymentModal/BatchOrderPaymentManager.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/BatchOrder/BatchOrderPaymentModal/index.tsx +2 -1
- package/js/widgets/Dashboard/components/DashboardItem/Certificate/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Contract/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/CourseEnrolling/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/CourseEnrolling/index.tsx +8 -4
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderReadonly.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderWritable.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/Installment/index.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderPaymentRetryModal/index.tsx +2 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrganizationBlock/index.tsx +6 -3
- package/js/widgets/Dashboard/components/DashboardItem/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/index.tsx +2 -1
- package/js/widgets/Dashboard/components/DashboardListAvatar/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardSidebar/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/LearnerDashboardSidebar/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/ProtectedOutlet/AuthenticatedOutlet.spec.tsx +1 -1
- package/js/widgets/Dashboard/components/ProtectedOutlet/ProtectedOutlet.spec.tsx +1 -1
- package/js/widgets/Dashboard/components/SearchBar/index.tsx +2 -1
- package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/components/TeacherDashboardProfileSidebar/index.stories.tsx +1 -1
- package/js/widgets/Dashboard/index.spec.tsx +1 -1
- package/js/widgets/Search/components/SearchFilterValueParent/index.stories.tsx +1 -1
- package/js/widgets/Search/components/SearchFiltersPane/index.tsx +2 -1
- package/js/widgets/Slider/index.stories.tsx +1 -1
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCertificateItem/index.stories.tsx +1 -1
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseRunItem/index.stories.tsx +1 -1
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.stories.tsx +1 -1
- package/js/widgets/SyllabusCourseRunsList/components/CourseWishButton/index.tsx +4 -2
- package/js/widgets/SyllabusCourseRunsList/components/SyllabusCourseRun/index.stories.tsx +1 -1
- package/js/widgets/SyllabusCourseRunsList/components/SyllabusCourseRunCompacted/index.stories.tsx +41 -0
- package/js/widgets/UserLogin/index.stories.tsx +1 -1
- package/package.json +75 -75
- package/scss/vendors/css/cunningham-tokens.css +1259 -154
- package/scss/vendors/cunningham-tokens.scss +1479 -150
- package/tsconfig.json +1 -1
- package/webpack.config.js +6 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
2
2
|
import { Fragment, useEffect } from 'react';
|
|
3
|
-
import { FormProvider, useForm } from 'react-hook-form';
|
|
3
|
+
import { FormProvider, Resolver, useForm } from 'react-hook-form';
|
|
4
4
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
5
5
|
import { Button, Checkbox } from '@openfun/cunningham-react';
|
|
6
6
|
import { getLocalizedCunninghamErrorProp } from 'components/Form/utils';
|
|
@@ -39,7 +39,7 @@ const AddressForm = ({ handleReset, onSubmit, address }: Props) => {
|
|
|
39
39
|
defaultValues: address || defaultValues,
|
|
40
40
|
mode: 'onBlur',
|
|
41
41
|
reValidateMode: 'onChange',
|
|
42
|
-
resolver: yupResolver(validationSchema)
|
|
42
|
+
resolver: yupResolver(validationSchema) as Resolver<AddressFormValues>,
|
|
43
43
|
});
|
|
44
44
|
const { register, handleSubmit, reset, formState } = form;
|
|
45
45
|
|
|
@@ -140,7 +140,8 @@ const AddressForm = ({ handleReset, onSubmit, address }: Props) => {
|
|
|
140
140
|
{address ? (
|
|
141
141
|
<Fragment>
|
|
142
142
|
<Button
|
|
143
|
-
color="
|
|
143
|
+
color="brand"
|
|
144
|
+
variant="tertiary"
|
|
144
145
|
onClick={handleCancel}
|
|
145
146
|
title={intl.formatMessage(messages.cancelTitleButton)}
|
|
146
147
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { StorybookHelper } from 'utils/StorybookHelper';
|
|
3
3
|
import { RichieContextFactory } from 'utils/test/factories/richie';
|
|
4
4
|
import AddressesManagement from '.';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Children, useEffect, useState,
|
|
1
|
+
import { Children, useEffect, useState, Ref } from 'react';
|
|
2
2
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
3
3
|
import { Button } from '@openfun/cunningham-react';
|
|
4
4
|
import AddressForm, { type AddressFormValues } from 'components/AddressesManagement/AddressForm';
|
|
@@ -105,9 +105,10 @@ export const messages = defineMessages({
|
|
|
105
105
|
},
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
interface AddressesManagementProps
|
|
108
|
+
interface AddressesManagementProps {
|
|
109
109
|
handleClose: () => void;
|
|
110
110
|
selectAddress: (address: Joanie.Address) => void;
|
|
111
|
+
ref?: Ref<HTMLDivElement>;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
const AddressesManagement = ({ handleClose, selectAddress, ref }: AddressesManagementProps) => {
|
|
@@ -191,7 +192,8 @@ const AddressesManagement = ({ handleClose, selectAddress, ref }: AddressesManag
|
|
|
191
192
|
<div className="AddressesManagement" ref={ref}>
|
|
192
193
|
<Button
|
|
193
194
|
className="AddressesManagement__closeButton"
|
|
194
|
-
color="
|
|
195
|
+
color="brand"
|
|
196
|
+
variant="tertiary"
|
|
195
197
|
size="small"
|
|
196
198
|
onClick={handleClose}
|
|
197
199
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { CourseLightFactory, RichieContextFactory } from 'utils/test/factories/richie';
|
|
3
3
|
import { CourseGlimpse, getCourseGlimpseProps } from 'components/CourseGlimpse';
|
|
4
4
|
import { CourseCertificateOffer, CourseOffer } from 'types/Course';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { RichieContextFactory, CourseLightFactory } from 'utils/test/factories/richie';
|
|
3
3
|
import { CourseGlimpseList, getCourseGlimpseListProps } from '.';
|
|
4
4
|
|
|
@@ -111,7 +111,8 @@ export const CreditCardSelector = ({
|
|
|
111
111
|
{allowEdit && creditCards?.length > 0 && (
|
|
112
112
|
<Button
|
|
113
113
|
icon={<span className="material-icons">edit</span>}
|
|
114
|
-
color="
|
|
114
|
+
color="brand"
|
|
115
|
+
variant="tertiary"
|
|
115
116
|
size="medium"
|
|
116
117
|
onClick={modal.open}
|
|
117
118
|
aria-label={intl.formatMessage(messages.editCreditCardAriaLabel)}
|
|
@@ -122,7 +123,8 @@ export const CreditCardSelector = ({
|
|
|
122
123
|
<Button
|
|
123
124
|
onClick={() => setCreditCard(undefined)}
|
|
124
125
|
size="small"
|
|
125
|
-
color="
|
|
126
|
+
color="brand"
|
|
127
|
+
variant="secondary"
|
|
126
128
|
className="mt-t"
|
|
127
129
|
fullWidth={isMobile}
|
|
128
130
|
>
|
|
@@ -217,7 +219,13 @@ const CreditCardSelectorModal = ({
|
|
|
217
219
|
size={ModalSize.MEDIUM}
|
|
218
220
|
title={intl.formatMessage(messages.modalTitle)}
|
|
219
221
|
actions={
|
|
220
|
-
<Button
|
|
222
|
+
<Button
|
|
223
|
+
color="brand"
|
|
224
|
+
variant="primary"
|
|
225
|
+
size="small"
|
|
226
|
+
fullWidth={true}
|
|
227
|
+
onClick={() => onChange(selected)}
|
|
228
|
+
>
|
|
221
229
|
<FormattedMessage {...messages.modalTitle} />
|
|
222
230
|
</Button>
|
|
223
231
|
}
|
|
@@ -39,7 +39,13 @@ const DownloadContractButton = ({ contract, className }: DownloadContractButtonP
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
<Button
|
|
42
|
+
<Button
|
|
43
|
+
size="small"
|
|
44
|
+
className={className}
|
|
45
|
+
color="brand"
|
|
46
|
+
variant="secondary"
|
|
47
|
+
onClick={downloadContract}
|
|
48
|
+
>
|
|
43
49
|
<FormattedMessage {...messages.contractDownloadActionLabel} />
|
|
44
50
|
</Button>
|
|
45
51
|
);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import c from 'classnames';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
3
|
|
|
4
|
-
interface FormProps
|
|
5
|
-
|
|
4
|
+
interface FormProps extends React.DetailedHTMLProps<
|
|
5
|
+
React.FormHTMLAttributes<HTMLFormElement>,
|
|
6
|
+
HTMLFormElement
|
|
7
|
+
> {}
|
|
6
8
|
|
|
7
9
|
const Form = ({ children, onSubmit, className, name, noValidate = true }: FormProps) => {
|
|
8
10
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { PropsWithChildren, useState, useRef, CSSProperties } from 'react';
|
|
3
3
|
import { HttpStatusCode } from 'utils/errors/HttpError';
|
|
4
4
|
import { Icon, IconTypeEnum } from './index';
|
|
@@ -69,6 +69,7 @@ const IconContainer = ({ name, enumKey }: IconContainerProps) => {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
const clipboardCopy = () => {
|
|
72
|
+
// eslint-disable-next-line compat/compat
|
|
72
73
|
navigator.clipboard.writeText(`${ENUM_NAME}.${enumKey}`);
|
|
73
74
|
setShowTooltip(true);
|
|
74
75
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
@@ -78,7 +78,8 @@ export const Modal = ({
|
|
|
78
78
|
className="modal__closeButton"
|
|
79
79
|
onClick={(e) => props.onRequestClose?.(e)}
|
|
80
80
|
title={intl.formatMessage(messages.closeDialog)}
|
|
81
|
-
color="
|
|
81
|
+
color="brand"
|
|
82
|
+
variant="tertiary"
|
|
82
83
|
size="small"
|
|
83
84
|
>
|
|
84
85
|
<Icon name={IconTypeEnum.ROUND_CLOSE} />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ButtonElement, Input, Alert, VariantType } from '@openfun/cunningham-react';
|
|
2
2
|
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
|
3
|
-
import { FormProvider, useForm } from 'react-hook-form';
|
|
3
|
+
import { FormProvider, Resolver, useForm } from 'react-hook-form';
|
|
4
4
|
import * as Yup from 'yup';
|
|
5
5
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
6
6
|
import { useEffect, useMemo, useRef } from 'react';
|
|
@@ -78,7 +78,7 @@ const OpenEdxFullNameForm = () => {
|
|
|
78
78
|
defaultValues,
|
|
79
79
|
mode: 'onBlur',
|
|
80
80
|
reValidateMode: 'onChange',
|
|
81
|
-
resolver: yupResolver(validationSchema)
|
|
81
|
+
resolver: yupResolver(validationSchema) as Resolver<OpenEdxFullNameFormValues>,
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
const { getValues, register, handleSubmit, reset, formState } = form;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { StorybookHelper } from 'utils/StorybookHelper';
|
|
3
3
|
import { AddressFactory } from 'utils/test/factories/joanie';
|
|
4
4
|
import RegisteredAddress from '.';
|
|
@@ -91,7 +91,8 @@ const RegisteredAddress = ({ promote, select, edit, remove, address }: Props) =>
|
|
|
91
91
|
</Button>
|
|
92
92
|
<Button
|
|
93
93
|
aria-label={intl.formatMessage(messages.editButtonLabel, { title: address.title })}
|
|
94
|
-
color="
|
|
94
|
+
color="brand"
|
|
95
|
+
variant="secondary"
|
|
95
96
|
size="small"
|
|
96
97
|
onClick={() => edit(address)}
|
|
97
98
|
>
|
|
@@ -101,7 +102,8 @@ const RegisteredAddress = ({ promote, select, edit, remove, address }: Props) =>
|
|
|
101
102
|
aria-label={intl.formatMessage(messages.deleteButtonLabel, {
|
|
102
103
|
title: address.title,
|
|
103
104
|
})}
|
|
104
|
-
color="
|
|
105
|
+
color="brand"
|
|
106
|
+
variant="secondary"
|
|
105
107
|
size="small"
|
|
106
108
|
disabled={address.is_main}
|
|
107
109
|
onClick={() => remove(address)}
|
|
@@ -52,7 +52,7 @@ export const CreateAddressFormModal = (props: AddressFormModalProps) => {
|
|
|
52
52
|
size={ModalSize.MEDIUM}
|
|
53
53
|
title={intl.formatMessage(messages.title)}
|
|
54
54
|
actions={
|
|
55
|
-
<Button color="primary" size="small" onClick={handleSubmit(onSubmit)}>
|
|
55
|
+
<Button color="brand" variant="primary" size="small" onClick={handleSubmit(onSubmit)}>
|
|
56
56
|
<FormattedMessage {...messages.submit} />
|
|
57
57
|
</Button>
|
|
58
58
|
}
|
|
@@ -49,7 +49,7 @@ export const EditAddressFormModal = ({
|
|
|
49
49
|
size={ModalSize.MEDIUM}
|
|
50
50
|
title={intl.formatMessage(messages.title)}
|
|
51
51
|
actions={
|
|
52
|
-
<Button color="primary" size="small" onClick={handleSubmit(onSubmit)}>
|
|
52
|
+
<Button color="brand" variant="primary" size="small" onClick={handleSubmit(onSubmit)}>
|
|
53
53
|
<FormattedMessage {...messages.save} />
|
|
54
54
|
</Button>
|
|
55
55
|
}
|
|
@@ -75,7 +75,8 @@ export const AddressSelector = () => {
|
|
|
75
75
|
<Button
|
|
76
76
|
size="small"
|
|
77
77
|
icon={<span className="material-icons">edit</span>}
|
|
78
|
-
color="
|
|
78
|
+
color="brand"
|
|
79
|
+
variant="tertiary"
|
|
79
80
|
onClick={editFormModal.open}
|
|
80
81
|
fullWidth={isMobile}
|
|
81
82
|
>
|
|
@@ -85,7 +86,8 @@ export const AddressSelector = () => {
|
|
|
85
86
|
<Button
|
|
86
87
|
size="small"
|
|
87
88
|
icon={<span className="material-icons">add</span>}
|
|
88
|
-
color="
|
|
89
|
+
color="brand"
|
|
90
|
+
variant="primary"
|
|
89
91
|
onClick={createFormModal.open}
|
|
90
92
|
fullWidth={isMobile}
|
|
91
93
|
>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
3
|
-
import { FormProvider, useForm } from 'react-hook-form';
|
|
3
|
+
import { FormProvider, Resolver, useForm } from 'react-hook-form';
|
|
4
4
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
5
5
|
import * as Yup from 'yup';
|
|
6
6
|
import { Step, StepLabel, Stepper } from '@mui/material';
|
|
@@ -197,7 +197,7 @@ const BatchOrderForm = () => {
|
|
|
197
197
|
const form = useForm<BatchOrder>({
|
|
198
198
|
defaultValues: batchOrder || defaultValues,
|
|
199
199
|
mode: 'onBlur',
|
|
200
|
-
resolver: yupResolver(validationSchema)
|
|
200
|
+
resolver: yupResolver(validationSchema) as Resolver<BatchOrder>,
|
|
201
201
|
});
|
|
202
202
|
const { watch } = form;
|
|
203
203
|
const values = watch();
|
|
@@ -268,7 +268,8 @@ const BatchOrderForm = () => {
|
|
|
268
268
|
}
|
|
269
269
|
}}
|
|
270
270
|
hidden={activeStep === 0}
|
|
271
|
-
color="
|
|
271
|
+
color="brand"
|
|
272
|
+
variant="tertiary"
|
|
272
273
|
>
|
|
273
274
|
<FormattedMessage {...messages.previousButton} />
|
|
274
275
|
</Button>
|
|
@@ -443,7 +443,13 @@ const Voucher = ({
|
|
|
443
443
|
label={intl.formatMessage(messages.voucherTitle)}
|
|
444
444
|
disabled={!!voucherCode}
|
|
445
445
|
/>
|
|
446
|
-
<Button
|
|
446
|
+
<Button
|
|
447
|
+
size="small"
|
|
448
|
+
color="brand"
|
|
449
|
+
variant="primary"
|
|
450
|
+
onClick={submitVoucher}
|
|
451
|
+
disabled={!!voucherCode}
|
|
452
|
+
>
|
|
447
453
|
<FormattedMessage {...messages.voucherValidate} />
|
|
448
454
|
</Button>
|
|
449
455
|
</div>
|
|
@@ -500,7 +506,7 @@ const CpfPayment = ({ deepLink }: { deepLink: string }) => {
|
|
|
500
506
|
<FormattedMessage {...messages.cpfDescription} />
|
|
501
507
|
</p>
|
|
502
508
|
<Button
|
|
503
|
-
color="
|
|
509
|
+
color="brand"
|
|
504
510
|
fullWidth={true}
|
|
505
511
|
href={deepLink}
|
|
506
512
|
target="_blank"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { defineMessages, useIntl } from 'react-intl';
|
|
2
|
-
import { MutateOptions } from '@tanstack/react-query';
|
|
3
2
|
import { useAddresses } from 'hooks/useAddresses';
|
|
4
3
|
import * as Joanie from 'types/Joanie';
|
|
5
4
|
import { confirm } from 'utils/indirection/window';
|
|
@@ -58,7 +57,10 @@ export function useAddressesManagement() {
|
|
|
58
57
|
* @param {Joanie.Address} address
|
|
59
58
|
* @param {AddressesMutateOptions} options
|
|
60
59
|
*/
|
|
61
|
-
const remove = (
|
|
60
|
+
const remove = (
|
|
61
|
+
address: Joanie.Address,
|
|
62
|
+
options?: Parameters<typeof addresses.methods.delete>[1],
|
|
63
|
+
) => {
|
|
62
64
|
if (address.is_main) {
|
|
63
65
|
addresses.methods.setError(intl.formatMessage(messages.errorCannotRemoveMain));
|
|
64
66
|
return;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { defineMessages, useIntl } from 'react-intl';
|
|
2
2
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
3
|
-
import { MutateOptions } from '@tanstack/query-core';
|
|
4
3
|
import { API, CreditCard } from 'types/Joanie';
|
|
5
4
|
import { useJoanieApi } from 'contexts/JoanieApiContext';
|
|
6
5
|
import { useSessionMutation } from 'utils/react-query/useSessionMutation';
|
|
@@ -84,10 +83,13 @@ const useCreditCardResources =
|
|
|
84
83
|
* If the error is a 409, it means the credit card is used to pay at least one order
|
|
85
84
|
* and the user should be informed about that.
|
|
86
85
|
*/
|
|
87
|
-
const deleteMutateAsync = async (
|
|
86
|
+
const deleteMutateAsync = async (
|
|
87
|
+
creditCard: CreditCard,
|
|
88
|
+
options?: Parameters<typeof custom.methods.delete>[1],
|
|
89
|
+
) => {
|
|
88
90
|
return custom.methods.delete(creditCard.id, {
|
|
89
91
|
...options,
|
|
90
|
-
onError: (error: HttpError, variables, context) => {
|
|
92
|
+
onError: (error: HttpError, variables, context, mutationContext) => {
|
|
91
93
|
if (error.code === HttpStatusCode.CONFLICT) {
|
|
92
94
|
custom.methods.setError(
|
|
93
95
|
intl.formatMessage(messages.errorCannotDelete, {
|
|
@@ -97,7 +99,7 @@ const useCreditCardResources =
|
|
|
97
99
|
} else {
|
|
98
100
|
custom.methods.setError(intl.formatMessage(messages.errorDelete));
|
|
99
101
|
}
|
|
100
|
-
options?.onError?.(error, variables, context);
|
|
102
|
+
options?.onError?.(error, variables, context, mutationContext);
|
|
101
103
|
},
|
|
102
104
|
});
|
|
103
105
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { yupResolver } from '@hookform/resolvers/yup
|
|
2
|
-
import { FormProvider, useForm } from 'react-hook-form';
|
|
1
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
2
|
+
import { FormProvider, Resolver, useForm } from 'react-hook-form';
|
|
3
3
|
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
|
4
4
|
import * as Yup from 'yup';
|
|
5
5
|
import countries from 'i18n-iso-countries';
|
|
@@ -60,7 +60,7 @@ export const useDashboardAddressForm = (address?: Address) => {
|
|
|
60
60
|
defaultValues: address || defaultValues,
|
|
61
61
|
mode: 'onBlur',
|
|
62
62
|
reValidateMode: 'onChange',
|
|
63
|
-
resolver: yupResolver(validationSchema)
|
|
63
|
+
resolver: yupResolver(validationSchema) as Resolver<AddressFormValues>,
|
|
64
64
|
});
|
|
65
65
|
const { register, handleSubmit, formState } = form;
|
|
66
66
|
|
|
@@ -36,6 +36,6 @@ const useMatchMedia = (query: string): boolean => {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
export const useMatchMediaLg = () =>
|
|
39
|
-
useMatchMedia(`(max-width: ${tokens.themes.default.
|
|
39
|
+
useMatchMedia(`(max-width: ${tokens.themes.default.globals.breakpoints.lg})`);
|
|
40
40
|
|
|
41
41
|
export default useMatchMedia;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMutation, useQuery, useQueryClient, UseQueryResult } from '@tanstack/react-query';
|
|
2
2
|
import { useCallback, useMemo, useState } from 'react';
|
|
3
3
|
import { defineMessages, useIntl } from 'react-intl';
|
|
4
|
-
import { MutateOptions } from '@tanstack/query-core
|
|
4
|
+
import { MutateOptions } from '@tanstack/query-core';
|
|
5
5
|
import { AddParameters, Maybe } from 'types/utils';
|
|
6
6
|
import { HttpError } from 'utils/errors/HttpError';
|
|
7
7
|
import { useSessionQuery } from 'utils/react-query/useSessionQuery';
|
|
@@ -35,8 +35,12 @@ export interface ResourceUnionPaginationProps {
|
|
|
35
35
|
perPage?: number;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
interface UseUnionResourceProps<
|
|
39
|
-
|
|
38
|
+
interface UseUnionResourceProps<
|
|
39
|
+
DataA,
|
|
40
|
+
DataB,
|
|
41
|
+
FiltersA,
|
|
42
|
+
FiltersB,
|
|
43
|
+
> extends ResourceUnionPaginationProps {
|
|
40
44
|
queryAConfig: QueryConfig<DataA, FiltersA>;
|
|
41
45
|
queryBConfig: QueryConfig<DataB, FiltersB>;
|
|
42
46
|
errorGetMessage?: MessageDescriptor;
|
|
@@ -53,6 +53,7 @@ export const fetchEntity = async <
|
|
|
53
53
|
// Here we need to mimic the behavior of staleTime, which does not seems to be implemented when using `getQueryData`.
|
|
54
54
|
if (
|
|
55
55
|
state &&
|
|
56
|
+
state.status === 'success' &&
|
|
56
57
|
state.dataUpdatedAt >= new Date().getTime() - REACT_QUERY_SETTINGS.staleTimes.sessionItems &&
|
|
57
58
|
!state.isInvalidated
|
|
58
59
|
) {
|
|
@@ -47,16 +47,16 @@ export const DashboardAddressBox = ({
|
|
|
47
47
|
<>
|
|
48
48
|
<div className="dashboard-address-box__buttons">
|
|
49
49
|
{!address.is_main && (
|
|
50
|
-
<Button color="primary" onClick={() => promote(address)}>
|
|
50
|
+
<Button color="brand" variant="primary" onClick={() => promote(address)}>
|
|
51
51
|
<FormattedMessage {...messages.setMain} />
|
|
52
52
|
</Button>
|
|
53
53
|
)}
|
|
54
|
-
<Button color="primary" onClick={() => edit(address)}>
|
|
54
|
+
<Button color="brand" variant="primary" onClick={() => edit(address)}>
|
|
55
55
|
<FormattedMessage {...messages.edit} />
|
|
56
56
|
</Button>
|
|
57
57
|
</div>
|
|
58
58
|
{!address.is_main && (
|
|
59
|
-
<Button color="primary" onClick={() => remove(address)}>
|
|
59
|
+
<Button color="brand" variant="primary" onClick={() => remove(address)}>
|
|
60
60
|
<FormattedMessage {...messages.delete} />
|
|
61
61
|
</Button>
|
|
62
62
|
)}
|
|
@@ -38,7 +38,7 @@ export const DashboardCreateAddress = ({ onSettled }: { onSettled?: Function })
|
|
|
38
38
|
<DashboardCard
|
|
39
39
|
header={<FormattedMessage {...messages.header} />}
|
|
40
40
|
footer={
|
|
41
|
-
<Button color="primary" onClick={handleSubmit(onSubmit)}>
|
|
41
|
+
<Button color="brand" variant="primary" onClick={handleSubmit(onSubmit)}>
|
|
42
42
|
<FormattedMessage {...messages.submit} />
|
|
43
43
|
</Button>
|
|
44
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { StorybookHelper } from 'utils/StorybookHelper';
|
|
3
3
|
import { AddressFactory } from 'utils/test/factories/joanie';
|
|
4
4
|
import { DashboardEditAddress } from './DashboardEditAddress';
|
|
@@ -54,12 +54,13 @@ export const DashboardEditAddress = ({ address, onSettled = noop }: DashboardEdi
|
|
|
54
54
|
header={<FormattedMessage {...messages.header} values={{ title: address.title }} />}
|
|
55
55
|
footer={
|
|
56
56
|
<>
|
|
57
|
-
<Button color="secondary" onClick={handleSubmit(onSubmit)}>
|
|
57
|
+
<Button color="brand" variant="secondary" onClick={handleSubmit(onSubmit)}>
|
|
58
58
|
<FormattedMessage {...messages.submit} />
|
|
59
59
|
</Button>
|
|
60
60
|
{!address.is_main && (
|
|
61
61
|
<Button
|
|
62
|
-
color="
|
|
62
|
+
color="brand"
|
|
63
|
+
variant="secondary"
|
|
63
64
|
onClick={() => {
|
|
64
65
|
remove(address, {
|
|
65
66
|
onSuccess: () => onSettled(),
|
|
@@ -86,7 +86,7 @@ export const DashboardAddressesManagement = ({
|
|
|
86
86
|
))}
|
|
87
87
|
</DashboardBox.List>
|
|
88
88
|
)}
|
|
89
|
-
<Button color="secondary" fullWidth onClick={() => onClickCreate?.()}>
|
|
89
|
+
<Button color="brand" variant="secondary" fullWidth onClick={() => onClickCreate?.()}>
|
|
90
90
|
<Icon name={IconTypeEnum.PLUS} className="button__icon" />
|
|
91
91
|
<FormattedMessage {...messages.add} />
|
|
92
92
|
</Button>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
2
|
import { CreditCardFactory } from 'utils/test/factories/joanie';
|
|
3
3
|
import { CreditCard, CreditCardBrand } from 'types/Joanie';
|
|
4
4
|
import { CreditCardBrandLogo } from './CreditCardBrandLogo';
|