# pivot-expo

This is the cross-platform client application for the Pivot platform. We build for iOS, Android, and web based on this React Native project.

## React Storybook

It is worth reading this article on [Design System](https://storybook.js.org/tutorials/design-systems-for-developers/react/en/introduction/) in order to have a good idea of how we should be building some of our components and understanding [Storybook](https://storybook.js.org/) in general.https://storybook.js.org

## Important Storybook Links

> All references to `.js` or `.jsx` should be converted to `.ts` or `.tsx` respectively.

- [Configuration](https://storybook.js.org/docs/react/configure/overview)
- [Addons](https://storybook.js.org/docs/react/addons/introduction)
- [Theming](https://storybook.js.org/docs/react/configure/theming)
- [Writing Stories](https://storybook.js.org/docs/react/writing-stories/introduction)
- [Writing Documentation](https://storybook.js.org/docs/react/writing-docs/introduction)

## Testing

For testing we are using [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/) together with [Jest](https://jestjs.io/)

## GraphQL

### Apollo Studio

Create a new api key [here](https://studio.apollographql.com/user-settings?overlay=new-user-key) and add `APOLLO_KEY` to your global environment with the value of the newly created key.

- **Schema Generation**: We use [codegen](https://www.graphql-code-generator.com/) to generate our graphql schema. This helps us share types between our backend and frontend. We use [Apollo Rover](https://www.apollographql.com/docs/rover/getting-started/) to download the latest schema from [Apollo Studio](https://studio.apollographql.com/org/pivot/graphs).

## **Environment Variables**

Please make sure you have `.env` with values similar to the ones in `.env.example`. The environment variables are loaded inside `app.config.ts`. This makes sure that the environment variables needed by the app are available to the application before you can build or start.

### Importing and New Environment Variables.

You should only import the Config from `src/config`. When new variables are needed, make sure to add them to the
[interface](./src/config/environment.ts#EnvironmentVariables), [variables](./app.config.ts#variables), [.env](.env) and [.env](.env.example)

## Expo Dev Client

We have setup [expo-dev-client](https://docs.expo.dev/development/getting-started/) in our app to support the bare react-native libraries in our expo manged workflow.

To start expo-dev-cleint based project run `npm run start` inside `apps/expo`.
This will propmt QRCode and other options on the console, where you can selete and option for your desired platform to test your app.

If you want to start directly on a specific platform (ios/android)
then run bellow inside `apps/expo` :

- ios `npm run ios`

- android `npm run android`

### how expo-dev-client works

Above 2 scripts will build the project and launch on android/ios(device/simulator) in case you have ios/android folder inside `apps/expo`.
Otherwise it will generate android/ios folder inside `apps/expo`, install dependencies (In case dependencies installation fails you can manually install by `npm install` inside `apps/expo`), pod install (for ios only), build for android/ios and launch on android/android(device/simulator).
