-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create button for importing groups from medlem as options (#212)
* feat: create button for importing groups from medlem as options
- Loading branch information
Showing
9 changed files
with
7,602 additions
and
1,802 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Response } from "express"; | ||
import { getAllGroups } from "ntnui-tools"; | ||
import { RequestWithNtnuiNo } from "../utils/request"; | ||
|
||
export const getGroups = async ( | ||
req: RequestWithNtnuiNo, | ||
res: Response | ||
): Promise<Response> => { | ||
try { | ||
const groups = await getAllGroups(req.body.category); | ||
return res.status(200).json(groups); | ||
} catch (error) { | ||
return res | ||
.status(500) | ||
.json({ message: "Error while fetching groups from medlem" }); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Router } from "express"; | ||
import { getGroups } from "../controllers/group"; | ||
|
||
const groupRoutes = Router(); | ||
|
||
groupRoutes.post("/", getGroups); | ||
|
||
export default groupRoutes; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import axios from "axios"; | ||
|
||
export const getGroups = async (category?: string): Promise<Group[]> => { | ||
try { | ||
const response = await axios.post( | ||
"/groups", | ||
{ category }, | ||
{ withCredentials: true } | ||
); | ||
return response.data; | ||
} catch (error) { | ||
console.error("Error fetching groups:", error); | ||
throw new Error("Failed to fetch groups"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
interface Group { | ||
group_id: number; | ||
name: string; | ||
name_english: string; | ||
slug: string; | ||
gsuite_prefix: string; | ||
subgroups: any[]; | ||
member?: boolean; | ||
access: string; | ||
sent_request?: boolean; | ||
category: string; | ||
website_link: string; | ||
} |