mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-11-24 05:36:54 +00:00
Move remaining state to common hook
This commit is contained in:
1 parent
c282d5e5bc
commit
9fb7a79047
4 files changed
+45
-103
No files matched your search
@@ -1,20 +1,11 @@
|
||||
import './homePage.less';
|
||||
|
||||
// Common imports
|
||||
import React, { useState } from 'react';
|
||||
import request from '../../utils/request-middleware.js';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { DEFAULT_BREW } from '../../../../server/brewDefaults.js';
|
||||
|
||||
import React from 'react';
|
||||
import request from '../../utils/request-middleware.js';
|
||||
import _ from 'lodash';
|
||||
import useCommonEditPageFunctions from '../../utils/commonEditPageFunctions.jsx';
|
||||
|
||||
// Page specific imports
|
||||
const useLocalStorage = false;
|
||||
const sandbox = true;
|
||||
const showFloatingButtons = true;
|
||||
const showEditorButtons = false;
|
||||
const pageName = 'homePage';
|
||||
import { DEFAULT_BREW } from '../../../../server/brewDefaults.js';
|
||||
|
||||
const HomePage =(props)=>{
|
||||
props = {
|
||||
@@ -22,18 +13,10 @@ const HomePage =(props)=>{
|
||||
...props
|
||||
};
|
||||
|
||||
const [currentBrew, setCurrentBrew] = useState(props.brew);
|
||||
const [error, setError] = useState(undefined);
|
||||
|
||||
const save = async (brew, saveToGoogle)=>{
|
||||
const res = await request
|
||||
.post(`/api${saveToGoogle ? '?saveToGoogle=true' : ''}`)
|
||||
.send(brew)
|
||||
.catch((err)=>{
|
||||
console.error('Error Updating Local Brew');
|
||||
setError(err);
|
||||
});
|
||||
if(!res) return;
|
||||
.send(brew);
|
||||
|
||||
return res.body;
|
||||
};
|
||||
@@ -46,18 +29,15 @@ const HomePage =(props)=>{
|
||||
const {
|
||||
renderPanels
|
||||
} = useCommonEditPageFunctions({
|
||||
error,
|
||||
setError,
|
||||
currentBrew,
|
||||
setCurrentBrew,
|
||||
useLocalStorage,
|
||||
sandbox,
|
||||
showFloatingButtons,
|
||||
useLocalStorage : false,
|
||||
sandbox : true,
|
||||
showFloatingButtons : true,
|
||||
showEditorButtons : false,
|
||||
pageName : 'homePage',
|
||||
brew : props.brew,
|
||||
userThemes : {},
|
||||
save,
|
||||
onSaveSuccess,
|
||||
pageName,
|
||||
showEditorButtons,
|
||||
userThemes : {}
|
||||
});
|
||||
|
||||
return renderPanels();
|
||||
|
||||
Reference in new issue
Block a user