# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default tseslint.config({
  extends: [
    // Remove ...tseslint.configs.recommended and replace with this
    ...tseslint.configs.recommendedTypeChecked,
    // Alternatively, use this for stricter rules
    ...tseslint.configs.strictTypeChecked,
    // Optionally, add this for stylistic rules
    ...tseslint.configs.stylisticTypeChecked,
  ],
  languageOptions: {
    // other options...
    parserOptions: {
      project: ['./tsconfig.node.json', './tsconfig.app.json'],
      tsconfigRootDir: import.meta.dirname,
    },
  },
})
```

You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default tseslint.config({
  plugins: {
    // Add the react-x and react-dom plugins
    'react-x': reactX,
    'react-dom': reactDom,
  },
  rules: {
    // other rules...
    // Enable its recommended typescript rules
    ...reactX.configs['recommended-typescript'].rules,
    ...reactDom.configs.recommended.rules,
  },
})
```


# Akashic Health Records WordPress Plugin

This repository contains the Akashic Health Records WordPress plugin. The development environment is set up using Docker to ensure consistency across all team members' machines.

## Development Environment Setup

### Prerequisites

- [Docker](https://www.docker.com/get-started) installed on your machine
- [Docker Compose](https://docs.docker.com/compose/install/) installed on your machine
- Git for version control

### Getting Started

1. Clone this repository:
   ```bash
   git clone https://github.com/your-org/akashic-wp-plugin.git
   cd akashic-wp-plugin
   ```

2. Make the development helper script executable:
   ```bash
   chmod +x dev.sh
   ```

3. Start the development environment:
   ```bash
   ./dev.sh start
   ```

4. Install WordPress (first time only):
   ```bash
   ./dev.sh install
   ```

5. Access your development site:
    - WordPress site: http://localhost:8080
    - WordPress admin: http://localhost:8080/wp-admin
    - Default admin credentials:
        - Username: admin
        - Password: password

### Development Workflow

The plugin directory is mounted into the WordPress container, so any changes you make to the plugin files will be immediately reflected in the running WordPress instance.

#### Common Tasks

- Start the environment: `./dev.sh start`
- Stop the environment: `./dev.sh stop`
- View logs: `./dev.sh logs`
- Access WordPress container shell: `./dev.sh shell`
- Run WP-CLI commands: `./dev.sh wp [command]`
    - Example: `./dev.sh wp plugin list`
- Build plugin assets: `./dev.sh build`
- Clean up everything (removes all data): `./dev.sh clean`

### Plugin Structure

- `akashic-health-records-patient-portal.php` - Main plugin file
- `includes/` - PHP classes and functionality
    - `admin/` - Admin-specific functionality
    - `frontend/` - Frontend functionality

### Development Guidelines

1. Always work in feature branches, not directly in `main`
2. Run `./dev.sh build` before committing changes to ensure assets are properly built
3. Test your changes thoroughly before submitting pull requests
4. Follow the WordPress [coding standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/)

## Troubleshooting

### Common Issues

1. **Port conflicts**: If port 8080 is already in use on your machine, modify the port mapping in `docker-compose.yml`.

2. **Database connection issues**: If WordPress can't connect to the database, try:
   ```bash
   ./dev.sh restart
   ```

3. **Plugin not activating**: Run:
   ```bash
   ./dev.sh wp plugin activate akashic-health-records-patient-portal
   ```

4. **Permissions issues**: If you encounter permission problems, run:
   ```bash
   sudo chown -R $USER:$USER .
   ```

### Resetting the Environment

If you need to start fresh:

```bash
./dev.sh clean
./dev.sh start
./dev.sh install
```

## Contributing

Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines on how to contribute to this project.

## Patient MVP Flow
See the canonical diagrams in the infrastructure repo:
https://github.com/Akashic-Health-Records/akashic-infrastructure/tree/main/docs