chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 deletions
31
packages/server/lib/customer-notes.js
Normal file
31
packages/server/lib/customer-notes.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
const uuid = require('uuid')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const db = require('./db')
|
||||
|
||||
const getCustomerNotes = customerId => {
|
||||
const sql = `SELECT * FROM customer_notes WHERE customer_id=$1`
|
||||
return db.oneOrNone(sql, [customerId]).then(res => _.mapKeys((_, key) => _.camelize(key), res))
|
||||
}
|
||||
|
||||
const createCustomerNote = (customerId, userId, title, content) => {
|
||||
const sql = `INSERT INTO customer_notes (id, customer_id, last_edited_by, last_edited_at, title, content) VALUES ($1, $2, $3, now(), $4, $5)`
|
||||
return db.none(sql, [uuid.v4(), customerId, userId, title, content])
|
||||
}
|
||||
|
||||
const deleteCustomerNote = noteId => {
|
||||
const sql = `DELETE FROM customer_notes WHERE id=$1`
|
||||
return db.none(sql, [noteId])
|
||||
}
|
||||
|
||||
const updateCustomerNote = (noteId, userId, content) => {
|
||||
const sql = `UPDATE customer_notes SET last_edited_at=now(), last_edited_by=$1, content=$2 WHERE id=$3`
|
||||
return db.none(sql, [userId, content, noteId])
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getCustomerNotes,
|
||||
createCustomerNote,
|
||||
deleteCustomerNote,
|
||||
updateCustomerNote
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue