# IPW.CO.ZA

BD updates:

Tables:

email
refresh_token

Adjustments:

Adjust the data structure of the password field to allow of the argon2 hash. Change from char(32) to varchar(97)

For prisma schema amendments:
https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#fields-1

./src/prisma/prisma.schema should have the output field as follows:

generator client {
  provider = "prisma-client-js"
  output = "./generated"
}

## BACKGROUND INFORMATION

This is a rewrite of the [old IPW website](https://github.com/WeboonTechnologySolution/old-ipw.co.za) and user portal, it provides IPW staff with and the industry participants with:

- General information about Integrated Production of Wine (IPW) which is the environmental sustainability scheme that was established by the South African wine industry in 1998.
- Various functions that members of IPW use to maintain their membership and meet regulatory guidelines.
- Various functions for administration of IPW, its members and this website software.

The application consists of:

- Fastify back-end web/API server
- Nuxt front-end web client

The web/API server in the [Fastify](https://www.fastify.io/) framework using [Prisma](prisma.io/) as an [ORM utility](https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping) and [Typescript](https://www.typescriptlang.org/) for enhanced types in JavaScript.

The web client is created in the [Nuxt](https://nuxt.com/) framework using [Bootstrap](https://getbootstrap.com/) for UI / styling along with various [custom branding assets](https://github.com/WeboonTechnologySolution/ipw-branding) and [Vue](vuejs.org/) for handling the interface logic.

## GENERAL OPERATION

See the instructions for the [client](https://github.com/WeboonTechnologySolution/ipw.co.za/tree/main/client) and [server](https://github.com/WeboonTechnologySolution/ipw.co.za/tree/main/server) applications for more information.

## CONTRIBUTING INSTRUCTIONS

Add the staging and production deployment repositories:

    git remote add staging git@github.com:WeboonTechnologySolution/deployed-staging.ipw.co.za.git
    git remote add production git@github.com:WeboonTechnologySolution/deployed-ipw.co.za.git

Make and commit changes first to the [development repository](https://github.com/WeboonTechnologySolution/ipw.co.za):

    git add -A
    git commit -m 'Made some changes'
    git push

Next push the current state of the development repository to the [staging](https://github.com/WeboonTechnologySolution/deployed-staging.ipw.co.za) and/or [production](https://github.com/WeboonTechnologySolution/deployed-ipw.co.za) repositories as required:

    git push staging
    git push production

## Developer Setup Instructions

### Prerequisites
- Make sure you have NestJS CLI installed

### Setup Steps
1. Clone the repository
2. Setup the database using 'ipw_live.sql' found on Sharepoint
   > **Note:** This is a big file and it may take a while to import. You may need to update the import settings in MySQL Workbench to allow the process to complete.
3. Within the `/client` and `/server` folders, run `npm install` to install the dependencies
4. Within the `/client` and `/server` folders, create a `.env` file using the `.env.template` file as a reference
5. Within the `/server` folder, update the `.env` file to connect to the database and generate the secret key
6. Within the `/client` and `/server` folders, run `npm run start` to start the development server

### Port Configuration
- Backend port: 9000
- Frontend port: 8080

### Known Issues
- **Frontend Issue:** The frontend is not working as expected. It is not showing any errors and the page is blank. Investigation shows that the problem is with a newer version of dart sass and old syntax being dropped. [Reference Issue](https://github.com/nuxt/nuxt/issues/31265)