mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-09-20 14:32:57 +00:00
Merge pull request #5027 from naturalcrit/NewEditHome-Merge
New/Edit/Home Move clearError to common hook
This commit is contained in:
@@ -247,11 +247,6 @@ const EditPage = (props)=>{
|
|||||||
</Nav.item>
|
</Nav.item>
|
||||||
);
|
);
|
||||||
|
|
||||||
const clearError = ()=>{
|
|
||||||
setError(null);
|
|
||||||
setIsSaving(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderNavbar = ()=>{
|
const renderNavbar = ()=>{
|
||||||
return <Navbar>
|
return <Navbar>
|
||||||
<Nav.section>
|
<Nav.section>
|
||||||
@@ -282,6 +277,7 @@ const EditPage = (props)=>{
|
|||||||
handleSplitMove,
|
handleSplitMove,
|
||||||
handleBrewChange,
|
handleBrewChange,
|
||||||
toggleAutoSave,
|
toggleAutoSave,
|
||||||
|
clearError,
|
||||||
trySave
|
trySave
|
||||||
} = useCommonEditPageFunctions({
|
} = useCommonEditPageFunctions({
|
||||||
saveGoogle,
|
saveGoogle,
|
||||||
|
|||||||
@@ -112,11 +112,6 @@ const HomePage =(props)=>{
|
|||||||
return <Nav.item className='save saved'>saved</Nav.item>;
|
return <Nav.item className='save saved'>saved</Nav.item>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearError = ()=>{
|
|
||||||
setError(null);
|
|
||||||
setIsSaving(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderNavbar = ()=>{
|
const renderNavbar = ()=>{
|
||||||
return <Navbar ver={props.ver}>
|
return <Navbar ver={props.ver}>
|
||||||
<Nav.section>
|
<Nav.section>
|
||||||
@@ -137,6 +132,7 @@ const HomePage =(props)=>{
|
|||||||
resetWarnUnsavedTimer,
|
resetWarnUnsavedTimer,
|
||||||
handleSplitMove,
|
handleSplitMove,
|
||||||
handleBrewChange,
|
handleBrewChange,
|
||||||
|
clearError,
|
||||||
trySave
|
trySave
|
||||||
} = useCommonEditPageFunctions({
|
} = useCommonEditPageFunctions({
|
||||||
saveGoogle,
|
saveGoogle,
|
||||||
|
|||||||
@@ -156,11 +156,6 @@ const NewPage = (props)=>{
|
|||||||
return <Nav.item className='save saved'>saved</Nav.item>;
|
return <Nav.item className='save saved'>saved</Nav.item>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearError = ()=>{
|
|
||||||
setError(null);
|
|
||||||
setIsSaving(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderNavbar = ()=>(
|
const renderNavbar = ()=>(
|
||||||
<Navbar>
|
<Navbar>
|
||||||
<Nav.section>
|
<Nav.section>
|
||||||
@@ -185,6 +180,7 @@ const NewPage = (props)=>{
|
|||||||
resetWarnUnsavedTimer,
|
resetWarnUnsavedTimer,
|
||||||
handleSplitMove,
|
handleSplitMove,
|
||||||
handleBrewChange,
|
handleBrewChange,
|
||||||
|
clearError,
|
||||||
trySave
|
trySave
|
||||||
} = useCommonEditPageFunctions({
|
} = useCommonEditPageFunctions({
|
||||||
saveGoogle,
|
saveGoogle,
|
||||||
|
|||||||
@@ -121,6 +121,11 @@ export default function useCommonEditPageFunctions(dependencies) {
|
|||||||
setWarnUnsavedChanges(autoSaveEnabled);
|
setWarnUnsavedChanges(autoSaveEnabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clearError = ()=>{
|
||||||
|
setError(null);
|
||||||
|
setIsSaving(false);
|
||||||
|
};
|
||||||
|
|
||||||
const trySave = useEffectEvent((forceSave = false, hasChanges = true, saveToGoogle = false)=>{
|
const trySave = useEffectEvent((forceSave = false, hasChanges = true, saveToGoogle = false)=>{
|
||||||
clearTimeout(saveTimeout.current);
|
clearTimeout(saveTimeout.current);
|
||||||
if(isSaving) return;
|
if(isSaving) return;
|
||||||
@@ -145,6 +150,7 @@ export default function useCommonEditPageFunctions(dependencies) {
|
|||||||
handleSplitMove,
|
handleSplitMove,
|
||||||
handleBrewChange,
|
handleBrewChange,
|
||||||
toggleAutoSave,
|
toggleAutoSave,
|
||||||
|
clearError,
|
||||||
trySave,
|
trySave,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user