Feat/faq backend#33
Conversation
…lose for all container sizes
…dded padding between questions
…nd updated styling to use common.css
Co-authored-by: Copilot <copilot@github.com>
RLee64
left a comment
There was a problem hiding this comment.
Nice work, but going to need to do a bit more to meet functionality requirements. Lmk if you need clarifying on any of the comments or aren't sure how to approach the ticket.
| @@ -0,0 +1,26 @@ | |||
| [ | |||
| import { RequestHandler } from "express"; | ||
| import { Faq } from "../model/faq"; | ||
|
|
||
| export const listFaqs: RequestHandler = async (req, res) => { |
There was a problem hiding this comment.
Since FAQs are unlikely to be updated often, we should look into some sort of caching if possible (might just be as simple as not hitting the DB until timeout or on outdated version).
|
|
||
| const faqSchema = new Schema( | ||
| { | ||
| question: { type: String, required: true }, |
There was a problem hiding this comment.
The schema we want instead is a single object like
{
content: { type: String, required: true },
timestamp: { type: Date, required: true },
}
Expanding a bit more on why the ticket wants this, allowing admins to directly edit the entire FAQ rather than a bit at a time will probably be a lot easier for them (and for us since we won't have to design a bunch of extra functionality!).
Having this also gives us the potential basis to extend the FAQ backend into a larger 'content' backend, which allows for the editing of text fields in other importantn places.
There was a problem hiding this comment.
Oh whoops, turns out there's a nice and easy way for Mongo/mongoose to automatically add timestamps
{
content: { type: String, required: true },
},
{ timestamps: true, versionKey: false }
| import { RequestHandler } from "express"; | ||
| import { Faq } from "../model/faq"; | ||
|
|
||
| export const listFaqs: RequestHandler = async (req, res) => { |
There was a problem hiding this comment.
nit: getFaqs would be a better function name (a bit more conventional for web servers)
|
|
||
| const router = express.Router(); | ||
| router.get("/", listFaqs); | ||
|
|
There was a problem hiding this comment.
As per the ticket we should also include the ability for admins to update the FAQ page, make sure to create an endpoint for this and then test it out with Postman
| return <div>Faq page - not yet implemented</div>; | ||
| const [faqs, setFaqs] = useState<Faq[]>([]); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
If you're hooking up backend to frontend, run a function to parse the content into the desired faq item format. Maybe new lines starting with a # could be used to determine a question, and then the text in the lines below (until the next #) will be that question's answer.
created the connection between faq.tsx and database. created scheme, controller, and route. updated index accordingly.