# cms-files

This repository contains static assets and scripts used across our CMS systems.

For more info, see:
[**Confluence Doc**](https://getolo.atlassian.net/wiki/spaces/PE/pages/122683451/Managing+files+for+different+CMS)

---

## Bundling implementation

⚠️ Bundling is currently a **manual process** and only applies to the funnel scripts located in `/src`

The bundled output is generated in: `shared/scripts/funnel-scripts`

### ⚙️ Environments

Supported environments:

- `development`
- `staging`
- `production`

⚠️ For `staging` and `production`, please copy the content of `.env.development` and update it with correct values.

#### 🔑 API keys

To view the dentist map locally, three API keys are required. Their values can be found in 1Password under these names:

| Env variable | 1Password name |
| --- | --- |
| `GTL_DENTIST_MAP_API_KEY` | CRM Dentist Map API Key |
| `GTL_GOOGLE_MAPS_API_KEY` | CRM Google Maps API Key |
| `GTL_IPGEOLOCATION_API_KEY` | CRM Geolocation API Key |

To set this up, create a `.env.development.local` file in the root folder alongside the other `.env` files and add these lines:

```bash
GTL_DENTIST_MAP_API_KEY=__key_value_from_1Password__
GTL_GOOGLE_MAPS_API_KEY=__key_value_from_1Password__
GTL_IPGEOLOCATION_API_KEY=__key_value_from_1Password__
```

`.env.development.local` is gitignored and overrides `.env.development` when running `npm run dev`. For staging and production builds, add the same keys to `.env.staging` and `.env.production`.

#### 🧪 Development (Local)

```bash
npm run dev
```

- Bundles the script and serves it locally at: `http://localhost:3100`

#### 🟠 Staging

> Need to run this manually and push the changes

```bash
npm run build:staging
```

- Generates a bundled file for **staging** with the `.staging` prefix

#### 🔴 Production

> Need to run this manually and push the changes

```bash
npm run build:prod
```

- Generates a bundled file for **production** with the `.min` prefix

## 🗺️ Dentist map

Moved from `faircare-home`. Source lives in `src/dentist-map`, the bundle and its assets (vendor scripts, marker images, iframe pages) in `shared/dentist-map`.

Add the script to a page and use one of these hooks:

```html
<!-- map rendered inside the element (min-height 480px) -->
<div class="js-embed-dentists-inline-map"></div>

<!-- modal opened on page load, without close button -->
<div class="js-embed-dentists-modal-map"></div>

<!-- modal opened on click -->
<a href="#" data-toggle-modal="modal-embed-map">Zahnärzte anzeigen</a>

<script src="<cms-files-url>/shared/dentist-map/index-dentist-map.min.js"></script>
```

For iframes, `shared/dentist-map/iframe_inline_map.html` and `shared/dentist-map/iframe_modal_map.html` replace the old faircare-home pages.

Required env vars: `GTL_DENTIST_MAP_API_URL`, `GTL_DENTIST_MAP_API_KEY`, `GTL_GOOGLE_MAPS_API_KEY`, `GTL_IPGEOLOCATION_API_KEY` (keys come from 1Password, see [API keys](#-api-keys)).

To build only this bundle:

```bash
npm run build:prod -- dentist-map
```

## 🚀 Deployment

ℹ️ **Nothing has changed regarding deployment process.**

### For the funnel scripts:

- Manually run the appropriate build command
- Commit the generated file
- Merge into the target branch
