# Subcomfy - Week 6 --- ## WHY ![](https://i.imgur.com/N0hBl5M.png) --- ### Subcomfy helps you feel more productive... ![](https://monophy.com/media/cA2S6jVVUg5X2/monophy.gif) --- ### ...and happier straight away ![](https://i.gifer.com/Iktw.gif) --- ## Demo --- ## Homepage ![](https://i.imgur.com/fT4RqP7.png) --- ## Product Page ![](https://i.imgur.com/93hRioP.png) --- ## Basket Page ![](https://i.imgur.com/aOXDPnH.png) --- ## Planning - Name & Logo Generator: <https://namelix.com/> - Figma: Page Design, Page Flow, Database --- ### Pages ![](https://i.imgur.com/P7wzgzH.jpg) --- ![](https://i.imgur.com/QpnLIkM.jpg) --- ### Database ![](https://i.imgur.com/RUDxaF1.png) --- ### Pages & Components ![](https://i.imgur.com/GVEdTBv.png) --- ## Authentication We tried to implement a sign-up and login... --- ```js= export async function getServerSideProps(req, res) { const cookies = new Cookies(req, res); //COOKIE STUFF HERE } ``` --- ```js= if (!cookies.get('sid')) { return { props: { session: false, data: 'no data', sid: 'no sid', }, }; ``` --- ```js= const sid = cookies.get('sid'); const data = await model.getSession(sid); return { props: { session: true, }, }; } ``` --- ```JS= if (!cookie) return res.redirect('/'); ``` --- Reflections: - Trying to use `next.js` like express gets confusing - Using fetch on `api` routes to get a response seems like a better way - Server-side vs client side rendering 🤦‍♂️ - So many new things - my head hurts --- ![](https://i.imgur.com/jEEaTGJ.png) --- ## Database Bugs `Module not found: Can't resolve 'fs'` - Should call database-functions from model.js **on pages, not components**! - Server-error without reference (e.g.`index.js:26:30`) &rarr; check model.js for typos (e.g. missing ,)! --- ## What worked well - **Planning** on Figma - **Group** & Pair Programming: delegating, merging - Use of **Components**, passing props & keys - Shopping **Basket**: - add items - save basket - calculate total sum - **Multiple colour options** are stored on a product in database: ```sql= '{"colour":["purple", "blue" ,"pink"]}' ``` --- ## Future improvements: Product * An option to **subscribe** * Use FAC22 **discount code** on basket page * More catalogue **filters** * More **colours, sizes** ( * Perhaps own database tables? * **Variations** between products --- ## Future improvements: Coding * Write **Tests** * More **styling** * Try more React & Next * hooks * built-in features (e.g. [automatic cookie reader](https://nextjs.org/docs/basic-features/data-fetching#provided-req-middleware-in-getserversideprops)) * libraries --- ![](https://www.gifcen.com/wp-content/uploads/2021/05/thank-you-gif-3.gif)
{"metaMigratedAt":"2023-06-16T13:54:56.851Z","metaMigratedFrom":"Content","title":"Subcomfy - Week 6","breaks":true,"contributors":"[{\"id\":\"6cc335f8-1f36-47ab-89ea-21858127bf52\",\"add\":2667,\"del\":697},{\"id\":\"fd429060-bd08-4036-b343-577a83f24e57\",\"add\":479,\"del\":473},{\"id\":\"5e681836-8f91-4878-933c-ec6586284e6c\",\"add\":1009,\"del\":187}]"}
    221 views