-
Notifications
You must be signed in to change notification settings - Fork 18
BASE: Address Management #2286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
BASE: Address Management #2286
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 a93545e
refactor: set up story for single address
sunilsabatp 47abd98
feat: story for address list
sunilsabatp 2fbe97f
feat: ui of address action popup
sunilsabatp 71440bb
feat: once a action is selected close the action modal
sunilsabatp 6eb041c
refactor: clean up unused utils, update address action config
sunilsabatp 5cd3ec4
feat: add UI for adding addresses
sunilsabatp a210e25
refactor: move adddress management folder to edit profile section, up…
sunilsabatp 804ebd4
feat: add new address button UI
sunilsabatp abf402a
refactor: consolidate translation resources
sunilsabatp 667ba5e
fix: translation issue
sunilsabatp b0a716a
feat: integrate the api
sunilsabatp 2b83ef2
merge: merge base branch, consolidate translation
sunilsabatp a6d09e1
feat: use modal for add new address form
sunilsabatp 8948142
feat: debounce address suggestions to improve performance
sunilsabatp b2e639b
feat: introduce a simple spinner for address mgmt form
sunilsabatp ae8575e
refactor(forms): create reusable AddressInput component
sunilsabatp c5c62f7
style: adjust min-width for address form container
sunilsabatp fd99142
feat: update add address form to make it work as edit address form.
sunilsabatp f840a58
feat: add api call to fetch user addresses
sunilsabatp 1eff9ad
feat: add a space between 2 and ( for Address 2(optional)
sunilsabatp cfd513d
feat: set address type modal UI
sunilsabatp 26c7cd3
feat: modify the edit address api to handle change address type
sunilsabatp 7a29a2b
feat: component rename for better clarity
sunilsabatp dbdc164
feat: implement delete action & lift state management
sunilsabatp 3dfea1f
refactor: refactor translations, optimize address selection, and defi…
sunilsabatp 7ea7126
refactor singleAddress component: simplify address formatting, optimi…
sunilsabatp 1afb426
refactor: modularize address management styles using scss mixins and …
sunilsabatp cb98e06
refactor: clean up address related code in edit profile component
sunilsabatp ab12086
refactor: minor width adjustment.
sunilsabatp 9ccd86f
refactor: group translation resources base on their use
sunilsabatp 2801e9b
refactor: avoid using multiple DashboardView in the edit profile page
sunilsabatp 40eb901
refactor: remove the stories
sunilsabatp d6b2a9b
refactor: rename variables
sunilsabatp d9aeb69
refactor: minor width adjustment for the button,address tag
sunilsabatp dd0f6f7
Merge branch 'address-mgmt/single-address-story' into address-mgmt/ad…
sunilsabatp 03dc974
refactor: minor change in styling in the form button container
sunilsabatp 8b7b544
refactor: extract form input's into a seperate component.
sunilsabatp c4edd1f
refactor: renaming of helper function, render add address form condit…
sunilsabatp 229bffb
Merge branch 'address-mgmt/add-address-form' into address-mgmt/edit-a…
sunilsabatp 39b53e1
refactor: shift the edit form to the root component
sunilsabatp a4d058a
feat: avoid using profile response addresses
sunilsabatp 949f36c
refactor: use switch case to render modal content, remove unneeded ut…
sunilsabatp 4be3b81
merge: merge base branch, shift setAddressType(primary,billing) moda…
sunilsabatp 13311ac
refactor: shift address delete modal to the root component
sunilsabatp b16d705
refactor: simplify AddressTypeConfirmationModal component
sunilsabatp dbab76a
refactor: format address details to render address 2, minor code cl…
sunilsabatp 77af5eb
refactor: move type definitions to d.ts file and improve addressList …
sunilsabatp 9fd2ab3
chore : update planet-sdk/common package
sunilsabatp 1afc9f2
Merge branch 'develop' into feature/address-mgmt
sunilsabatp 39ce8e9
Merge branch 'feature/address-mgmt' into address-mgmt/single-address-…
sunilsabatp 08db197
refactor: resolve merge conflicts
sunilsabatp 0140fe1
Merge branch 'feature/address-mgmt' into address-mgmt/single-address-…
sunilsabatp 93cd555
refactor: use user address type from planet-sdk/common
sunilsabatp 69701c7
refactor: corrected typo: "kabab" to "kebab" across all affected files,
sunilsabatp c2d581c
refactor: merge base branch, resolve conflict
sunilsabatp 7ea1906
Merge branch 'address-mgmt/add-address-form' into address-mgmt/edit-a…
sunilsabatp 4a5f0e4
Merge branch 'address-mgmt/edit-address-form' into address-mgmt/addre…
sunilsabatp aaa5848
refactor: simplify address formatting logic,
sunilsabatp df3db69
feat: add FormattedAddressBlock component to display user address
sunilsabatp ea0228b
refactor: rename variable, and wrap the fetchUserAddresses function i…
sunilsabatp f82fd28
refactor: consistent type import
sunilsabatp 5299b88
Merge branch 'address-mgmt/add-address-form' into address-mgmt/edit-a…
sunilsabatp ccc8ce4
refactor: merge base branch, resolve conflicts
sunilsabatp 8301648
refactor: remove duplicate import
sunilsabatp ceae2b3
refactor: seperate out edit address form.
sunilsabatp 75bb560
refactor: remove the edit address form logic from the add address form
sunilsabatp 417554f
refactor: move early return condition to the top for better readabili…
sunilsabatp 3cc0406
refactor: address feedbacks
sunilsabatp 2991b43
refactor: consistent type import
sunilsabatp 25860aa
docs: add documentation for geocoding functions: suggestAddress and f…
sunilsabatp bc1aeae
Merge branch 'address-mgmt/single-address-story' into address-mgmt/ed…
sunilsabatp ce39b5d
fix: update margin-top for address management styles
mohitb35 2462e84
refactor: move helper function to the utils file
sunilsabatp 1afe8c0
Merge branch 'address-mgmt/single-address-story' into address-mgmt/ed…
sunilsabatp 0e60fac
refactor: early return if token is missing
sunilsabatp f95a383
Merge pull request #2289 from Plant-for-the-Planet-org/address-mgmt/s…
sunilsabatp eb6896e
Merge branch 'address-mgmt/edit-address-form' into address-mgmt/addre…
sunilsabatp 64f7351
refactor: minor ui fixes
sunilsabatp 9d258ef
Merge branch 'address-mgmt/address-actions' into address-mgmt/code-cl…
sunilsabatp 917756c
refactor(styles): use flex-container mixin for consistent layout styling
sunilsabatp 7dfa3e5
feat: add address limit check and show message when limit is reached
sunilsabatp 0c35ec5
refactor: remove unneeded space.
sunilsabatp e5ce25f
refactor: Initialize userAddresses state with profile addresses.
sunilsabatp fe263b6
refactor: rename tProfile to tAddressManagement
sunilsabatp 0c7d439
refactor(address-form): centralize handlers and buttons, improve reus…
sunilsabatp 8dc1266
fix: handle cases where the user has no address
sunilsabatp 7ece720
refactor: consolidate translation resources
sunilsabatp 911deac
refactor: initialize country state with prioritized userCountry value
sunilsabatp 6df7098
Merge branch 'address-mgmt/edit-address-form' into address-mgmt/addre…
sunilsabatp 17dd921
Merge branch 'address-mgmt/address-actions' into address-mgmt/code-cl…
sunilsabatp 36a67d6
refactor: address the feedbacks.
sunilsabatp f69fd7b
Merge branch 'address-mgmt/edit-address-form' into address-mgmt/addre…
sunilsabatp 062dac1
Merge pull request #2307 from Plant-for-the-Planet-org/address-mgmt/e…
sunilsabatp 9ff8673
refactor: remove unneeded files
sunilsabatp 6523041
Merge branch 'feature/address-mgmt' into address-mgmt/address-actions
sunilsabatp 3837dc7
refactor: rename component/function/props.
sunilsabatp 6783400
"refactor: reset addressAction state when the modal is opened or closed
sunilsabatp 075a427
refactor: minor code clean up
sunilsabatp 9e154b6
refactor: simplify translation interpolation
sunilsabatp ef5ce97
refactor: rename tProfile to tAddressManagement
sunilsabatp 43054c8
refactor: define constant for max address limit
sunilsabatp 035c34e
refactor: update address confirmation messages for clarity and structure
mohitb35 b64c57f
fix: corrects import path for ADDRESS_ACTIONS while creating AddressA…
mohitb35 14762b8
Merge branch 'address-mgmt/address-actions' into address-mgmt/address…
sunilsabatp 1525e50
Merge pull request #2308 from Plant-for-the-Planet-org/address-mgmt/a…
sunilsabatp 0a47487
Merge branch 'feature/address-mgmt' into address-mgmt/address-max-limit
sunilsabatp 551b72c
Merge pull request #2316 from Plant-for-the-Planet-org/address-mgmt/a…
sunilsabatp ade9fff
Merge branch 'feature/address-mgmt' into address-mgmt/code-clean-up
sunilsabatp 6ade3b0
Merge branch 'feature/address-mgmt' into address-mgmt/code-clean-up
sunilsabatp 630d5d3
Merge pull request #2312 from Plant-for-the-Planet-org/address-mgmt/c…
sunilsabatp 8ade0d7
refactor: replace SCSS variables with direct values
sunilsabatp 2e31276
refactor: group the addressManagement translation resources.
sunilsabatp 0b02f0e
refactor: organize address management translation keys for consistency
mohitb35 4b28506
Merge pull request #2323 from Plant-for-the-Planet-org/address-mgmt/s…
sunilsabatp e5e093f
feat: add unset billing address option to the address action menu.
sunilsabatp bfe457d
feat: hide delete option for primary address
sunilsabatp 9c9ac78
Merge pull request #2330 from Plant-for-the-Planet-org/address-mgmt/r…
mohitb35 e1b69ad
refactor: address coderabbit points
sunilsabatp f2838b1
refactor: address the code rabbit points
sunilsabatp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
src/features/user/Settings/EditProfile/AddressManagement/AddAddress.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.