Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: super admin read faqs #574

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
28 changes: 25 additions & 3 deletions src/controllers/FaqController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,42 @@ class FAQController {
* type: string
* description: The category of the FAQ.
* example: Returns
* created_at:
* type: string
* format: date-time
* description: The timestamp when the FAQ was created.
* updated_at:
* type: string
* format: date-time
* description: The timestamp when the FAQ was last updated.
*
*
* 500:
* description: Internal server error.
*/
public async getFaq(req: Request, res: Response, next: NextFunction) {
try {
const isAdmin = await isSuperAdmin(req.user.id);
if (!isAdmin) {
return res.status(403).json({
status_code: 403,
success: false,
message: "Unauthorized access",
});
}

const faqs = await faqService.getAllFaqs();
res.status(200).json({
status_code: 200,
success: true,
message: "The FAQ has been retrieved successfully.",
message: "Faq fetched successfully",
data: faqs,
});
} catch (error) {
next(error);
res.status(500).json({
status_code: 500,
message: error,
data: {},
});
}
}

Expand Down
Loading