Skip to content
Commits on Source (16)
......@@ -130,6 +130,13 @@ export default function Navigation() {
</a>
</Link>
</div>
<div className={styles.link}>
<Link href="/skills">
<a>
<p>Skills</p>
</a>
</Link>
</div>
<div className={styles.link}>
<Link href="/structures">
<a>
......
import mongoose from "mongoose";
const SkillsSchema = new mongoose.Schema(
{
_id: { type: String },
name: { type: String },
count: { type: Number },
},
{ collection: "skills" },
{ timestamps: true }
);
export default mongoose.models.Skills || mongoose.model("Skills", SkillsSchema);
# Changelog
## [1.1.0](https://gitlab.mim-libre.fr/alphabet/supercrud/compare/release/1.0.0...release/1.1.0) (2023-08-24)
### Features
* **skills:** add new collection skills ([79dbaf7](https://gitlab.mim-libre.fr/alphabet/supercrud/commit/79dbaf74048981330d81b1f9090d9142486c7b43))
### Bug Fixes
* **audit:** update vulnerable mongoose library ([845c853](https://gitlab.mim-libre.fr/alphabet/supercrud/commit/845c853f9d863096277d8c6d01e5e9d1ed8e2470))
## 1.0.0 (2022-11-22)
......
This diff is collapsed.
{
"name": "supercrudv2",
"version": "1.0.0",
"version": "1.1.0",
"private": true,
"scripts": {
"dev": "next dev -p 3050",
......@@ -10,19 +10,22 @@
"lint": "next lint"
},
"dependencies": {
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@mui/icons-material": "^5.10.9",
"@mui/material": "^5.10.9",
"material-react-table": "^1.2.8",
"mongoose": "^6.5.4",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.11.12",
"material-react-table": "^1.8.5",
"mongoose": "^6.10.2",
"next": "12.2.5",
"next-auth": "^4.14.0",
"next-auth": "^4.20.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"eslint": "8.23.0",
"eslint-config-next": "12.2.5"
},
"overrides": {
"semver": "^7.5.2"
}
}
import { unstable_getServerSession } from "next-auth/next";
import { authOptions } from "../auth/[...nextauth]";
import connectDB from "../../../database/connectDB";
import Skills from "../../../database/models/Skills";
export default async function handler(req, res) {
const session = await unstable_getServerSession(req, res, authOptions);
const { method } = req;
const { tableName } = req.query;
if (!session)
return res.end(
"You must be signed in to view the protected content on this page."
);
if (!tableName) return res.end("Cannot access API by URL");
await connectDB();
switch (method) {
case "GET":
try {
const skills = await Skills.find({});
res.status(200).json({ data: skills });
} catch (error) {
res.status(400).json({ success: false, error: error.message });
}
break;
case "DELETE":
try {
const bodyParsed = JSON.parse(req.body);
const id = bodyParsed.id;
const result = await Skills.findOneAndDelete({ _id: id });
res.status(200).json({
success: true,
result,
message: "supprimé de la Base de Donnée !",
});
} catch (error) {
res.status(400).json({ success: false, error: error.message });
}
break;
case "PUT":
try {
const bodyParsed = JSON.parse(req.body);
const id = bodyParsed._id;
const result = await Skills.findByIdAndUpdate(
{ _id: id },
{ ...bodyParsed }
);
res.status(200).json({
success: true,
result,
message: "Modifié en Base de Donnée !",
});
} catch (error) {
res.status(400).json({ success: false, error: error.message });
}
break;
}
}
import { useMemo } from "react";
import Dashboard from "../Components/DashBoard";
const Skills = () => {
const columns = useMemo(
() => [
{
accessorKey: "_id",
header: "id",
enableClickToCopy: true,
enableEditing: false,
size: 200,
},
{
accessorKey: "name",
header: "name",
},
{
accessorKey: "count",
header: "count",
enableGlobalFilter: false,
muiTableBodyCellEditTextFieldProps: () => ({
type: "number",
}),
},
],
[]
);
return (
<>
<Dashboard columns={columns} apiRouteName={"skills"} />
</>
);
};
export default Skills;