tr_spinplus_addresses v0.2.0
Sure, here's a basic documentation for the provided code:
Addresses Module
This module provides functionality related to addresses and delivery types. It includes the ability to fetch user addresses, delivery types, and manage the current address and delivery type.
Installation
npm install tr_spinplus_addresses
Usage
import { useAddress, AddressProvider } from 'tr_spinplus_addresses';
API
useAddress()
A React hook that provides access to the address context. It returns an object with the following properties:
currentAddress
: The current user address.currentDeliveryType
: The current delivery type.fetchUserAddresses
: A function to fetch the user's addresses.customerAddresses
: A list of the user's addresses.setAddress
: A function to set the address from the address creation flow.address
: The address from the address creation flow.deliveryTypes
: The delivery types for dynamic usage across the app.currentCoverageAreaId
: The current coverage area id.openAddressList
: A function to open the address list.openAddressCreate
: A function to open the address creation flow.fetchDeliveryTypes
: A function to fetch the delivery types.deepLinkRoute
: The route to return back to from select address/create address flow.setDeepLinkRoute
: A function to set the deep link route.setCurrentAddress
: A function to set the current address.setCurrentDeliveryType
: A function to set the current delivery type.setDeliveryTypes
: A function to set the delivery types.deleteCustomerAddress
: A function to delete a customer address.isDeliveryTypesLoading
: A boolean indicating if the delivery types are loading.isLoading
: A boolean indicating if the module is loading.selectedDeliveryTypeState
: The selected delivery type state.setDeliveryTypeState
: A function to set the delivery type state.
AddressProvider
A React component that provides the address context to its children. It accepts the following props:
children
: The children components.selectedDeliveryType
: The selected delivery type.
Sure, here's the additional documentation for the AddressesScreens
component:
AddressesScreens
This is a component that defines the navigation for the address-related screens in the application. It uses the Screen
component passed as a parameter to define the different screens.
Screens
The AddressesScreens
component defines the following screens:
AddressSelectScreen
: This screen is used to select an address from a list of addresses.AddressCreateFormScreen
: This screen is used to confirm the details of an address.AddressCreateMapScreen
: This screen is used to select an address on a map.AddressCreateIndexScreen
: This screen is used to search for an address.
Each screen is defined with a name
, component
, and options
. The name
is a string that identifies the screen,
the component
is the React component that will be rendered for the screen, and the options
is an object that
configures the screen's appearance and behavior.
The options
object for each screen includes the following properties:
header
: This is set tonull
to hide the header for the screen.presentation
: This is set to'card'
to use the card-style presentation for the screen.
Example
const AddressesScreens = (Screen: any) => {
return (
<>
<Screen
name={Routes.AddressSelectScreen}
component={AddressSelectScreen}
options={{
header: () => null,
presentation: 'card',
}}
/>
// ... other screens ...
</>
)
}
Usage
import AddressesScreens from 'tr_spinplus_addresses/navigation/AddressesScreens';
In this example, Screen
is a component that is used to define a screen in the navigation. The name
prop is a string
that identifies the screen, the component
prop is the React component that will be rendered for the screen, and
the options
prop is an object that configures the screen's appearance and behavior.
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library
1 year ago