diff --git a/db/models/DesignNote.js b/db/models/DesignNote.js index 253fde1..2844b68 100644 --- a/db/models/DesignNote.js +++ b/db/models/DesignNote.js @@ -1,30 +1,22 @@ const mongoose = require('mongoose'); -const EXPIRATION = 2; +// const EXPIRATION = 2; const designNoteSchema = mongoose.Schema({ - section: { type: String }, - placement: { type: String }, - slug: { type: String }, - art: { type: String }, - comments: { type: String }, - date: { type: Date }, + section: { type: String, default: "" }, + placement: { type: String, default: "" }, + slug: { type: String, default: "" }, + art: { type: String, default: "" }, + artStatus: { type: String, default: "" }, + comments: { type: String, default: "" }, + date: { type: Date, defautl: Date.now }, // You would think this would be a number // but people often approximate or give // ranges so - wordCount: { type: String }, - status: { type: String }, - referText: { type: String }, - // expireAt: { - // type: Date, - // default: function () { - // const now = new Date(); - // now.setDate(now.getDate() + EXPIRATION) - // return now; - // } - // } + wordCount: { type: String, default: "" }, + status: { type: String, default: "" }, + referText: { type: String, default: "" }, }, { timestamps: true, strict: false }); -// designNoteSchema.index({ expireAt: 1 }, { expireAfterSeconds: 0 }); let DesignNote = mongoose.model('DesignNote', designNoteSchema); module.exports = DesignNote; diff --git a/db/models/InstagramStory.js b/db/models/InstagramStory.js index d8a1a5f..1357f16 100644 --- a/db/models/InstagramStory.js +++ b/db/models/InstagramStory.js @@ -6,16 +6,6 @@ const instagramStorySchema = mongoose.Schema({ figma: { type: String }, caption: { type: String }, date: { type: Date }, - // expireAt: { - // type: Date, - // default: function () { - // const now = new Date(); - // now.setDate(now.getDate() + EXPIRATION) - // return now; - // } - // } }, { timestamps: true, strict: false }); -// instagramStorySchema.index({ expireAt: 1 }, { expireAfterSeconds: 0 }); - let InstagramStory = mongoose.model('InstagramStory', instagramStorySchema); module.exports = InstagramStory; diff --git a/db/models/Modular.js b/db/models/Modular.js index 60a4ea8..f1923ff 100644 --- a/db/models/Modular.js +++ b/db/models/Modular.js @@ -4,16 +4,7 @@ const EXPIRATION = 2; const modularSchema = mongoose.Schema({ date: { type: Date }, - // expireAt: { - // type: Date, - // default: function () { - // const now = new Date(); - // now.setDate(now.getDate() + EXPIRATION) - // return now; - // } - // } }, { timestamps: true, strict: false }); -// modularSchema.index({ expireAt: 1 }, { expireAfterSeconds: 0 }); let Modular = mongoose.model('Modular', modularSchema); diff --git a/routes/api/designNotes.js b/routes/api/designNotes.js index b8fb0cc..150eb63 100644 --- a/routes/api/designNotes.js +++ b/routes/api/designNotes.js @@ -20,35 +20,28 @@ router.get('/:year-:month-:day', async (req, res) => { }); router.post('/:year-:month-:day', async (req, res) => { - const { section, placement, slug, wordCount, art, status, comments, referText } = req.body; + const { section, placement, slug, wordCount, art, artStatus, status, comments, referText } = req.body; const { year, month, day } = req.params; - const date = new Date(`${year}-${month}-${day}`); - - const query = { placement, slug, section, wordCount, art, comments, status, referText, date }; - // if (section == "inserts") { - // let expiration = new Date(); - // expiration.setDate(expiration.getDate() + 14); - // query.expireAt = expiration; - // } + const query = { placement, slug, section, wordCount, art, artStatus, comments, status, referText, date }; await DesignNote.create(query, (err, note) => { if (err) { handleError(res); } - res.json(note); }) }); router.patch('/', async (req, res) => { - const { id, placement, slug, section, wordCount, art, comments, status, date, referText } = req.body; + const { id, placement, slug, section, wordCount, art, artStatus, comments, status, date, referText } = req.body; // TODO this is so bad const query = {}; placement && (query.placement = placement); slug && (query.slug = slug); wordCount && (query.wordCount = wordCount); art && (query.art = art); + artStatus && (query.artStatus = artStatus); comments && (query.comments = comments); status && (query.status = status); referText && (query.referText = referText); diff --git a/src/components/Home/DesignNotes/Form.js b/src/components/Home/DesignNotes/Form.js index e38e9df..3bd682d 100644 --- a/src/components/Home/DesignNotes/Form.js +++ b/src/components/Home/DesignNotes/Form.js @@ -45,17 +45,36 @@ export class DesignNotesForm extends React.Component { }} render={({ errors, status, touched, isSubmitting }) => ( - {this.props.properties.map(f => ( -
- - - -
- ))} + {this.props.properties.map((f) => { + if (f === "artStatus") { + return ( +
+ + + + + + + +
+ ) + } else { + return ( +
+ + + +
+ ) + } + })} {status && status.msg &&
{status.msg}
}