0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-18 10:02:49 +00:00

Use let instead of const

This commit is contained in:
Trevor Buckner
2021-06-28 11:50:12 -04:00
parent c18eb948b4
commit 496ab26972

View File

@@ -135,18 +135,18 @@ const NewPage = createClass({
console.log('saving new brew'); console.log('saving new brew');
const saveBrew = this.state.brew; let brew = this.state.brew;
// Split out CSS to Style if CSS codefence exists // Split out CSS to Style if CSS codefence exists
if(saveBrew.text.startsWith('```css') && saveBrew.text.indexOf('```\n\n') > 0) { if(brew.text.startsWith('```css') && brew.text.indexOf('```\n\n') > 0) {
const index = saveBrew.text.indexOf('```\n\n'); const index = brew.text.indexOf('```\n\n');
saveBrew.style = `${saveBrew.style ? `${saveBrew.style}\n` : ''}${saveBrew.text.slice(7, index - 1)}`; brew.style = `${brew.style ? `${brew.style}\n` : ''}${brew.text.slice(7, index - 1)}`;
saveBrew.text = saveBrew.text.slice(index + 5); brew.text = brew.text.slice(index + 5);
}; };
if(this.state.saveGoogle) { if(this.state.saveGoogle) {
const res = await request const res = await request
.post('/api/newGoogle') .post('/api/newGoogle')
.send(saveBrew) .send(brew)
.catch((err)=>{ .catch((err)=>{
console.log(err.status === 401 console.log(err.status === 401
? 'Not signed in!' ? 'Not signed in!'
@@ -155,13 +155,13 @@ const NewPage = createClass({
return; return;
}); });
const brew = res.body; brew = res.body;
localStorage.removeItem(BREWKEY); localStorage.removeItem(BREWKEY);
localStorage.removeItem(STYLEKEY); localStorage.removeItem(STYLEKEY);
window.location = `/edit/${brew.googleId}${brew.editId}`; window.location = `/edit/${brew.googleId}${brew.editId}`;
} else { } else {
request.post('/api') request.post('/api')
.send(saveBrew) .send(brew)
.end((err, res)=>{ .end((err, res)=>{
if(err){ if(err){
this.setState({ this.setState({
@@ -170,7 +170,7 @@ const NewPage = createClass({
return; return;
} }
window.onbeforeunload = function(){}; window.onbeforeunload = function(){};
const brew = res.body; brew = res.body;
localStorage.removeItem(BREWKEY); localStorage.removeItem(BREWKEY);
localStorage.removeItem(STYLEKEY); localStorage.removeItem(STYLEKEY);
window.location = `/edit/${brew.editId}`; window.location = `/edit/${brew.editId}`;