Interfaces
Interface: UseUser
module react autonomy docid\ zoz6w56ubppacr0po0gls useuser useuser contains the data and methods returned by the function useuser docid\ bctsq3gxnghvdbgtam2hy hook properties loaduser • loaduser () => promise < void > type declaration ▸ () promise < void > the loaduser function loads information about the current order's associated user from the chord api import { useuser } from '@chordcommerce/react autonomy' export default () => { const { user, loaduser } = useuser() useeffect(() => { loaduser() }, \[]) return \<p>welcome, {user data email}!\</p> } returns promise < void > a promise that resolves when the user object has been added to redux defined in packages/react autonomy/src/hooks/use user ts 125 https //github com/chordcommerce/chord ui/blob/2b105e1/packages/react autonomy/src/hooks/use user ts#l125 loaduseraddressbook • loaduseraddressbook () => promise < type alias addressbook docid\ vwvt8ioja7oym5bq qvv4 > type declaration ▸ () promise < type alias addressbook docid\ vwvt8ioja7oym5bq qvv4 > the loaduseraddressbook function loads the current user's stored addresses a user must be already logged in for this method to work properly import { useuser } from '@chordcommerce/react autonomy' export default () => { const { user, loaduseraddressbook } = useuser() useeffect(() => { loaduseraddressbook() }, \[]) if (!user addressbook) return null return ( \<ul> {user addressbook map(address => ( \<li>{address name} {address address1} {address city}, {address statetext}\</li> )} \</ul> ) } returns promise < type alias addressbook docid\ vwvt8ioja7oym5bq qvv4 > a promise that resolves when the array of addresses, addressbook has been added to redux defined in packages/react autonomy/src/hooks/use user ts 243 https //github com/chordcommerce/chord ui/blob/2b105e1/packages/react autonomy/src/hooks/use user ts#l243 loaduserreferralidentifier • loaduserreferralidentifier ( options type alias loaduserreferralidentifier docid\ munnrx729wzwkx8i39mxn ) => promise < interface referralidentifier docid\ ul grv5q ut1v77ravkro > type declaration ▸ ( options ) promise < interface referralidentifier docid\ ul grv5q ut1v77ravkro > the loaduserreferralidentifier function loads the referral identifier information for a user with the given email address from the chord api import { useuser } from '@chordcommerce/react autonomy' export default () => { const { user, loaduserreferralidentifier } = useuser() const referralpurl = user referralidentifier && user referralidentifier purl useeffect(() => { loaduserreferralidentifier() }, \[]) return ( \<p>refer your friends with your personal referral link {referralpurl}\</p> ) } parameters name type options type alias loaduserreferralidentifier docid\ munnrx729wzwkx8i39mxn returns promise < interface referralidentifier docid\ ul grv5q ut1v77ravkro > a promise that resolves when the referralidentifier object has been added to the user object in redux defined in packages/react autonomy/src/hooks/use user ts 152 https //github com/chordcommerce/chord ui/blob/2b105e1/packages/react autonomy/src/hooks/use user ts#l152 loaduserstorecreditevents • loaduserstorecreditevents () => promise < interface storecreditevents docid\ bdqyxxvrlbigb2p vj yg > type declaration ▸ () promise < interface storecreditevents docid\ bdqyxxvrlbigb2p vj yg > the loaduserstorecreditevents function loads information about the current user's store credit history a user must be already logged in for this method to work properly import { useuser } from '@chordcommerce/react autonomy' export default () => { const { user, loaduserstorecreditevents } = useuser() useeffect(() => { loaduserstorecreditevents() }, \[]) if (!user storecreditevents) return null return ( \<ul> {user storecreditevents map(event => ( \<li>{event displayeventdate} {event displayaction} {event displayamount} ({event displayremainingamount} remaining)\</li> )} \</ul> ) } returns promise < interface storecreditevents docid\ bdqyxxvrlbigb2p vj yg > a promise that resolves when the array of storecreditevents has been added to redux defined in packages/react autonomy/src/hooks/use user ts 210 https //github com/chordcommerce/chord ui/blob/2b105e1/packages/react autonomy/src/hooks/use user ts#l210 modifyuser • modifyuser ( options type alias modifyuser docid yhhr4fzjwtqorcu 3ssm ) => promise < void > type declaration ▸ ( options ) promise < void > the modifyuser function is used to update the user's profile information import { useuser } from '@chordcommerce/react autonomy' export const accountpage => { const { modifyuser } = useuser() const onsubmit = ({ email }) => { modifyuser({ email }) } // return profile edit form } parameters name type options type alias modifyuser docid yhhr4fzjwtqorcu 3ssm returns promise < void > a promise that resolves when the user object has been updated in redux defined in packages/react autonomy/src/hooks/use user ts 176 https //github com/chordcommerce/chord ui/blob/2b105e1/packages/react autonomy/src/hooks/use user ts#l176 modifyuseraddressbook • modifyuseraddressbook ( address updateaddressinput ) => promise < type alias addressbook docid\ vwvt8ioja7oym5bq qvv4 > type declaration ▸ ( address ) promise < type alias addressbook docid\ vwvt8ioja7oym5bq qvv4 > the modifyuseraddressbook function updates an address the current user's stored addresses a user must be already logged in for this method to work properly import { useuser } from '@chordcommerce/react autonomy' export default () => { const { user, loaduseraddressbook, modifyuseraddressbook } = useuser() useeffect(() => { loaduseraddressbook() }, \[]) const setaddresstodefault = (addressid) => { const addresstoupdate = { user addressbook find(a => a id === addressid) } delete addresstoupdate country delete addresstoupdate state addresstoupdate default = true modifyuseraddressbook(addresstoupdate) } if (!user addressbook) return null return ( \<ul> {user addressbook map(address => ( \<li onclick={() => setaddresstodefault(address id)}> {address name} {address address1} {address city}, {address statetext} \</li> )} \</ul> ) } parameters name type address updateaddressinput returns promise < type alias addressbook docid\ vwvt8ioja7oym5bq qvv4 > a promise that resolves when the array of addresses, addressbook has been updated in redux defined in packages/react autonomy/src/hooks/use user ts 288 https //github com/chordcommerce/chord ui/blob/2b105e1/packages/react autonomy/src/hooks/use user ts#l288 removefromuseraddressbook • removefromuseraddressbook ( addressid number ) => promise < void > type declaration ▸ ( addressid ) promise < void > the removefromuseraddressbook function removes an address the current user's stored addresses a user must be already logged in for this method to work properly import { useuser } from '@chordcommerce/react autonomy' export default () => { const { user, loaduseraddressbook, removefromuseraddressbook } = useuser() useeffect(() => { loaduseraddressbook() }, \[]) const removeaddress = (addressid) => { removefromuseraddressbook(addressid) } if (!user addressbook) return null return ( \<ul> {user addressbook map(address => ( \<li onclick={() => removeaddress(address id)}> {address name} {address address1} {address city}, {address statetext} \</li> )} \</ul> ) } parameters name type addressid number returns promise < void > a promise that resolves when the array of addresses, addressbook has been updated in redux to reflect the removal of the address id passed to this function defined in packages/react autonomy/src/hooks/use user ts 327 https //github com/chordcommerce/chord ui/blob/2b105e1/packages/react autonomy/src/hooks/use user ts#l327 user • user object chord's user state the data property contains the user's information it will be an empty object if the user is not logged in, which allows for top level optional chaining import { useuser } from '@chordcommerce/react autonomy' function greeting() { const { user } = useuser() return \<h1>hello{user data? name ? `, ${user data name}` ''}!\</h1> } type declaration name type addressbook type alias addressbook docid\ vwvt8ioja7oym5bq qvv4 data interface user docid\ zayf yt0nlpydphk2v988 | record < string , never > referralidentifier string storecreditevents interface storecreditevents docid\ bdqyxxvrlbigb2p vj yg defined in packages/react autonomy/src/hooks/use user ts 101 https //github com/chordcommerce/chord ui/blob/2b105e1/packages/react autonomy/src/hooks/use user ts#l101