#!/bin/bash

# Create standard main.tsx for all apps
create_main() {
  cat > "$1/main.tsx" << 'MAIN'
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);
MAIN
}

# Create standard vite.config.ts for all apps
create_vite() {
  cat > "$1/vite.config.ts" << 'VITE'
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
  build: {
    outDir: 'dist',
    emptyOutDir: true,
  },
});
VITE
}

# Create directories
for app in org-chart payroll-dashboard payroll-detail time-tracker timesheet-approvals time-off-calendar benefits-overview benefits-enrollment ats-pipeline job-board candidate-detail learning-dashboard course-catalog device-inventory app-management team-overview department-grid; do
  mkdir -p "$app"
  create_main "$app"
  create_vite "$app"
done

echo "Standard files created for all apps"
