Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
831af23
chore: updates husky to allow "address-mgmt/" branch pattern
mohitb35 Nov 5, 2024
a93545e
refactor: set up story for single address
sunilsabatp Nov 5, 2024
47abd98
feat: story for address list
sunilsabatp Nov 6, 2024
2fbe97f
feat: ui of address action popup
sunilsabatp Nov 7, 2024
71440bb
feat: once a action is selected close the action modal
sunilsabatp Nov 7, 2024
6eb041c
refactor: clean up unused utils, update address action config
sunilsabatp Nov 7, 2024
5cd3ec4
feat: add UI for adding addresses
sunilsabatp Nov 9, 2024
a210e25
refactor: move adddress management folder to edit profile section, up…
sunilsabatp Nov 9, 2024
804ebd4
feat: add new address button UI
sunilsabatp Nov 9, 2024
abf402a
refactor: consolidate translation resources
sunilsabatp Nov 9, 2024
667ba5e
fix: translation issue
sunilsabatp Nov 10, 2024
b0a716a
feat: integrate the api
sunilsabatp Nov 11, 2024
2b83ef2
merge: merge base branch, consolidate translation
sunilsabatp Nov 11, 2024
a6d09e1
feat: use modal for add new address form
sunilsabatp Nov 11, 2024
8948142
feat: debounce address suggestions to improve performance
sunilsabatp Nov 12, 2024
b2e639b
feat: introduce a simple spinner for address mgmt form
sunilsabatp Nov 12, 2024
ae8575e
refactor(forms): create reusable AddressInput component
sunilsabatp Nov 12, 2024
c5c62f7
style: adjust min-width for address form container
sunilsabatp Nov 12, 2024
fd99142
feat: update add address form to make it work as edit address form.
sunilsabatp Nov 13, 2024
f840a58
feat: add api call to fetch user addresses
sunilsabatp Nov 13, 2024
1eff9ad
feat: add a space between 2 and ( for Address 2(optional)
sunilsabatp Nov 13, 2024
cfd513d
feat: set address type modal UI
sunilsabatp Nov 13, 2024
26c7cd3
feat: modify the edit address api to handle change address type
sunilsabatp Nov 14, 2024
7a29a2b
feat: component rename for better clarity
sunilsabatp Nov 14, 2024
dbdc164
feat: implement delete action & lift state management
sunilsabatp Nov 14, 2024
3dfea1f
refactor: refactor translations, optimize address selection, and defi…
sunilsabatp Nov 16, 2024
7ea7126
refactor singleAddress component: simplify address formatting, optimi…
sunilsabatp Nov 17, 2024
1afb426
refactor: modularize address management styles using scss mixins and …
sunilsabatp Nov 20, 2024
cb98e06
refactor: clean up address related code in edit profile component
sunilsabatp Nov 20, 2024
ab12086
refactor: minor width adjustment.
sunilsabatp Nov 20, 2024
9ccd86f
refactor: group translation resources base on their use
sunilsabatp Nov 21, 2024
2801e9b
refactor: avoid using multiple DashboardView in the edit profile page
sunilsabatp Nov 21, 2024
40eb901
refactor: remove the stories
sunilsabatp Nov 21, 2024
d6b2a9b
refactor: rename variables
sunilsabatp Nov 21, 2024
d9aeb69
refactor: minor width adjustment for the button,address tag
sunilsabatp Nov 21, 2024
dd0f6f7
Merge branch 'address-mgmt/single-address-story' into address-mgmt/ad…
sunilsabatp Nov 21, 2024
03dc974
refactor: minor change in styling in the form button container
sunilsabatp Nov 21, 2024
8b7b544
refactor: extract form input's into a seperate component.
sunilsabatp Nov 21, 2024
c4edd1f
refactor: renaming of helper function, render add address form condit…
sunilsabatp Nov 22, 2024
229bffb
Merge branch 'address-mgmt/add-address-form' into address-mgmt/edit-a…
sunilsabatp Nov 22, 2024
39b53e1
refactor: shift the edit form to the root component
sunilsabatp Nov 22, 2024
a4d058a
feat: avoid using profile response addresses
sunilsabatp Nov 22, 2024
949f36c
refactor: use switch case to render modal content, remove unneeded ut…
sunilsabatp Nov 22, 2024
4be3b81
merge: merge base branch, shift setAddressType(primary,billing) moda…
sunilsabatp Nov 22, 2024
13311ac
refactor: shift address delete modal to the root component
sunilsabatp Nov 22, 2024
b16d705
refactor: simplify AddressTypeConfirmationModal component
sunilsabatp Nov 22, 2024
dbab76a
refactor: format address details to render address 2, minor code cl…
sunilsabatp Nov 24, 2024
77af5eb
refactor: move type definitions to d.ts file and improve addressList …
sunilsabatp Nov 24, 2024
9fd2ab3
chore : update planet-sdk/common package
sunilsabatp Nov 24, 2024
1afc9f2
Merge branch 'develop' into feature/address-mgmt
sunilsabatp Nov 24, 2024
39ce8e9
Merge branch 'feature/address-mgmt' into address-mgmt/single-address-…
sunilsabatp Nov 24, 2024
08db197
refactor: resolve merge conflicts
sunilsabatp Nov 24, 2024
0140fe1
Merge branch 'feature/address-mgmt' into address-mgmt/single-address-…
sunilsabatp Nov 24, 2024
93cd555
refactor: use user address type from planet-sdk/common
sunilsabatp Nov 24, 2024
69701c7
refactor: corrected typo: "kabab" to "kebab" across all affected files,
sunilsabatp Nov 24, 2024
c2d581c
refactor: merge base branch, resolve conflict
sunilsabatp Nov 25, 2024
7ea1906
Merge branch 'address-mgmt/add-address-form' into address-mgmt/edit-a…
sunilsabatp Nov 25, 2024
4a5f0e4
Merge branch 'address-mgmt/edit-address-form' into address-mgmt/addre…
sunilsabatp Nov 25, 2024
aaa5848
refactor: simplify address formatting logic,
sunilsabatp Nov 25, 2024
df3db69
feat: add FormattedAddressBlock component to display user address
sunilsabatp Nov 25, 2024
ea0228b
refactor: rename variable, and wrap the fetchUserAddresses function i…
sunilsabatp Nov 25, 2024
f82fd28
refactor: consistent type import
sunilsabatp Nov 25, 2024
5299b88
Merge branch 'address-mgmt/add-address-form' into address-mgmt/edit-a…
sunilsabatp Nov 25, 2024
ccc8ce4
refactor: merge base branch, resolve conflicts
sunilsabatp Nov 25, 2024
8301648
refactor: remove duplicate import
sunilsabatp Nov 25, 2024
ceae2b3
refactor: seperate out edit address form.
sunilsabatp Nov 26, 2024
75bb560
refactor: remove the edit address form logic from the add address form
sunilsabatp Nov 26, 2024
417554f
refactor: move early return condition to the top for better readabili…
sunilsabatp Nov 26, 2024
3cc0406
refactor: address feedbacks
sunilsabatp Nov 26, 2024
2991b43
refactor: consistent type import
sunilsabatp Nov 26, 2024
25860aa
docs: add documentation for geocoding functions: suggestAddress and f…
sunilsabatp Nov 26, 2024
bc1aeae
Merge branch 'address-mgmt/single-address-story' into address-mgmt/ed…
sunilsabatp Nov 26, 2024
ce39b5d
fix: update margin-top for address management styles
mohitb35 Nov 26, 2024
2462e84
refactor: move helper function to the utils file
sunilsabatp Nov 26, 2024
1afe8c0
Merge branch 'address-mgmt/single-address-story' into address-mgmt/ed…
sunilsabatp Nov 26, 2024
0e60fac
refactor: early return if token is missing
sunilsabatp Nov 26, 2024
f95a383
Merge pull request #2289 from Plant-for-the-Planet-org/address-mgmt/s…
sunilsabatp Nov 26, 2024
eb6896e
Merge branch 'address-mgmt/edit-address-form' into address-mgmt/addre…
sunilsabatp Nov 26, 2024
64f7351
refactor: minor ui fixes
sunilsabatp Nov 26, 2024
9d258ef
Merge branch 'address-mgmt/address-actions' into address-mgmt/code-cl…
sunilsabatp Nov 27, 2024
917756c
refactor(styles): use flex-container mixin for consistent layout styling
sunilsabatp Nov 27, 2024
7dfa3e5
feat: add address limit check and show message when limit is reached
sunilsabatp Nov 27, 2024
0c35ec5
refactor: remove unneeded space.
sunilsabatp Nov 27, 2024
e5ce25f
refactor: Initialize userAddresses state with profile addresses.
sunilsabatp Nov 28, 2024
fe263b6
refactor: rename tProfile to tAddressManagement
sunilsabatp Nov 28, 2024
0c7d439
refactor(address-form): centralize handlers and buttons, improve reus…
sunilsabatp Nov 29, 2024
8dc1266
fix: handle cases where the user has no address
sunilsabatp Nov 29, 2024
7ece720
refactor: consolidate translation resources
sunilsabatp Nov 29, 2024
911deac
refactor: initialize country state with prioritized userCountry value
sunilsabatp Nov 29, 2024
6df7098
Merge branch 'address-mgmt/edit-address-form' into address-mgmt/addre…
sunilsabatp Nov 29, 2024
17dd921
Merge branch 'address-mgmt/address-actions' into address-mgmt/code-cl…
sunilsabatp Nov 29, 2024
36a67d6
refactor: address the feedbacks.
sunilsabatp Dec 2, 2024
f69fd7b
Merge branch 'address-mgmt/edit-address-form' into address-mgmt/addre…
sunilsabatp Dec 2, 2024
062dac1
Merge pull request #2307 from Plant-for-the-Planet-org/address-mgmt/e…
sunilsabatp Dec 2, 2024
9ff8673
refactor: remove unneeded files
sunilsabatp Dec 2, 2024
6523041
Merge branch 'feature/address-mgmt' into address-mgmt/address-actions
sunilsabatp Dec 2, 2024
3837dc7
refactor: rename component/function/props.
sunilsabatp Dec 4, 2024
6783400
"refactor: reset addressAction state when the modal is opened or closed
sunilsabatp Dec 4, 2024
075a427
refactor: minor code clean up
sunilsabatp Dec 4, 2024
9e154b6
refactor: simplify translation interpolation
sunilsabatp Dec 4, 2024
ef5ce97
refactor: rename tProfile to tAddressManagement
sunilsabatp Dec 4, 2024
43054c8
refactor: define constant for max address limit
sunilsabatp Dec 4, 2024
035c34e
refactor: update address confirmation messages for clarity and structure
mohitb35 Dec 4, 2024
b64c57f
fix: corrects import path for ADDRESS_ACTIONS while creating AddressA…
mohitb35 Dec 4, 2024
14762b8
Merge branch 'address-mgmt/address-actions' into address-mgmt/address…
sunilsabatp Dec 4, 2024
1525e50
Merge pull request #2308 from Plant-for-the-Planet-org/address-mgmt/a…
sunilsabatp Dec 4, 2024
0a47487
Merge branch 'feature/address-mgmt' into address-mgmt/address-max-limit
sunilsabatp Dec 4, 2024
551b72c
Merge pull request #2316 from Plant-for-the-Planet-org/address-mgmt/a…
sunilsabatp Dec 4, 2024
ade9fff
Merge branch 'feature/address-mgmt' into address-mgmt/code-clean-up
sunilsabatp Dec 4, 2024
6ade3b0
Merge branch 'feature/address-mgmt' into address-mgmt/code-clean-up
sunilsabatp Dec 4, 2024
630d5d3
Merge pull request #2312 from Plant-for-the-Planet-org/address-mgmt/c…
sunilsabatp Dec 4, 2024
8ade0d7
refactor: replace SCSS variables with direct values
sunilsabatp Dec 4, 2024
2e31276
refactor: group the addressManagement translation resources.
sunilsabatp Dec 5, 2024
0b02f0e
refactor: organize address management translation keys for consistency
mohitb35 Dec 6, 2024
4b28506
Merge pull request #2323 from Plant-for-the-Planet-org/address-mgmt/s…
sunilsabatp Dec 6, 2024
e5e093f
feat: add unset billing address option to the address action menu.
sunilsabatp Dec 11, 2024
bfe457d
feat: hide delete option for primary address
sunilsabatp Dec 11, 2024
9c9ac78
Merge pull request #2330 from Plant-for-the-Planet-org/address-mgmt/r…
mohitb35 Dec 11, 2024
e1b69ad
refactor: address coderabbit points
sunilsabatp Dec 12, 2024
f2838b1
refactor: address the code rabbit points
sunilsabatp Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prepare": "node ./husky-prepare.js"
},
"validate-branch-name": {
"pattern": "^(main|develop){1}$|^(feature|hotfix|projects-redesign)/[a-z0-9-_]+$",
"pattern": "^(main|develop){1}$|^(feature|hotfix|address-mgmt)/[a-z0-9-_]+$",
"errorMsg": "Invalid branch name. \n 1.Branch names can contain lowercase characters, numbers, hyphen and underscore. \n 2.Except for 'main' and 'develop', branch names must begin with 'feature/' or 'hotfix/' "
},
"engines": {
Expand Down Expand Up @@ -57,7 +57,7 @@
"@mui/x-date-pickers": "^5.0.15",
"@netlify/plugin-nextjs": "^4.33.0",
"@next/bundle-analyzer": "^10.2.3",
"@planet-sdk/common": "^0.1.41",
"@planet-sdk/common": "^0.1.43",
"@prisma/client": "^4.13.0",
"@sentry/browser": "^6.15.0",
"@sentry/integrations": "^6.19.2",
Expand Down
23 changes: 13 additions & 10 deletions pages/sites/[slug]/[locale]/profile/edit.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import Head from 'next/head';
import React, { ReactElement } from 'react';
import UserLayout from '../../../../../src/features/common/Layout/UserLayout/UserLayout';
import { AbstractIntlMessages, useTranslations } from 'next-intl';
import EditProfile from '../../../../../src/features/user/Settings/EditProfile';
import {
import type { AbstractIntlMessages } from 'next-intl';
import type {
GetStaticProps,
GetStaticPropsContext,
GetStaticPropsResult,
} from 'next';
import type { Tenant } from '@planet-sdk/common/build/types/tenant';
import type { ReactElement } from 'react';

import { useEffect } from 'react';
import Head from 'next/head';
import { useTranslations } from 'next-intl';
import UserLayout from '../../../../../src/features/common/Layout/UserLayout/UserLayout';
import EditProfile from '../../../../../src/features/user/Settings/EditProfile';
import {
constructPathsForTenantSlug,
getTenantConfig,
} from '../../../../../src/utils/multiTenancy/helpers';
import { Tenant } from '@planet-sdk/common/build/types/tenant';
import { defaultTenant } from '../../../../../tenant.config';
import { useRouter } from 'next/router';
import { useTenant } from '../../../../../src/features/common/Layout/TenantContext';
Expand All @@ -27,7 +30,7 @@ function EditProfilePage({ pageProps: { tenantConfig } }: Props): ReactElement {
const router = useRouter();
const { setTenantConfig } = useTenant();

React.useEffect(() => {
useEffect(() => {
if (router.isReady) {
setTenantConfig(tenantConfig);
}
Expand All @@ -50,7 +53,7 @@ export default EditProfilePage;
export const getStaticPaths = async () => {
const subDomainPaths = await constructPathsForTenantSlug();

const paths = subDomainPaths.map((path) => {
const paths = subDomainPaths?.map((path) => {
return {
params: {
slug: path.params.slug,
Expand Down Expand Up @@ -78,7 +81,7 @@ export const getStaticProps: GetStaticProps<PageProps> = async (

const messages = await getMessagesForPage({
locale: context.params?.locale as string,
filenames: ['common', 'me', 'country', 'editProfile'],
filenames: ['common', 'me', 'country', 'editProfile', 'profile'],
});

return {
Expand Down
11 changes: 11 additions & 0 deletions public/assets/images/icons/KebabMenuIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const KebabMenuIcon = () => {
return (
<svg viewBox="0 0 12 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="4" y="2" width="4" height="4" rx="2" fill="black" />
<rect x="4" y="8" width="4" height="4" rx="2" fill="black" />
<rect x="4" y="14" width="4" height="4" rx="2" fill="black" />
</svg>
);
};

export default KebabMenuIcon;
38 changes: 38 additions & 0 deletions public/static/locales/en/editProfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"email": "Email",
"address": "Address",
"city": "City",
"state": "State",
"zipCode": "Postal/Zip Code",
"country": "Country",
"bio": "Your Description",
Expand All @@ -61,11 +62,48 @@
"addressInvalid": "Address is invalid. Only these special characters are allowed: space . , # - /",
"cityRequired": "City is required",
"cityInvalid": "City is invalid. Only letters and these special characters are allowed: space . , ( ) -",
"stateInvalid": "State is invalid. Only letters and these special characters are allowed: space . , ( ) -",
"zipCodeRequired": "Zip Code is required",
"zipCodeInvalid": "Zip Code is invalid",
"websiteInvalid": "Please enter valid Website URL",
"countryRequired": "Country is required",
"companyRequired": "Company Name is required"
},
"addressManagement": {
"labels": {
"actionMenu": "Action menu"
},
"addressManagementTitle": "Address",
"addressType": {
"primary": "Primary Address",
"mailing": "Billing Address"
},
"actions": {
"edit": "Edit",
"delete": "Delete",
"setAsPrimaryAddress": "Set as Primary Address",
"setAsBillingAddress": "Set as Billing Address",
"unsetBillingAddress": "Unset Billing Address",
"addAddress": "Add New Address"
},
"deleteAction": {
"title": "Delete Address",
"deleteButton": "Delete",
"deleteAddressConfirmationMessage": "Are you sure you want to delete this address? If you want to use it again, please add it as a new address."
},
"updateAddressType": {
"setAddressConfirmation": "Are you sure you want to set this address as your {addressType}?",
"replaceAddressWarning": "This will replace your current {addressType}.",
"confirmButton": "Confirm",
"unsetBillingAddressMessage": "Do you want to unset your billing address? Your primary address will be used as billing address."
},
"maxAddressesMessage": "You have reached the maximum number of addresses! Remove one to add a new address.",
"addressForm": {
"addAddress": "Add Address",
"editAddress": "Edit Address",
"saveChanges": "Save Changes",
"address2": "Address 2(optional)"
}
}
}
}
19 changes: 11 additions & 8 deletions src/features/common/InputTypes/AutoCompleteCountry.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* eslint-disable no-use-before-define */
import { useState, ReactElement, useEffect, ReactNode } from 'react';
import type { CountryType, ExtendedCountryCode } from '../types/country';
import type { SetState } from '../types/common';
import type { ReactNode, ReactElement } from 'react';
import type { CountryCode } from '@planet-sdk/common';

import { useState, useEffect } from 'react';
import { TextField } from '@mui/material';
import React from 'react';
import { useTranslations } from 'next-intl';
import { MuiAutoComplete, StyledAutoCompleteOption } from './MuiAutoComplete';
import { CountryType, ExtendedCountryCode } from '../types/country';
import { allCountries } from '../../../utils/constants/countries';
import { SetState } from '../types/common';

// ISO 3166-1 alpha-2
// ⚠️ No support for IE 11
Expand Down Expand Up @@ -66,8 +68,8 @@ export default function CountrySelect({

useEffect(() => {
countries.sort((a, b) => {
const nameA = t(a.code.toLowerCase());
const nameB = t(b.code.toLowerCase());
const nameA = t(a.code.toLowerCase() as Lowercase<CountryCode>);
const nameB = t(b.code.toLowerCase() as Lowercase<CountryCode>);

//Automatic Selection option is always at first position (if present)
if (a.code === 'auto') return -1;
Expand All @@ -91,7 +93,8 @@ export default function CountrySelect({
getOptionLabel={(option) => {
const { code: countryCode, currency } = option as CountryType;
const label =
(currency ? `(${currency}) ` : '') + t(countryCode.toLowerCase());
(currency ? `(${currency}) ` : '') +
t(countryCode.toLowerCase() as Lowercase<CountryCode>);
return label;
}}
isOptionEqualToValue={(option, value) =>
Expand All @@ -101,7 +104,7 @@ export default function CountrySelect({
const { code: countryCode, currency } = option as CountryType;
const displayedOption =
(currency ? `(${currency}) ` : '') +
t(countryCode.toLowerCase()) +
t(countryCode.toLowerCase() as Lowercase<CountryCode>) +
(!(name == 'editProfile' || countryCode === 'auto')
? ` ${countryCode}`
: '');
Expand Down
12 changes: 9 additions & 3 deletions src/features/common/types/profile.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { User, UserPublicProfile } from '@planet-sdk/common';
import { SetState } from './common';
import { PublicUser } from './user';
import type { User, UserPublicProfile } from '@planet-sdk/common';
import type { SetState } from './common';
import type { PublicUser } from './user';
import type { ADDRESS_ACTIONS } from '../../../utils/addressManagement';

export interface UserFeaturesProps {
handleShare: () => void;
Expand All @@ -25,3 +26,8 @@ export type PublicProfileV2Props = {
};

export type ProfileV2Props = PrivateProfileV2Props | PublicProfileV2Props;

// address management

export type AddressAction =
(typeof ADDRESS_ACTIONS)[keyof typeof ADDRESS_ACTIONS];
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
position: relative;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 398px;
height: 524px;
background: #fff;
transform: translate(-50%, -50%);
border-radius: 16px;
padding: 18px;
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import type { ExtendedCountryCode } from '../../../../common/types/country';
import type { SetState } from '../../../../common/types/common';
import type { Address, APIError } from '@planet-sdk/common';
import type { AddressAction } from '../../../../common/types/profile';

import { useState, useContext, useCallback } from 'react';
import { useTranslations } from 'next-intl';
import { handleError } from '@planet-sdk/common';
import { useUserProps } from '../../../../common/Layout/UserPropsContext';
import { postAuthenticatedRequest } from '../../../../../utils/apiRequests/api';
import { useTenant } from '../../../../common/Layout/TenantContext';
import { ErrorHandlingContext } from '../../../../common/Layout/ErrorHandlingContext';
import AddressForm from './microComponents/AddressForm';
import { ADDRESS_TYPE } from '../../../../../utils/addressManagement';
import AddressFormLayout from './microComponents/AddressFormLayout';
import { getStoredConfig } from '../../../../../utils/storeConfig';

export type FormData = {
address: string | undefined;
address2: string | null;
city: string | undefined;
zipCode: string | undefined;
state: string | null;
};

interface Props {
setIsModalOpen: SetState<boolean>;
setUserAddresses: SetState<Address[]>;
setAddressAction: SetState<AddressAction | null>;
}

const defaultAddressDetail = {
address: '',
address2: '',
city: '',
zipCode: '',
state: '',
};

const AddAddress = ({
setIsModalOpen,
setUserAddresses,
setAddressAction,
}: Props) => {
const tAddressManagement = useTranslations('EditProfile.addressManagement');
const { contextLoaded, user, token, logoutUser } = useUserProps();
const configCountry = getStoredConfig('country');
const defaultCountry = user?.country || configCountry || 'DE';
const { tenantConfig } = useTenant();
const { setErrors } = useContext(ErrorHandlingContext);
const [country, setCountry] = useState<ExtendedCountryCode | ''>(
defaultCountry
);
const [isLoading, setIsLoading] = useState(false);

const addAddress = useCallback(
async (data: FormData) => {
if (!contextLoaded || !user || !token) return;
setIsLoading(true);
const bodyToSend = {
...data,
country,
type: ADDRESS_TYPE.OTHER,
};
try {
const res = await postAuthenticatedRequest<Address>(
tenantConfig.id,
'/app/addresses',
bodyToSend,
token,
logoutUser
);
if (res && setUserAddresses) {
setUserAddresses((prevAddresses) => [...prevAddresses, res]);
}
} catch (error) {
setErrors(handleError(error as APIError));
} finally {
setIsLoading(false);
setIsModalOpen(false);
setAddressAction(null);
}
},
[
contextLoaded,
user,
token,
country,
logoutUser,
setUserAddresses,
handleError,
setIsLoading,
setIsModalOpen,
postAuthenticatedRequest,
]
);

return (
<AddressFormLayout label={tAddressManagement('addressForm.addAddress')}>
<AddressForm
country={country}
setCountry={setCountry}
setIsModalOpen={setIsModalOpen}
isLoading={isLoading}
label={tAddressManagement('addressForm.addAddress')}
defaultAddressDetail={defaultAddressDetail}
processFormData={addAddress}
setAddressAction={setAddressAction}
/>
</AddressFormLayout>
);
};

export default AddAddress;
Loading
Loading