Skip to content

Commit

Permalink
chore: ran prettier and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
codecreator127 committed Aug 30, 2024
1 parent 44d61d1 commit 7d1fc8f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
12 changes: 9 additions & 3 deletions backend/src/db/daos/resourcesDao.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const createResource = async (type, content, name, requiredFlags) => {
name,
textContent: content,
imageContent: "",
requiredFlags: requiredFlags,
requiredFlags,
});
await dbResource.save();
break;
Expand All @@ -20,7 +20,7 @@ const createResource = async (type, content, name, requiredFlags) => {
name,
textContent: "",
imageContent: content,
requiredFlags: requiredFlags,
requiredFlags,
});
await dbResource.save();
break;
Expand Down Expand Up @@ -76,7 +76,13 @@ const removeFlag = async (groupId, flag) => {
return group.currentFlags;
};

const updateResourceById = async (resourceId, name, type, content, requiredFlags) => {
const updateResourceById = async (
resourceId,
name,
type,
content,
requiredFlags
) => {
const resource = await Resource.findById(resourceId);

resource.name = name;
Expand Down
4 changes: 2 additions & 2 deletions backend/src/routes/api/navigate/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@ export const groupGetResources = async (req) => {
if (flags.length > 0) {
// Fetch all resources from the database
const allResources = await Resource.find({});

// Filter resources where all requiredFlags are present in the group's current flags
const matchingResources = allResources.filter((resource) =>
resource.requiredFlags.every((flag) => flags.includes(flag))
);

// Push the filtered resources to the resources array
resources.push(...matchingResources);
}
Expand Down
11 changes: 8 additions & 3 deletions backend/src/routes/api/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const HTTP_NOT_FOUND = 404;
const HTTP_INTERNAL_SERVER_ERROR = 500;

// Apply auth middleware to all routes below this point
// router.use(auth);
router.use(auth);

/**
* @route POST /
Expand All @@ -37,7 +37,12 @@ router.post(
"/",
handle(async (req, res) => {
const { type, content, name, requiredFlags } = req.body;
const newResource = await createResource(type, content, name, requiredFlags);
const newResource = await createResource(
type,
content,
name,
requiredFlags
);
return res.status(HTTP_CREATED).json(newResource).send();
})
);
Expand Down Expand Up @@ -146,7 +151,7 @@ router.delete("/group/:groupId/:flag", async (req, res) => {

router.put("/:resourceId", async (req, res) => {
const { resourceId } = req.params;
const { name, type, content, requiredFlags } = req.body;
const { name, type, content, requiredFlags } = req.body;

if (!content || !name || !type) {
return res.status(HTTP_BAD_REQUEST).send("Bad Request");
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/components/ResourcesModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ function ResourcesModal({ handleClose, resources }) {
);

const ResourceContent = ({ item }) => {
const hasTextContent = item.textContent?.length > 0 && item.textContent[0] !== "";
const hasTextContent =
item.textContent?.length > 0 && item.textContent[0] !== "";
const hasImageContent = item.imageContent && item.imageContent !== "";

return (
<div>
{hasTextContent &&
item.textContent.map((textItem) => (
<p key={textItem}>{textItem}</p>
))}
item.textContent.map((textItem) => <p key={textItem}>{textItem}</p>)}
{hasImageContent && (
<img
className={resourceStyles.resourceImage}
Expand Down

0 comments on commit 7d1fc8f

Please sign in to comment.