Skip to content

Commit

Permalink
showBoard
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongworry committed Apr 26, 2024
1 parent 16ad29e commit aba91e3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/admin/components/uploadZabo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const uploadZaboComponent = (props) => {
const [description, setDescription] = useState("");
const [category, setCategory] = useState("");
const [schedule, setSchedule] = useState({});
const [showBoard, setShowBoard] = useState(false);

const handleZaboChange = (e) => {
const files = Array.from(e.target.files);
Expand Down Expand Up @@ -119,6 +120,7 @@ const uploadZaboComponent = (props) => {
zaboJSON.append("title", title);
zaboJSON.append("description", description);
zaboJSON.append("category", category);
zaboJSON.append("showBoard", showBoard);
//TODO: handle if schedule exists
// formData.append("schedule", schedule);

Expand Down
4 changes: 3 additions & 1 deletion src/controllers/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const checkAdmin = ash(async (req, res, next) => {
export const postNewZabo = ash(async (req, res) => {
const self = req.adminUser.user;

const { title, description, schedules: jsonSchedules } = req.body;
const { title, description, schedules: jsonSchedules, showBoard } = req.body;
const schedules = parseJSON(jsonSchedules, []);
let { category } = req.body;
logger.zabo.info(
Expand All @@ -111,6 +111,7 @@ export const postNewZabo = ash(async (req, res) => {
description,
category,
schedules,
showBoard,
req.files,
);
category = (category || "")
Expand Down Expand Up @@ -142,6 +143,7 @@ export const postNewZabo = ash(async (req, res) => {
description,
category,
schedules,
showBoard,
});

const calSizes = [];
Expand Down
9 changes: 7 additions & 2 deletions src/controllers/zabo.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const getZabo = ash(async (req, res) => {

export const postNewZabo = ash(async (req, res) => {
const { self } = req;
const { title, description, schedules: jsonSchedules } = req.body;
const { title, description, schedules: jsonSchedules, showBoard } = req.body;
const schedules = parseJSON(jsonSchedules, []);
let { category } = req.body;
logger.zabo.info(
Expand All @@ -74,6 +74,7 @@ export const postNewZabo = ash(async (req, res) => {
description,
category,
schedules,
showBoard,
req.files,
);
category = (category || "")
Expand All @@ -99,6 +100,7 @@ export const postNewZabo = ash(async (req, res) => {
description,
category,
schedules,
showBoard,
});

const calSizes = [];
Expand Down Expand Up @@ -133,7 +135,7 @@ export const postNewZabo = ash(async (req, res) => {

export const editZabo = ash(async (req, res) => {
const { zabo } = req;
const { title, description, schedules = [] } = req.body;
const { title, description, schedules = [], showBoard } = req.body;
let { category } = req.body;
logger.zabo.info(
"post /zabo/%s/edit request; title: %s, description: %s, category: %s, schedules: %s",
Expand All @@ -142,6 +144,7 @@ export const editZabo = ash(async (req, res) => {
description,
category,
schedules,
showBoard,
);
category = (category || "")
.toLowerCase()
Expand All @@ -151,12 +154,14 @@ export const editZabo = ash(async (req, res) => {
zabo.description = description;
zabo.category = category;
zabo.schedules = schedules;
zabo.showBoard = showBoard;
await zabo.save();
return res.json({
title: zabo.title,
description: zabo.description,
category: zabo.category,
schedules: zabo.schedules,
showBoard: zabo.showBoard,
});
});

Expand Down
1 change: 1 addition & 0 deletions src/db/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const zaboSchemaObject = {
eventType: String, // '행사' or '신청'
},
],
showBoard: Boolean,
pins: [
{
type: mongoose.Schema.ObjectId,
Expand Down

0 comments on commit aba91e3

Please sign in to comment.