Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion components/display-notices.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,20 @@ const DataDisplay = (props) => {
</span>
)
})}
{detail.intranet ? (
<div
style={{
display: 'flex',
flexWrap: 'wrap',
fontWeight: 'bold',
}}
>
Intranet
</div>
) : (
<span></span>
)}
</div>

<div style={{ display: 'flex', flexWrap: 'wrap' }}>
<div>Uploaded By : {detail.email} </div>
<div>Updated By: {detail.updatedBy} </div>
Expand Down
18 changes: 17 additions & 1 deletion components/notices-props/add-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const AddForm = ({ handleClose, modal }) => {
department: '',
isVisible: true,
important: false,
intranet: false,
notice_type: 'department',
})

Expand All @@ -44,7 +45,11 @@ export const AddForm = ({ handleClose, modal }) => {
const [submitting, setSubmitting] = useState(false)

const handleChange = (e) => {
if (e.target.name == 'important' || e.target.name == 'isVisible') {
if (
e.target.name == 'important' ||
e.target.name == 'isVisible' ||
e.target.name == 'intranet'
) {
setContent({ ...content, [e.target.name]: e.target.checked })
} else {
setContent({ ...content, [e.target.name]: e.target.value })
Expand All @@ -66,6 +71,7 @@ export const AddForm = ({ handleClose, modal }) => {
id: now,
isVisible: content.isVisible ? 1 : 0,
important: content.important ? 1 : 0,
intranet: content.intranet ? 1 : 0,
notice_type:
session.user.role == 4
? session.user.administration
Expand Down Expand Up @@ -218,6 +224,16 @@ export const AddForm = ({ handleClose, modal }) => {
}
label="Visibility"
/>
<FormControlLabel
control={
<Checkbox
name="intranet"
checked={content.intranet}
onChange={(e) => handleChange(e)}
/>
}
label="Intranet"
/>

<FormControl
style={{ margin: `10px auto`, width: `100%` }}
Expand Down
18 changes: 17 additions & 1 deletion components/notices-props/edit-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const EditForm = ({ data, handleClose, modal }) => {
notice_type: data.notice_type,
isVisible: data.isVisible ? true : false,
important: data.important ? true : false,
intranet: data.intranet ? true : false,
})

const [verifyDelete, setVerifyDelete] = useState(false)
Expand All @@ -52,7 +53,11 @@ export const EditForm = ({ data, handleClose, modal }) => {
const [newMainAttachment, setNewMainAttachment] = useState({})

const handleChange = (e) => {
if (e.target.name == 'important' || e.target.name == 'isVisible') {
if (
e.target.name == 'important' ||
e.target.name == 'isVisible' ||
e.target.name == 'intranet'
) {
setContent({ ...content, [e.target.name]: e.target.checked })
} else {
setContent({ ...content, [e.target.name]: e.target.value })
Expand Down Expand Up @@ -104,6 +109,7 @@ export const EditForm = ({ data, handleClose, modal }) => {

isVisible: content.isVisible ? 1 : 0,
important: content.important ? 1 : 0,
intranet: content.intranet ? 1 : 0,
openDate: open,
closeDate: close,
timestamp: now,
Expand Down Expand Up @@ -244,6 +250,16 @@ export const EditForm = ({ data, handleClose, modal }) => {
}
label="Visibility"
/>
<FormControlLabel
control={
<Checkbox
name="intranet"
checked={content.intranet}
onChange={(e) => handleChange(e)}
/>
}
label="Intranet"
/>

<FormControl
style={{ margin: `10px auto`, width: `100%` }}
Expand Down
5 changes: 3 additions & 2 deletions pages/api/create/[type].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const handler = async (req, res) => {
)
params.timestamp = new Date().getTime()
let result = await query(
`INSERT INTO notices (id,title,timestamp,openDate,closeDate,important,attachments,email,isVisible,notice_link,notice_type,department,updatedBy,updatedAt) VALUES ` +
`(?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
`INSERT INTO notices (id,title,timestamp,openDate,closeDate,important,attachments,email,isVisible,notice_link,notice_type,department,updatedBy,updatedAt,intranet) VALUES ` +
`(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
[
params.id,
params.title,
Expand All @@ -40,6 +40,7 @@ const handler = async (req, res) => {
params.department,
params.email,
params.timestamp,
params.intranet,
]
).catch((err) => console.log(err))
return res.json(result)
Expand Down
5 changes: 3 additions & 2 deletions pages/api/update/[type].js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const handler = async (req, res) => {
params.main_attachment
)
let result = await query(
`UPDATE notices SET title=?,updatedAt=?,openDate=?,closeDate=?,important=?,` +
`attachments=?,notice_link=?,isVisible=?,updatedBy=?,notice_type=? WHERE id=?`,
`UPDATE notices SET title=?,updatedAt=?,openDate=?,closeDate=?,important=?,
attachments=?,notice_link=?,isVisible=?,updatedBy=?,notice_type=?,intranet=? WHERE id=?`,
[
params.title,
params.timestamp,
Expand All @@ -36,6 +36,7 @@ const handler = async (req, res) => {
params.isVisible,
params.email,
params.notice_type,
params.intranet,
params.id,
]
)
Expand Down
1 change: 1 addition & 0 deletions scripts/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async function migrate() {
attachments varchar(1000),
email varchar(50) NOT NULL,
isDept int,
intranet int;
department varchar(1000),
PRIMARY KEY (id)
);`).catch((e) => console.log(e))
Expand Down