# Subcomfy - Week 6
---
## WHY

---
### Subcomfy helps you feel more productive...

---
### ...and happier straight away

---
## Demo
---
## Homepage

---
## Product Page

---
## Basket Page

---
## Planning
- Name & Logo Generator: <https://namelix.com/>
- Figma: Page Design, Page Flow, Database
---
### Pages

---

---
### Database

---
### Pages & Components

---
## 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
---

---
## 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`) → 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
---

{"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}]"}