@faststore/core 4.4.0-dev.0 → 4.4.0-dev.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.
- package/.turbo/turbo-generate.log +3 -3
- package/.turbo/turbo-test.log +48 -48
- package/CHANGELOG.md +6 -0
- package/README.md +2 -1
- package/cms/faststore/my-account/README.md +36 -0
- package/cms/faststore/my-account/components/cms_component__accountnavigation.jsonc +59 -0
- package/cms/faststore/my-account/components/cms_component__accountorderbudgets.jsonc +39 -0
- package/cms/faststore/my-account/components/cms_component__accountorderdelivery.jsonc +69 -0
- package/cms/faststore/my-account/components/cms_component__accountorderdetails.jsonc +79 -0
- package/cms/faststore/my-account/components/cms_component__accountordermoreinfo.jsonc +19 -0
- package/cms/faststore/my-account/components/cms_component__accountorderorderedby.jsonc +19 -0
- package/cms/faststore/my-account/components/cms_component__accountorderpayment.jsonc +69 -0
- package/cms/faststore/my-account/components/cms_component__accountorderslist.jsonc +154 -0
- package/cms/faststore/my-account/components/cms_component__accountorderstatus.jsonc +44 -0
- package/cms/faststore/my-account/components/cms_component__accountordersummary.jsonc +29 -0
- package/cms/faststore/my-account/components/cms_component__accountprofile.jsonc +39 -0
- package/cms/faststore/my-account/components/cms_component__accountsecurity.jsonc +104 -0
- package/cms/faststore/my-account/components/cms_component__accountunauthorized.jsonc +29 -0
- package/cms/faststore/my-account/components/cms_component__accountuserdetails.jsonc +49 -0
- package/cms/faststore/my-account/pages/cms_content_type__myaccountorderdetails.jsonc +18 -0
- package/cms/faststore/my-account/pages/cms_content_type__myaccountorders.jsonc +18 -0
- package/cms/faststore/my-account/pages/cms_content_type__myaccountprofile.jsonc +18 -0
- package/cms/faststore/my-account/pages/cms_content_type__myaccountsecurity.jsonc +18 -0
- package/cms/faststore/my-account/pages/cms_content_type__myaccountunauthorized.jsonc +18 -0
- package/cms/faststore/my-account/pages/cms_content_type__myaccountuserdetails.jsonc +18 -0
- package/package.json +6 -6
- package/src/components/account/{MyAccountDrawer → Drawer}/OrganizationDrawer/OrganizationDrawerBody.tsx +15 -3
- package/src/components/account/{MyAccountDrawer → Drawer}/OrganizationSignInButton/OrganizationSignInButton.tsx +5 -1
- package/src/components/account/{MyAccountDrawer → Drawer}/ProfileSummary/ProfileSummary.tsx +12 -2
- package/src/components/account/Layout/Layout.tsx +46 -0
- package/src/components/account/Layout/index.ts +1 -0
- package/src/components/account/{MyAccountLayout → Layout}/styles.scss +2 -2
- package/src/components/account/{MyAccountMenu/MyAccountMenu.tsx → Menu/Menu.tsx} +8 -10
- package/src/components/account/Menu/index.ts +1 -0
- package/src/components/account/UserDetails/UserDetails.tsx +54 -0
- package/src/components/account/UserDetails/index.ts +1 -0
- package/src/components/account/{MyAccountUserDetails → UserDetails}/styles.module.scss +2 -2
- package/src/components/account/UserDetails/userDetailsLabels.ts +25 -0
- package/src/components/account/components/{MyAccountAccordion/MyAccountAccordion.tsx → Accordion/Accordion.tsx} +2 -4
- package/src/components/account/components/{MyAccountAccordion/MyAccountAccordionButton.tsx → Accordion/AccordionButton.tsx} +3 -7
- package/src/components/account/components/{MyAccountAccordion/MyAccountAccordionItem.tsx → Accordion/AccordionItem.tsx} +3 -7
- package/src/components/account/components/{MyAccountAccordion/MyAccountAccordionPanel.tsx → Accordion/AccordionPanel.tsx} +3 -3
- package/src/components/account/components/Accordion/index.ts +4 -0
- package/src/components/account/components/{MyAccountCard/MyAccountCard.tsx → Card/Card.tsx} +2 -4
- package/src/components/account/components/Card/index.ts +1 -0
- package/src/components/account/components/{MyAccountHeader/MyAccountHeader.tsx → Header/Header.tsx} +3 -3
- package/src/components/account/components/Header/index.ts +1 -0
- package/src/components/account/components/StatusBadge/StatusBadge.tsx +43 -0
- package/src/components/account/components/StatusBadge/index.ts +1 -0
- package/src/components/account/components/{MyAccountTable/MyAccountTable.tsx → Table/Table.tsx} +3 -3
- package/src/components/account/components/Table/index.ts +1 -0
- package/src/components/account/components/Tag/index.ts +1 -0
- package/src/components/account/index.ts +2 -2
- package/src/components/account/orders/ListOrders/FilterSlider/FilterFacetDateRange/FilterFacetDateRange.tsx +128 -0
- package/src/components/account/orders/ListOrders/FilterSlider/FilterFacetDateRange/index.ts +2 -0
- package/src/components/account/orders/{MyAccountListOrders/MyAccountFilterSlider/MyAccountFilterFacetPendingApproval/MyAccountFilterFacetPendingApproval.tsx → ListOrders/FilterSlider/FilterFacetPendingApproval/FilterFacetPendingApproval.tsx} +4 -4
- package/src/components/account/orders/ListOrders/FilterSlider/FilterFacetPendingApproval/index.ts +2 -0
- package/src/components/account/orders/{MyAccountListOrders/MyAccountFilterSlider/MyAccountFilterSlider.tsx → ListOrders/FilterSlider/FilterSlider.tsx} +13 -4
- package/src/components/account/orders/ListOrders/FilterSlider/index.ts +1 -0
- package/src/components/account/orders/{MyAccountListOrders/MyAccountFilterSlider → ListOrders/FilterSlider}/section.module.scss +2 -2
- package/src/components/account/orders/{MyAccountListOrders/MyAccountListOrders.tsx → ListOrders/ListOrders.tsx} +53 -30
- package/src/components/account/orders/{MyAccountListOrders/MyAccountListOrdersTable → ListOrders/ListOrdersTable}/ExpandButton/ExpandButton.tsx +5 -1
- package/src/components/account/orders/{MyAccountListOrders/MyAccountListOrdersTable/MyAccountListOrdersTable.tsx → ListOrders/ListOrdersTable/ListOrdersTable.tsx} +35 -12
- package/src/components/account/orders/ListOrders/ListOrdersTable/index.ts +1 -0
- package/src/components/account/orders/{MyAccountListOrders/MyAccountSelectedTags/MyAccountSelectedTags.tsx → ListOrders/SelectedTags/SelectedTags.tsx} +24 -14
- package/src/components/account/orders/ListOrders/SelectedTags/index.ts +1 -0
- package/src/components/account/orders/ListOrders/index.ts +1 -0
- package/src/components/account/orders/ListOrders/listOrdersLabels.ts +112 -0
- package/src/components/account/orders/{MyAccountListOrders → ListOrders}/styles.module.scss +3 -3
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountBudgetsCard/MyAccountBudgetsCard.tsx → OrderDetails/BudgetsCard/BudgetsCard.tsx} +18 -11
- package/src/components/account/orders/OrderDetails/BudgetsCard/index.ts +1 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountBuyingPolicyAlert/MyAccountBuyingPolicyAlert.tsx → OrderDetails/BuyingPolicyAlert/BuyingPolicyAlert.tsx} +46 -20
- package/src/components/account/orders/OrderDetails/BuyingPolicyAlert/index.ts +1 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountDeliveryCard/MyAccountDeliveryCard.tsx → OrderDetails/DeliveryCard/DeliveryCard.tsx} +16 -15
- package/src/components/account/orders/OrderDetails/DeliveryCard/index.ts +1 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountDeliveryOptionAccordion/MyAccountDeliveryOptionAccordion.tsx → OrderDetails/DeliveryOptionAccordion/DeliveryOptionAccordion.tsx} +38 -25
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountDeliveryOptionAccordion/MyAccountDeliveryOptionAccordionDeliveryInfo.tsx → OrderDetails/DeliveryOptionAccordion/DeliveryOptionAccordionDeliveryInfo.tsx} +4 -4
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountDeliveryOptionAccordion/MyAccountDeliveryOptionAccordionProducts.tsx → OrderDetails/DeliveryOptionAccordion/DeliveryOptionAccordionProducts.tsx} +7 -10
- package/src/components/account/orders/OrderDetails/DeliveryOptionAccordion/index.ts +6 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountMoreInformationCard/MyAccountMoreInformationCard.tsx → OrderDetails/MoreInformationCard/MoreInformationCard.tsx} +10 -7
- package/src/components/account/orders/OrderDetails/MoreInformationCard/index.ts +1 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountOrderActionModal/MyAccountOrderActionModal.tsx → OrderDetails/OrderActionModal/OrderActionModal.tsx} +3 -3
- package/src/components/account/orders/OrderDetails/OrderActionModal/index.ts +1 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountOrderActions/MyAccountOrderActions.tsx → OrderDetails/OrderActions/OrderActions.tsx} +19 -12
- package/src/components/account/orders/OrderDetails/OrderActions/index.ts +1 -0
- package/src/components/account/orders/OrderDetails/OrderDetails.tsx +92 -0
- package/src/components/account/orders/OrderDetails/OrderDetailsHeader.tsx +89 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountOrderedByCard/MyAccountOrderedByCard.tsx → OrderDetails/OrderedByCard/OrderedByCard.tsx} +9 -7
- package/src/components/account/orders/OrderDetails/OrderedByCard/index.ts +1 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountPaymentCard/MyAccountPaymentCard.tsx → OrderDetails/PaymentCard/PaymentCard.tsx} +42 -27
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountPaymentCard/MyAccountPaymentFlagsIcon.tsx → OrderDetails/PaymentCard/PaymentFlagsIcon.tsx} +3 -3
- package/src/components/account/orders/OrderDetails/PaymentCard/index.ts +1 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountReorderButton/MyAccountReorderButton.tsx → OrderDetails/ReorderButton/ReorderButton.tsx} +6 -4
- package/src/components/account/orders/OrderDetails/ReorderButton/index.ts +2 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountStatusCard/MyAccountStatusCard.tsx → OrderDetails/StatusCard/StatusCard.tsx} +29 -8
- package/src/components/account/orders/OrderDetails/StatusCard/index.ts +1 -0
- package/src/components/account/orders/{MyAccountOrderDetails/MyAccountSummaryCard/MyAccountSummaryCard.tsx → OrderDetails/SummaryCard/SummaryCard.tsx} +16 -9
- package/src/components/account/orders/OrderDetails/SummaryCard/index.ts +1 -0
- package/src/components/account/orders/OrderDetails/index.ts +10 -0
- package/src/components/account/orders/OrderDetails/orderDetailsLabels.ts +204 -0
- package/src/components/account/orders/{MyAccountOrderDetails → OrderDetails}/section.module.scss +14 -14
- package/src/components/account/profile/profile.module.scss +1 -1
- package/src/components/account/profile/profile.tsx +31 -8
- package/src/components/account/section.module.scss +1 -1
- package/src/components/account/security/SecurityDrawer.tsx +29 -20
- package/src/components/account/security/SecuritySection.tsx +17 -6
- package/src/components/account/security/securityLabels.ts +47 -0
- package/src/components/account/security/styles.module.scss +1 -1
- package/src/components/cms/account/Components.ts +53 -0
- package/src/components/navigation/Navbar/Navbar.tsx +1 -1
- package/src/components/navigation/NavbarSlider/NavbarSlider.tsx +1 -1
- package/src/components/sections/Account/AccountNavigation.tsx +5 -0
- package/src/components/sections/Account/AccountOrderBudgets.tsx +35 -0
- package/src/components/sections/Account/AccountOrderDelivery.tsx +57 -0
- package/src/components/sections/Account/AccountOrderDetails.tsx +57 -0
- package/src/components/sections/Account/AccountOrderMoreInfo.tsx +39 -0
- package/src/components/sections/Account/AccountOrderOrderedBy.tsx +36 -0
- package/src/components/sections/Account/AccountOrderPayment.tsx +36 -0
- package/src/components/sections/Account/AccountOrderStatus.tsx +49 -0
- package/src/components/sections/Account/AccountOrderSummary.tsx +36 -0
- package/src/components/sections/Account/AccountOrdersList.tsx +89 -0
- package/src/components/sections/Account/AccountProfile.tsx +46 -0
- package/src/components/sections/Account/AccountSecurity.tsx +65 -0
- package/src/components/sections/Account/AccountUnauthorized.tsx +40 -0
- package/src/components/sections/Account/AccountUserDetails.tsx +43 -0
- package/src/experimental/index.ts +1 -1
- package/src/pages/_app.tsx +1 -1
- package/src/pages/pvt/account/403.tsx +43 -50
- package/src/pages/pvt/account/404.tsx +3 -3
- package/src/pages/pvt/account/orders/[id].tsx +58 -13
- package/src/pages/pvt/account/orders/index.tsx +59 -48
- package/src/pages/pvt/account/profile.tsx +64 -33
- package/src/pages/pvt/account/security.tsx +66 -32
- package/src/pages/pvt/account/user-details.tsx +67 -37
- package/src/sdk/account/accountPageContext.ts +73 -0
- package/src/sdk/account/getMyAccountRoutes.ts +48 -3
- package/src/sdk/overrides/PageProvider.tsx +3 -1
- package/src/server/cms/fetchMyAccountPageContent.ts +45 -0
- package/src/server/cms/myAccountDefaultSections.ts +73 -0
- package/src/utils/userOrderStatus.ts +129 -0
- package/test/utils/userOrderStatus.test.ts +36 -0
- package/src/components/account/MyAccountLayout/MyAccountLayout.tsx +0 -32
- package/src/components/account/MyAccountLayout/index.ts +0 -1
- package/src/components/account/MyAccountMenu/index.ts +0 -1
- package/src/components/account/MyAccountUserDetails/MyAccountUserDetails.tsx +0 -46
- package/src/components/account/MyAccountUserDetails/index.ts +0 -1
- package/src/components/account/components/MyAccountAccordion/index.ts +0 -4
- package/src/components/account/components/MyAccountCard/index.ts +0 -1
- package/src/components/account/components/MyAccountHeader/index.ts +0 -1
- package/src/components/account/components/MyAccountStatusBadge/MyAccountStatusBadge.tsx +0 -28
- package/src/components/account/components/MyAccountStatusBadge/index.ts +0 -1
- package/src/components/account/components/MyAccountTable/index.ts +0 -1
- package/src/components/account/components/MyAccountTag/index.ts +0 -1
- package/src/components/account/orders/MyAccountListOrders/MyAccountFilterSlider/MyAccountFilterFacetDateRange/MyAccountFilterFacetDateRange.tsx +0 -113
- package/src/components/account/orders/MyAccountListOrders/MyAccountFilterSlider/MyAccountFilterFacetDateRange/index.ts +0 -2
- package/src/components/account/orders/MyAccountListOrders/MyAccountFilterSlider/MyAccountFilterFacetPendingApproval/index.ts +0 -2
- package/src/components/account/orders/MyAccountListOrders/MyAccountFilterSlider/index.ts +0 -1
- package/src/components/account/orders/MyAccountListOrders/MyAccountListOrdersTable/index.ts +0 -1
- package/src/components/account/orders/MyAccountListOrders/MyAccountSelectedTags/index.ts +0 -1
- package/src/components/account/orders/MyAccountListOrders/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountBudgetsCard/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountBuyingPolicyAlert/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountDeliveryCard/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountDeliveryOptionAccordion/index.ts +0 -6
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountMoreInformationCard/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountOrderActionModal/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountOrderActions/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountOrderDetails.tsx +0 -136
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountOrderedByCard/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountPaymentCard/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountReorderButton/index.ts +0 -2
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountStatusCard/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/MyAccountSummaryCard/index.ts +0 -1
- package/src/components/account/orders/MyAccountOrderDetails/index.ts +0 -1
- package/src/components/account/profile/i18n.ts +0 -7
- /package/src/components/account/{MyAccountDrawer → Drawer}/OrganizationDrawer/OrganizationDrawer.tsx +0 -0
- /package/src/components/account/{MyAccountDrawer → Drawer}/OrganizationDrawer/OrganizationDrawerHeader.tsx +0 -0
- /package/src/components/account/{MyAccountDrawer → Drawer}/OrganizationDrawer/index.ts +0 -0
- /package/src/components/account/{MyAccountDrawer → Drawer}/OrganizationDrawer/section.module.scss +0 -0
- /package/src/components/account/{MyAccountDrawer → Drawer}/OrganizationDrawer/useReloadAfterLogoutReturn.ts +0 -0
- /package/src/components/account/{MyAccountDrawer → Drawer}/OrganizationSignInButton/index.ts +0 -0
- /package/src/components/account/{MyAccountDrawer → Drawer}/ProfileSummary/profile-summary.scss +0 -0
- /package/src/components/account/{MyAccountMenu → Menu}/styles.scss +0 -0
- /package/src/components/account/components/{MyAccountAccordion → Accordion}/styles.scss +0 -0
- /package/src/components/account/components/{MyAccountCard → Card}/styles.scss +0 -0
- /package/src/components/account/components/{MyAccountHeader → Header}/styles.scss +0 -0
- /package/src/components/account/components/{MyAccountStatusBadge → StatusBadge}/styles.scss +0 -0
- /package/src/components/account/components/{MyAccountTable → Table}/styles.scss +0 -0
- /package/src/components/account/components/{MyAccountTag/MyAccountTag.tsx → Tag/Tag.tsx} +0 -0
- /package/src/components/account/components/{MyAccountTag → Tag}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountListOrders/MyAccountFilterSlider/MyAccountFilterFacetDateRange → ListOrders/FilterSlider/FilterFacetDateRange}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountListOrders/MyAccountFilterSlider/MyAccountFilterFacetPendingApproval → ListOrders/FilterSlider/FilterFacetPendingApproval}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountListOrders/MyAccountListOrdersTable → ListOrders/ListOrdersTable}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountListOrders/MyAccountSelectedTags → ListOrders/SelectedTags}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountBudgetsCard → OrderDetails/BudgetsCard}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountBuyingPolicyAlert → OrderDetails/BuyingPolicyAlert}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountDeliveryCard → OrderDetails/DeliveryCard}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountDeliveryOptionAccordion → OrderDetails/DeliveryOptionAccordion}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountMoreInformationCard → OrderDetails/MoreInformationCard}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountOrderActionModal → OrderDetails/OrderActionModal}/styles.module.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountOrderActions → OrderDetails/OrderActions}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountOrderedByCard → OrderDetails/OrderedByCard}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountPaymentCard → OrderDetails/PaymentCard}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountReorderButton → OrderDetails/ReorderButton}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountStatusCard → OrderDetails/StatusCard}/styles.scss +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountStatusCard → OrderDetails/StatusCard}/useConnectorPositioning.ts +0 -0
- /package/src/components/account/orders/{MyAccountOrderDetails/MyAccountSummaryCard → OrderDetails/SummaryCard}/styles.scss +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { Locator } from '@vtex/client-cms'
|
|
1
|
+
import type { Locator, Section } from '@vtex/client-cms'
|
|
2
2
|
import type { GetServerSideProps } from 'next'
|
|
3
3
|
import { NextSeo } from 'next-seo'
|
|
4
4
|
import type { ComponentType } from 'react'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { Layout } from 'src/components/account'
|
|
6
|
+
import RenderSections, {
|
|
7
|
+
RenderSectionsBase,
|
|
8
|
+
} from 'src/components/cms/RenderSections'
|
|
9
|
+
import ACCOUNT_COMPONENTS from 'src/components/cms/account/Components'
|
|
8
10
|
import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
|
|
9
11
|
import CUSTOM_COMPONENTS from 'src/customizations/src/components'
|
|
10
12
|
|
|
@@ -18,8 +20,12 @@ import type {
|
|
|
18
20
|
import { default as AfterSection } from 'src/customizations/src/myAccount/extensions/profile/after'
|
|
19
21
|
import { default as BeforeSection } from 'src/customizations/src/myAccount/extensions/profile/before'
|
|
20
22
|
import type { MyAccountProps } from 'src/experimental/myAccountServerSideProps'
|
|
23
|
+
import type { AccountProfilePageData } from 'src/sdk/account/accountPageContext'
|
|
24
|
+
import type { AccountNavigationLabels } from 'src/sdk/account/getMyAccountRoutes'
|
|
21
25
|
import { getIsRepresentative } from 'src/sdk/account/getIsRepresentative'
|
|
22
26
|
import { injectGlobalSections } from 'src/server/cms/global'
|
|
27
|
+
import { extractAccountNavigationData } from 'src/server/cms/myAccountDefaultSections'
|
|
28
|
+
import { fetchMyAccountPageContent } from 'src/server/cms/fetchMyAccountPageContent'
|
|
23
29
|
import { getMyAccountRedirect } from 'src/utils/myAccountRedirect'
|
|
24
30
|
import { withLocaleValidationSSR } from 'src/utils/localization/withLocaleValidation'
|
|
25
31
|
|
|
@@ -27,23 +33,22 @@ import storeConfig from 'discovery.config'
|
|
|
27
33
|
import PageProvider from 'src/sdk/overrides/PageProvider'
|
|
28
34
|
import { execute } from 'src/server'
|
|
29
35
|
|
|
30
|
-
/* A list of components that can be used in the CMS. */
|
|
31
36
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
32
37
|
...GLOBAL_COMPONENTS,
|
|
33
38
|
...CUSTOM_COMPONENTS,
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
type ProfilePageProps = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
id: string | null
|
|
41
|
-
}
|
|
42
|
+
pageSections: Section[]
|
|
43
|
+
navigationLabels: AccountNavigationLabels
|
|
44
|
+
accountPageData: AccountProfilePageData
|
|
42
45
|
} & MyAccountProps
|
|
43
46
|
|
|
44
47
|
export default function Profile({
|
|
45
48
|
globalSections: globalSectionsProp,
|
|
46
|
-
|
|
49
|
+
pageSections,
|
|
50
|
+
navigationLabels,
|
|
51
|
+
accountPageData,
|
|
47
52
|
accountName,
|
|
48
53
|
isRepresentative,
|
|
49
54
|
}: ProfilePageProps) {
|
|
@@ -51,18 +56,28 @@ export default function Profile({
|
|
|
51
56
|
globalSectionsProp ?? {}
|
|
52
57
|
|
|
53
58
|
return (
|
|
54
|
-
<PageProvider
|
|
59
|
+
<PageProvider
|
|
60
|
+
context={{
|
|
61
|
+
globalSettings,
|
|
62
|
+
accountPageData,
|
|
63
|
+
navigationLabels,
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
55
66
|
<RenderSections globalSections={globalSections} components={COMPONENTS}>
|
|
56
67
|
<NextSeo noindex nofollow />
|
|
57
68
|
|
|
58
|
-
<
|
|
69
|
+
<Layout
|
|
59
70
|
isRepresentative={isRepresentative}
|
|
60
71
|
accountName={accountName}
|
|
72
|
+
navigationLabels={navigationLabels}
|
|
61
73
|
>
|
|
62
74
|
<BeforeSection />
|
|
63
|
-
<
|
|
75
|
+
<RenderSectionsBase
|
|
76
|
+
sections={pageSections}
|
|
77
|
+
components={ACCOUNT_COMPONENTS}
|
|
78
|
+
/>
|
|
64
79
|
<AfterSection />
|
|
65
|
-
</
|
|
80
|
+
</Layout>
|
|
66
81
|
</RenderSections>
|
|
67
82
|
</PageProvider>
|
|
68
83
|
)
|
|
@@ -79,7 +94,7 @@ const query = gql(`
|
|
|
79
94
|
`)
|
|
80
95
|
|
|
81
96
|
const getServerSidePropsBase: GetServerSideProps<
|
|
82
|
-
|
|
97
|
+
ProfilePageProps,
|
|
83
98
|
Record<string, string>,
|
|
84
99
|
Locator
|
|
85
100
|
> = async (context) => {
|
|
@@ -106,27 +121,35 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
106
121
|
globalSectionsFooterPromise,
|
|
107
122
|
] = getGlobalSectionsData(contentContext)
|
|
108
123
|
|
|
109
|
-
const [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
const [
|
|
125
|
+
pageContent,
|
|
126
|
+
profile,
|
|
127
|
+
globalSections,
|
|
128
|
+
globalSectionsHeader,
|
|
129
|
+
globalSectionsFooter,
|
|
130
|
+
] = await Promise.all([
|
|
131
|
+
fetchMyAccountPageContent(
|
|
132
|
+
'myAccountProfile',
|
|
133
|
+
contentContext,
|
|
134
|
+
'/pvt/account/profile'
|
|
135
|
+
),
|
|
136
|
+
execute<ServerProfileQueryQueryVariables, ServerProfileQueryQuery>(
|
|
137
|
+
{
|
|
138
|
+
variables: {},
|
|
139
|
+
operation: query,
|
|
140
|
+
},
|
|
141
|
+
{ headers: { ...context.req.headers } }
|
|
142
|
+
),
|
|
143
|
+
globalSectionsPromise,
|
|
144
|
+
globalSectionsHeaderPromise,
|
|
145
|
+
globalSectionsFooterPromise,
|
|
146
|
+
])
|
|
122
147
|
|
|
123
148
|
if (profile.errors) {
|
|
124
149
|
console.error(...profile.errors)
|
|
125
150
|
|
|
126
151
|
const statusCode: number = (profile.errors[0] as any)?.extensions?.status
|
|
127
152
|
|
|
128
|
-
// Redirect to 403 for authentication errors (401/403) to handle token refresh
|
|
129
|
-
// Redirect to 404 for other errors
|
|
130
153
|
const destination: string =
|
|
131
154
|
statusCode === 401 || statusCode === 403
|
|
132
155
|
? `/pvt/account/403?from=${encodeURIComponent('/pvt/account/profile')}`
|
|
@@ -140,6 +163,10 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
140
163
|
}
|
|
141
164
|
}
|
|
142
165
|
|
|
166
|
+
const { pageSections, navigationData } = extractAccountNavigationData(
|
|
167
|
+
pageContent.sections
|
|
168
|
+
)
|
|
169
|
+
|
|
143
170
|
const globalSectionsResult = injectGlobalSections({
|
|
144
171
|
globalSections,
|
|
145
172
|
globalSectionsHeader,
|
|
@@ -149,8 +176,12 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
149
176
|
return {
|
|
150
177
|
props: {
|
|
151
178
|
globalSections: globalSectionsResult,
|
|
152
|
-
accountName: profile.data.accountProfile.name,
|
|
153
|
-
|
|
179
|
+
accountName: profile.data.accountProfile.name ?? '',
|
|
180
|
+
accountPageData: {
|
|
181
|
+
profile: profile.data.accountProfile,
|
|
182
|
+
},
|
|
183
|
+
pageSections,
|
|
184
|
+
navigationLabels: navigationData as AccountNavigationLabels,
|
|
154
185
|
isRepresentative,
|
|
155
186
|
},
|
|
156
187
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import type { Locator, Section } from '@vtex/client-cms'
|
|
2
|
+
import type { GetServerSideProps } from 'next'
|
|
1
3
|
import { NextSeo } from 'next-seo'
|
|
2
4
|
import type { ComponentType } from 'react'
|
|
3
|
-
import {
|
|
4
|
-
import RenderSections
|
|
5
|
+
import { Layout } from 'src/components/account'
|
|
6
|
+
import RenderSections, {
|
|
7
|
+
RenderSectionsBase,
|
|
8
|
+
} from 'src/components/cms/RenderSections'
|
|
9
|
+
import ACCOUNT_COMPONENTS from 'src/components/cms/account/Components'
|
|
5
10
|
import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
|
|
6
11
|
import CUSTOM_COMPONENTS from 'src/customizations/src/components'
|
|
7
12
|
|
|
8
|
-
import type { Locator } from '@vtex/client-cms'
|
|
9
|
-
import type { GetServerSideProps } from 'next'
|
|
10
|
-
|
|
11
13
|
import { getGlobalSectionsData } from 'src/components/cms/GlobalSections'
|
|
12
14
|
|
|
13
15
|
import { gql } from '@generated/gql'
|
|
@@ -18,50 +20,65 @@ import type {
|
|
|
18
20
|
import { default as AfterSection } from 'src/customizations/src/myAccount/extensions/security/after'
|
|
19
21
|
import { default as BeforeSection } from 'src/customizations/src/myAccount/extensions/security/before'
|
|
20
22
|
import type { MyAccountProps } from 'src/experimental/myAccountServerSideProps'
|
|
23
|
+
import type { AccountSecurityPageData } from 'src/sdk/account/accountPageContext'
|
|
24
|
+
import type { AccountNavigationLabels } from 'src/sdk/account/getMyAccountRoutes'
|
|
21
25
|
import { getIsRepresentative } from 'src/sdk/account/getIsRepresentative'
|
|
22
26
|
import { execute } from 'src/server'
|
|
23
27
|
import { injectGlobalSections } from 'src/server/cms/global'
|
|
28
|
+
import { extractAccountNavigationData } from 'src/server/cms/myAccountDefaultSections'
|
|
29
|
+
import { fetchMyAccountPageContent } from 'src/server/cms/fetchMyAccountPageContent'
|
|
24
30
|
import { getMyAccountRedirect } from 'src/utils/myAccountRedirect'
|
|
25
31
|
import { withLocaleValidationSSR } from 'src/utils/localization/withLocaleValidation'
|
|
26
32
|
|
|
27
33
|
import PageProvider from 'src/sdk/overrides/PageProvider'
|
|
28
34
|
|
|
29
35
|
import storeConfig from 'discovery.config'
|
|
30
|
-
import { SecuritySection } from 'src/components/account/security'
|
|
31
36
|
|
|
32
|
-
/* A list of components that can be used in the CMS. */
|
|
33
37
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
34
38
|
...GLOBAL_COMPONENTS,
|
|
35
39
|
...CUSTOM_COMPONENTS,
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
type SecurityPageProps = {
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
pageSections: Section[]
|
|
44
|
+
navigationLabels: AccountNavigationLabels
|
|
45
|
+
accountPageData: AccountSecurityPageData
|
|
41
46
|
} & MyAccountProps
|
|
42
47
|
|
|
43
48
|
export default function Page({
|
|
44
49
|
globalSections: globalSectionsProp,
|
|
50
|
+
pageSections,
|
|
51
|
+
navigationLabels,
|
|
52
|
+
accountPageData,
|
|
45
53
|
accountName,
|
|
46
54
|
isRepresentative,
|
|
47
|
-
userEmail,
|
|
48
55
|
}: SecurityPageProps) {
|
|
49
56
|
const { sections: globalSections, settings: globalSettings } =
|
|
50
57
|
globalSectionsProp ?? {}
|
|
51
58
|
|
|
52
59
|
return (
|
|
53
|
-
<PageProvider
|
|
60
|
+
<PageProvider
|
|
61
|
+
context={{
|
|
62
|
+
globalSettings,
|
|
63
|
+
accountPageData,
|
|
64
|
+
navigationLabels,
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
54
67
|
<RenderSections globalSections={globalSections} components={COMPONENTS}>
|
|
55
68
|
<NextSeo noindex nofollow />
|
|
56
69
|
|
|
57
|
-
<
|
|
70
|
+
<Layout
|
|
58
71
|
isRepresentative={isRepresentative}
|
|
59
72
|
accountName={accountName}
|
|
73
|
+
navigationLabels={navigationLabels}
|
|
60
74
|
>
|
|
61
75
|
<BeforeSection />
|
|
62
|
-
<
|
|
76
|
+
<RenderSectionsBase
|
|
77
|
+
sections={pageSections}
|
|
78
|
+
components={ACCOUNT_COMPONENTS}
|
|
79
|
+
/>
|
|
63
80
|
<AfterSection />
|
|
64
|
-
</
|
|
81
|
+
</Layout>
|
|
65
82
|
</RenderSections>
|
|
66
83
|
</PageProvider>
|
|
67
84
|
)
|
|
@@ -79,7 +96,7 @@ const query = gql(`
|
|
|
79
96
|
`)
|
|
80
97
|
|
|
81
98
|
const getServerSidePropsBase: GetServerSideProps<
|
|
82
|
-
|
|
99
|
+
SecurityPageProps,
|
|
83
100
|
Record<string, string>,
|
|
84
101
|
Locator
|
|
85
102
|
> = async (context) => {
|
|
@@ -95,6 +112,7 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
95
112
|
if (!isFaststoreMyAccountEnabled) {
|
|
96
113
|
return { redirect }
|
|
97
114
|
}
|
|
115
|
+
|
|
98
116
|
const contentContext = {
|
|
99
117
|
previewData: context.previewData,
|
|
100
118
|
locale: context.locale,
|
|
@@ -106,26 +124,34 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
106
124
|
globalSectionsFooterPromise,
|
|
107
125
|
] = getGlobalSectionsData(contentContext)
|
|
108
126
|
|
|
109
|
-
const [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
const [
|
|
128
|
+
pageContent,
|
|
129
|
+
security,
|
|
130
|
+
globalSections,
|
|
131
|
+
globalSectionsHeader,
|
|
132
|
+
globalSectionsFooter,
|
|
133
|
+
] = await Promise.all([
|
|
134
|
+
fetchMyAccountPageContent(
|
|
135
|
+
'myAccountSecurity',
|
|
136
|
+
contentContext,
|
|
137
|
+
'/pvt/account/security'
|
|
138
|
+
),
|
|
139
|
+
execute<ServerSecurityQueryVariables, ServerSecurityQuery>(
|
|
140
|
+
{
|
|
141
|
+
variables: {},
|
|
142
|
+
operation: query,
|
|
143
|
+
},
|
|
144
|
+
{ headers: { ...context.req.headers } }
|
|
145
|
+
),
|
|
146
|
+
globalSectionsPromise,
|
|
147
|
+
globalSectionsHeaderPromise,
|
|
148
|
+
globalSectionsFooterPromise,
|
|
149
|
+
])
|
|
122
150
|
|
|
123
151
|
if (security.errors) {
|
|
124
152
|
console.error(...security.errors)
|
|
125
153
|
const statusCode: number = (security.errors[0] as any)?.extensions?.status
|
|
126
154
|
|
|
127
|
-
// Redirect to 403 for authentication errors (401/403) to handle token refresh
|
|
128
|
-
// Redirect to 404 for other errors
|
|
129
155
|
const destination: string =
|
|
130
156
|
statusCode === 401 || statusCode === 403
|
|
131
157
|
? `/pvt/account/403?from=${encodeURIComponent('/pvt/account/security')}`
|
|
@@ -139,6 +165,10 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
139
165
|
}
|
|
140
166
|
}
|
|
141
167
|
|
|
168
|
+
const { pageSections, navigationData } = extractAccountNavigationData(
|
|
169
|
+
pageContent.sections
|
|
170
|
+
)
|
|
171
|
+
|
|
142
172
|
const globalSectionsResult = injectGlobalSections({
|
|
143
173
|
globalSections,
|
|
144
174
|
globalSectionsHeader,
|
|
@@ -147,9 +177,13 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
147
177
|
|
|
148
178
|
return {
|
|
149
179
|
props: {
|
|
150
|
-
accountName: security.data.accountProfile.name,
|
|
151
|
-
|
|
180
|
+
accountName: security.data.accountProfile.name ?? '',
|
|
181
|
+
navigationLabels: navigationData as AccountNavigationLabels,
|
|
182
|
+
accountPageData: {
|
|
183
|
+
userEmail: security.data?.userDetails?.email || '',
|
|
184
|
+
},
|
|
152
185
|
globalSections: globalSectionsResult,
|
|
186
|
+
pageSections,
|
|
153
187
|
isRepresentative,
|
|
154
188
|
},
|
|
155
189
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import type { Locator, Section } from '@vtex/client-cms'
|
|
2
|
+
import type { GetServerSideProps } from 'next'
|
|
1
3
|
import { NextSeo } from 'next-seo'
|
|
2
4
|
import type { ComponentType } from 'react'
|
|
3
|
-
import {
|
|
4
|
-
import RenderSections
|
|
5
|
+
import { Layout } from 'src/components/account'
|
|
6
|
+
import RenderSections, {
|
|
7
|
+
RenderSectionsBase,
|
|
8
|
+
} from 'src/components/cms/RenderSections'
|
|
9
|
+
import ACCOUNT_COMPONENTS from 'src/components/cms/account/Components'
|
|
5
10
|
import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
|
|
6
11
|
import CUSTOM_COMPONENTS from 'src/customizations/src/components'
|
|
7
12
|
|
|
8
|
-
import type { Locator } from '@vtex/client-cms'
|
|
9
|
-
import type { GetServerSideProps } from 'next'
|
|
10
|
-
|
|
11
13
|
import { getGlobalSectionsData } from 'src/components/cms/GlobalSections'
|
|
12
14
|
|
|
13
15
|
import { gql } from '@generated/gql'
|
|
@@ -16,56 +18,65 @@ import type {
|
|
|
16
18
|
ServerUserDetailsQueryQueryVariables,
|
|
17
19
|
} from '@generated/graphql'
|
|
18
20
|
import storeConfig from 'discovery.config'
|
|
19
|
-
import MyAccountUserDetails from 'src/components/account/MyAccountUserDetails/MyAccountUserDetails'
|
|
20
21
|
import { default as AfterSection } from 'src/customizations/src/myAccount/extensions/user-details/after'
|
|
21
22
|
import { default as BeforeSection } from 'src/customizations/src/myAccount/extensions/user-details/before'
|
|
22
23
|
import type { MyAccountProps } from 'src/experimental/myAccountServerSideProps'
|
|
24
|
+
import type { AccountUserDetailsPageData } from 'src/sdk/account/accountPageContext'
|
|
25
|
+
import type { AccountNavigationLabels } from 'src/sdk/account/getMyAccountRoutes'
|
|
23
26
|
import { getIsRepresentative } from 'src/sdk/account/getIsRepresentative'
|
|
24
27
|
import PageProvider from 'src/sdk/overrides/PageProvider'
|
|
25
28
|
import { execute } from 'src/server'
|
|
26
29
|
import { injectGlobalSections } from 'src/server/cms/global'
|
|
30
|
+
import { extractAccountNavigationData } from 'src/server/cms/myAccountDefaultSections'
|
|
31
|
+
import { fetchMyAccountPageContent } from 'src/server/cms/fetchMyAccountPageContent'
|
|
27
32
|
import { getMyAccountRedirect } from 'src/utils/myAccountRedirect'
|
|
28
33
|
import { withLocaleValidationSSR } from 'src/utils/localization/withLocaleValidation'
|
|
29
34
|
|
|
30
|
-
/* A list of components that can be used in the CMS. */
|
|
31
35
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
32
36
|
...GLOBAL_COMPONENTS,
|
|
33
37
|
...CUSTOM_COMPONENTS,
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
type
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
email: string
|
|
41
|
-
phone: string
|
|
42
|
-
role: string[]
|
|
43
|
-
orgUnit: string
|
|
44
|
-
}
|
|
40
|
+
type UserDetailsPageProps = {
|
|
41
|
+
pageSections: Section[]
|
|
42
|
+
navigationLabels: AccountNavigationLabels
|
|
43
|
+
accountPageData: AccountUserDetailsPageData
|
|
45
44
|
} & MyAccountProps
|
|
46
45
|
|
|
47
46
|
export default function Page({
|
|
48
47
|
globalSections: globalSectionsProp,
|
|
48
|
+
pageSections,
|
|
49
|
+
navigationLabels,
|
|
50
|
+
accountPageData,
|
|
49
51
|
accountName,
|
|
50
52
|
isRepresentative,
|
|
51
|
-
|
|
52
|
-
}: UserDetailsPagePros) {
|
|
53
|
+
}: UserDetailsPageProps) {
|
|
53
54
|
const { sections: globalSections, settings: globalSettings } =
|
|
54
55
|
globalSectionsProp ?? {}
|
|
55
56
|
|
|
56
57
|
return (
|
|
57
|
-
<PageProvider
|
|
58
|
+
<PageProvider
|
|
59
|
+
context={{
|
|
60
|
+
globalSettings,
|
|
61
|
+
accountPageData,
|
|
62
|
+
navigationLabels,
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
58
65
|
<RenderSections globalSections={globalSections} components={COMPONENTS}>
|
|
59
66
|
<NextSeo noindex nofollow />
|
|
60
67
|
|
|
61
|
-
<
|
|
68
|
+
<Layout
|
|
62
69
|
isRepresentative={isRepresentative}
|
|
63
70
|
accountName={accountName}
|
|
71
|
+
navigationLabels={navigationLabels}
|
|
64
72
|
>
|
|
65
73
|
<BeforeSection />
|
|
66
|
-
<
|
|
74
|
+
<RenderSectionsBase
|
|
75
|
+
sections={pageSections}
|
|
76
|
+
components={ACCOUNT_COMPONENTS}
|
|
77
|
+
/>
|
|
67
78
|
<AfterSection />
|
|
68
|
-
</
|
|
79
|
+
</Layout>
|
|
69
80
|
</RenderSections>
|
|
70
81
|
</PageProvider>
|
|
71
82
|
)
|
|
@@ -88,7 +99,7 @@ const query = gql(`
|
|
|
88
99
|
`)
|
|
89
100
|
|
|
90
101
|
const getServerSidePropsBase: GetServerSideProps<
|
|
91
|
-
|
|
102
|
+
UserDetailsPageProps,
|
|
92
103
|
Record<string, string>,
|
|
93
104
|
Locator
|
|
94
105
|
> = async (context) => {
|
|
@@ -104,6 +115,16 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
104
115
|
if (!isFaststoreMyAccountEnabled) {
|
|
105
116
|
return { redirect }
|
|
106
117
|
}
|
|
118
|
+
|
|
119
|
+
if (!isRepresentative) {
|
|
120
|
+
return {
|
|
121
|
+
redirect: {
|
|
122
|
+
destination: '/pvt/account',
|
|
123
|
+
permanent: false,
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
107
128
|
const contentContext = {
|
|
108
129
|
previewData: context.previewData,
|
|
109
130
|
locale: context.locale,
|
|
@@ -116,11 +137,17 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
116
137
|
] = getGlobalSectionsData(contentContext)
|
|
117
138
|
|
|
118
139
|
const [
|
|
140
|
+
pageContent,
|
|
119
141
|
userDetails,
|
|
120
142
|
globalSections,
|
|
121
143
|
globalSectionsHeader,
|
|
122
144
|
globalSectionsFooter,
|
|
123
145
|
] = await Promise.all([
|
|
146
|
+
fetchMyAccountPageContent(
|
|
147
|
+
'myAccountUserDetails',
|
|
148
|
+
contentContext,
|
|
149
|
+
'/pvt/account/user-details'
|
|
150
|
+
),
|
|
124
151
|
execute<ServerUserDetailsQueryQueryVariables, ServerUserDetailsQueryQuery>(
|
|
125
152
|
{
|
|
126
153
|
variables: {},
|
|
@@ -135,24 +162,12 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
135
162
|
globalSectionsFooterPromise,
|
|
136
163
|
])
|
|
137
164
|
|
|
138
|
-
// If the user is not a representative (b2b), redirect them to the account home page
|
|
139
|
-
if (!isRepresentative) {
|
|
140
|
-
return {
|
|
141
|
-
redirect: {
|
|
142
|
-
destination: '/pvt/account',
|
|
143
|
-
permanent: false,
|
|
144
|
-
},
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
165
|
if (userDetails?.errors) {
|
|
149
166
|
console.error(...userDetails.errors)
|
|
150
167
|
|
|
151
168
|
const statusCode: number = (userDetails.errors[0] as any)?.extensions
|
|
152
169
|
?.status
|
|
153
170
|
|
|
154
|
-
// Redirect to 403 for authentication errors (401/403) to handle token refresh
|
|
155
|
-
// Redirect to 404 for other errors
|
|
156
171
|
const destination: string =
|
|
157
172
|
statusCode === 401 || statusCode === 403
|
|
158
173
|
? `/pvt/account/403?from=${encodeURIComponent('/pvt/account/user-details')}`
|
|
@@ -166,6 +181,10 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
166
181
|
}
|
|
167
182
|
}
|
|
168
183
|
|
|
184
|
+
const { pageSections, navigationData } = extractAccountNavigationData(
|
|
185
|
+
pageContent.sections
|
|
186
|
+
)
|
|
187
|
+
|
|
169
188
|
const globalSectionsResult = injectGlobalSections({
|
|
170
189
|
globalSections,
|
|
171
190
|
globalSectionsHeader,
|
|
@@ -175,8 +194,19 @@ const getServerSidePropsBase: GetServerSideProps<
|
|
|
175
194
|
return {
|
|
176
195
|
props: {
|
|
177
196
|
globalSections: globalSectionsResult,
|
|
178
|
-
accountName: userDetails.data.accountProfile.name,
|
|
179
|
-
|
|
197
|
+
accountName: userDetails.data.accountProfile.name ?? '',
|
|
198
|
+
navigationLabels: navigationData as AccountNavigationLabels,
|
|
199
|
+
accountPageData: {
|
|
200
|
+
userDetails: userDetails.data?.userDetails ?? {
|
|
201
|
+
username: '',
|
|
202
|
+
name: '',
|
|
203
|
+
email: '',
|
|
204
|
+
phone: '',
|
|
205
|
+
role: [],
|
|
206
|
+
orgUnit: '',
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
pageSections,
|
|
180
210
|
isRepresentative,
|
|
181
211
|
},
|
|
182
212
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ServerListOrdersQueryQuery,
|
|
3
|
+
ServerOrderDetailsQueryQuery,
|
|
4
|
+
ServerProfileQueryQuery,
|
|
5
|
+
} from '@generated/graphql'
|
|
6
|
+
import type { PageGlobalContext } from 'src/sdk/overrides/PageProvider'
|
|
7
|
+
import { usePage } from 'src/sdk/overrides/PageProvider'
|
|
8
|
+
import type { OrderStatusCmsLabels } from 'src/utils/userOrderStatus'
|
|
9
|
+
import type { AccountNavigationLabels } from './getMyAccountRoutes'
|
|
10
|
+
|
|
11
|
+
export type AccountProfilePageData = {
|
|
12
|
+
profile: ServerProfileQueryQuery['accountProfile']
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type AccountOrdersListPageData = {
|
|
16
|
+
listOrders: ServerListOrdersQueryQuery['listUserOrders']
|
|
17
|
+
total: number
|
|
18
|
+
perPage: number
|
|
19
|
+
filters: {
|
|
20
|
+
page: number
|
|
21
|
+
status: string[]
|
|
22
|
+
dateInitial: string
|
|
23
|
+
dateFinal: string
|
|
24
|
+
text: string
|
|
25
|
+
clientEmail: string
|
|
26
|
+
pendingMyApproval?: boolean
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type AccountOrderDetailsPageData = {
|
|
31
|
+
order: ServerOrderDetailsQueryQuery['userOrder']
|
|
32
|
+
orderStatusLabels?: OrderStatusCmsLabels
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type AccountSecurityPageData = {
|
|
36
|
+
userEmail: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type AccountUserDetailsPageData = {
|
|
40
|
+
userDetails: {
|
|
41
|
+
username: string
|
|
42
|
+
name: string
|
|
43
|
+
email: string
|
|
44
|
+
phone: string
|
|
45
|
+
role: string[]
|
|
46
|
+
orgUnit: string
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type AccountPageData =
|
|
51
|
+
| AccountProfilePageData
|
|
52
|
+
| AccountOrdersListPageData
|
|
53
|
+
| AccountOrderDetailsPageData
|
|
54
|
+
| AccountSecurityPageData
|
|
55
|
+
| AccountUserDetailsPageData
|
|
56
|
+
| Record<string, never>
|
|
57
|
+
|
|
58
|
+
export interface AccountPageContext extends PageGlobalContext {
|
|
59
|
+
accountPageData: AccountPageData
|
|
60
|
+
navigationLabels?: AccountNavigationLabels
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function useAccountNavigationLabels() {
|
|
64
|
+
const ctx = usePage<AccountPageContext>()
|
|
65
|
+
return ctx.navigationLabels
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function useAccountPageData<
|
|
69
|
+
T extends AccountPageData = AccountPageData,
|
|
70
|
+
>(): T {
|
|
71
|
+
const ctx = usePage<AccountPageContext>()
|
|
72
|
+
return ctx.accountPageData as T
|
|
73
|
+
}
|