mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 20:42:44 +00:00
rename props.brew.uiItems to ...accountDetails
and destructure props at start of account page component. `accountDetails` is more descriptive of what set of info is being passed through props to the account page, info which is only *then* displayed as UI items.
This commit is contained in:
@@ -76,7 +76,7 @@ const Homebrew = createClass({
|
|||||||
<Route path='/print' element={<WithRoute el={PrintPage} />} />
|
<Route path='/print' element={<WithRoute el={PrintPage} />} />
|
||||||
<Route path='/changelog' element={<WithRoute el={SharePage} brew={this.props.brew} />} />
|
<Route path='/changelog' element={<WithRoute el={SharePage} brew={this.props.brew} />} />
|
||||||
<Route path='/faq' element={<WithRoute el={SharePage} brew={this.props.brew} />} />
|
<Route path='/faq' element={<WithRoute el={SharePage} brew={this.props.brew} />} />
|
||||||
<Route path='/account' element={<WithRoute el={AccountPage} brew={this.props.brew} uiItems={this.props.brew.uiItems} />} />
|
<Route path='/account' element={<WithRoute el={AccountPage} brew={this.props.brew} accountDetails={this.props.brew.accountDetails} />} />
|
||||||
<Route path='/legacy' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
<Route path='/legacy' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
||||||
<Route path='/error' element={<WithRoute el={ErrorPage} brew={this.props.brew} />} />
|
<Route path='/error' element={<WithRoute el={ErrorPage} brew={this.props.brew} />} />
|
||||||
<Route path='/' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
<Route path='/' element={<WithRoute el={HomePage} brew={this.props.brew} />} />
|
||||||
|
|||||||
@@ -8,16 +8,20 @@ const NaturalCritIcon = require('naturalcrit/svg/naturalcrit.svg.jsx');
|
|||||||
let SAVEKEY = '';
|
let SAVEKEY = '';
|
||||||
|
|
||||||
const AccountPage = (props)=>{
|
const AccountPage = (props)=>{
|
||||||
|
// destructure props
|
||||||
|
const { accountDetails, brew } = props;
|
||||||
|
|
||||||
|
|
||||||
// State for the save location
|
// State for the save location
|
||||||
const [saveLocation, setSaveLocation] = React.useState('');
|
const [saveLocation, setSaveLocation] = React.useState('');
|
||||||
|
|
||||||
// initialize save location from local storage based on user id
|
// initialize save location from local storage based on user id
|
||||||
React.useEffect(()=>{
|
React.useEffect(()=>{
|
||||||
if(!saveLocation && props.uiItems.username) {
|
if(!saveLocation && accountDetails.username) {
|
||||||
SAVEKEY = `HOMEBREWERY-DEFAULT-SAVE-LOCATION-${props.uiItems.username}`;
|
SAVEKEY = `HOMEBREWERY-DEFAULT-SAVE-LOCATION-${accountDetails.username}`;
|
||||||
// if no SAVEKEY in local storage, default save location to Google Drive.
|
// if no SAVEKEY in local storage, default save location to Google Drive.
|
||||||
let saveLocation = window.localStorage.getItem(SAVEKEY);
|
let saveLocation = window.localStorage.getItem(SAVEKEY);
|
||||||
saveLocation = saveLocation ?? (props.uiItems.googleId ? 'GOOGLE-DRIVE' : 'HOMEBREWERY');
|
saveLocation = saveLocation ?? (accountDetails.googleId ? 'GOOGLE-DRIVE' : 'HOMEBREWERY');
|
||||||
makeActive(saveLocation);
|
makeActive(saveLocation);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
@@ -51,19 +55,19 @@ const AccountPage = (props)=>{
|
|||||||
<>
|
<>
|
||||||
<div className='dataGroup'>
|
<div className='dataGroup'>
|
||||||
<h1>Account Information <i className='fas fa-user'></i></h1>
|
<h1>Account Information <i className='fas fa-user'></i></h1>
|
||||||
<p><strong>Username: </strong>{props.uiItems.username || 'No user currently logged in'}</p>
|
<p><strong>Username: </strong>{accountDetails.username || 'No user currently logged in'}</p>
|
||||||
<p><strong>Last Login: </strong>{moment(props.uiItems.issued).format('dddd, MMMM Do YYYY, h:mm:ss a ZZ') || '-'}</p>
|
<p><strong>Last Login: </strong>{moment(accountDetails.issued).format('dddd, MMMM Do YYYY, h:mm:ss a ZZ') || '-'}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className='dataGroup'>
|
<div className='dataGroup'>
|
||||||
<h3>Homebrewery Information <NaturalCritIcon /></h3>
|
<h3>Homebrewery Information <NaturalCritIcon /></h3>
|
||||||
<p><strong>Brews on Homebrewery: </strong>{props.uiItems.mongoCount}</p>
|
<p><strong>Brews on Homebrewery: </strong>{accountDetails.mongoCount}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className='dataGroup'>
|
<div className='dataGroup'>
|
||||||
<h3>Google Information <i className='fab fa-google-drive'></i></h3>
|
<h3>Google Information <i className='fab fa-google-drive'></i></h3>
|
||||||
<p><strong>Linked to Google: </strong>{props.uiItems.googleId ? 'YES' : 'NO'}</p>
|
<p><strong>Linked to Google: </strong>{accountDetails.googleId ? 'YES' : 'NO'}</p>
|
||||||
{props.uiItems.googleId && (
|
{accountDetails.googleId && (
|
||||||
<p>
|
<p>
|
||||||
<strong>Brews on Google Drive: </strong>{props.uiItems.googleCount ?? (
|
<strong>Brews on Google Drive: </strong>{accountDetails.googleCount ?? (
|
||||||
<>
|
<>
|
||||||
Unable to retrieve files - <a href='https://github.com/naturalcrit/homebrewery/discussions/1580'>follow these steps to renew your Google credentials.</a>
|
Unable to retrieve files - <a href='https://github.com/naturalcrit/homebrewery/discussions/1580'>follow these steps to renew your Google credentials.</a>
|
||||||
</>
|
</>
|
||||||
@@ -74,7 +78,7 @@ const AccountPage = (props)=>{
|
|||||||
<div className='dataGroup'>
|
<div className='dataGroup'>
|
||||||
<h4>Default Save Location</h4>
|
<h4>Default Save Location</h4>
|
||||||
{renderButton('Homebrewery', 'HOMEBREWERY')}
|
{renderButton('Homebrewery', 'HOMEBREWERY')}
|
||||||
{renderButton('Google Drive', 'GOOGLE-DRIVE', props.uiItems.googleId)}
|
{renderButton('Google Drive', 'GOOGLE-DRIVE', accountDetails.googleId)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -82,7 +86,7 @@ const AccountPage = (props)=>{
|
|||||||
|
|
||||||
// return the account page inside the base layout wrapper (with navbar etc).
|
// return the account page inside the base layout wrapper (with navbar etc).
|
||||||
return (
|
return (
|
||||||
<UIPage brew={props.brew}>
|
<UIPage brew={brew}>
|
||||||
{renderAccountPage()}
|
{renderAccountPage()}
|
||||||
</UIPage>);
|
</UIPage>);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -372,7 +372,7 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
|
|||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
data.uiItems = {
|
data.accountDetails = {
|
||||||
username : req.account.username,
|
username : req.account.username,
|
||||||
issued : req.account.issued,
|
issued : req.account.issued,
|
||||||
googleId : Boolean(req.account.googleId),
|
googleId : Boolean(req.account.googleId),
|
||||||
|
|||||||
Reference in New Issue
Block a user