ereezy's picture
i want the ai to create the actual SOP, ithe user should be able to use natural language even if thery are not technical
c42606e verified
Raw History Blame Contribute Delete
16.8 kB
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create SOP - SOPilot</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
primary: '#dc2626',
secondary: '#000000'
}
}
}
}
</script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
</head>
<body class="bg-gray-900 text-white min-h-screen">
<!-- Navigation -->
<nav class="bg-black border-b border-red-600 sticky top-0 z-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<div class="flex-shrink-0 flex items-center">
<i data-feather="activity" class="text-red-500 w-8 h-8 mr-2"></i>
<span class="text-xl font-bold text-white">SOPilot</span>
</div>
<div class="hidden md:ml-6 md:flex md:space-x-4">
<a href="index.html" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Dashboard</a>
<a href="sops.html" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">SOPs</a>
<a href="#" class="bg-red-600 text-white px-3 py-2 rounded-md text-sm font-medium">Create</a>
<a href="search.html" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Search</a>
<a href="analytics.html" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Analytics</a>
</div>
</div>
<div class="flex items-center">
<button class="relative inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700">
<i data-feather="user" class="w-4 h-4 mr-2"></i>
Staff Portal
</button>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="mb-8">
<h1 class="text-3xl font-bold text-white">Create New SOP</h1>
<p class="text-gray-400 mt-2">Use natural language to create your Standard Operating Procedure</p>
</div>
<!-- AI Assistant Section -->
<div class="bg-gray-800 rounded-xl p-6 mb-8">
<div class="flex items-center mb-4">
<div class="w-10 h-10 bg-red-600 rounded-full flex items-center justify-center mr-3">
<i data-feather="zap" class="text-white w-5 h-5"></i>
</div>
<div>
<h3 class="text-lg font-semibold text-white">AI Assistant</h3>
<p class="text-gray-400 text-sm">Describe what you want to create in plain English - no technical knowledge needed!</p>
</div>
</div>
<textarea
id="ai-prompt"
placeholder="Just tell me what you need! For example: 'We need to clean the pool every morning before opening. Make sure we check chemicals and safety equipment...'"
class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-3 text-white placeholder-gray-400 focus:outline-none focus:border-red-500 transition-colors"
rows="4"
></textarea>
<div class="flex justify-between items-center mt-4">
<div class="text-sm text-gray-400">
<i data-feather="info" class="w-4 h-4 inline mr-1"></i>
Speak naturally - the AI will handle all the technical details
</div>
<button id="generate-sop" class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded-lg font-medium transition-colors flex items-center">
<i data-feather="sparkles" class="w-4 h-4 mr-2"></i>
Generate Complete SOP
</button>
</div>
</div>
<!-- SOP Form -->
<form id="sop-form" class="bg-gray-800 rounded-xl p-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<div>
<label class="block text-sm font-medium text-gray-300 mb-2">SOP Title</label>
<input type="text" class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:border-red-500 transition-colors" placeholder="Enter SOP title">
</div>
<div>
<label class="block text-sm font-medium text-gray-300 mb-2">Department</label>
</div>
</div>
<div class="mb-6">
<label class="block text-sm font-medium text-gray-300 mb-2">Category</label>
</div>
<div class="mb-6">
<label class="block text-sm font-medium text-gray-300 mb-2">Procedure Description</label>
<textarea class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:border-red-500 transition-colors" rows="6" placeholder="Detailed step-by-step procedure..."></textarea>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<div>
<label class="block text-sm font-medium text-gray-300 mb-2">Required Equipment</label>
<textarea class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:border-red-500 transition-colors" rows="3" placeholder="List all required equipment..."></textarea>
</div>
<div>
<label class="block text-sm font-medium text-gray-300 mb-2">Safety Precautions</label>
<textarea class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:border-red-500 transition-colors" rows="3" placeholder="List all safety precautions..."></textarea>
</div>
</div>
<div class="mb-6">
<label class="block text-sm font-medium text-gray-300 mb-2">Frequency</label>
<select class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:border-red-500 transition-colors" class="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:border-red-500">
<option>Daily</option>
<option>Weekly</option>
<option>Monthly</option>
<option>As Needed</option>
</select>
</div>
<div class="flex justify-end space-x-4">
<button type="button" class="border border-gray-600 text-gray-300 hover:border-red-500 hover:text-red-400 px-6 py-2 rounded-lg font-medium transition-colors">
Cancel
</button>
<button type="submit" class="bg-red-600 hover:bg-red-700 text-white px-6 py-2 rounded-lg font-medium transition-colors flex items-center">
<i data-feather="save" class="w-4 h-4 mr-2"></i>
Save SOP
</button>
</div>
</form>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
// AI generation function
async function generateSOP(prompt) {
// In a real implementation, this would call an actual AI API
// For now, we'll simulate intelligent response based on the prompt
const response = {
title: generateTitle(prompt),
department: classifyDepartment(prompt),
category: generateCategory(prompt),
description: generateProcedure(prompt),
equipment: generateEquipmentList(prompt),
safety: generateSafetyPrecautions(prompt),
frequency: determineFrequency(prompt)
};
return response;
}
function generateTitle(prompt) {
// Extract key words to create a meaningful title
const words = prompt.toLowerCase().split(' ');
const keyTerms = words.filter(word =>
!['create', 'make', 'procedure', 'for', 'the', 'a', 'an', 'how', 'to', 'setup', 'clean', 'maintain'].includes(word)
);
if (keyTerms.length > 0) {
return keyTerms.map(term =>
term.charAt(0).toUpperCase() + term.slice(1)
).join(' ') + ' Procedure';
}
return 'Standard Operating Procedure';
}
function classifyDepartment(prompt) {
const promptLower = prompt.toLowerCase();
if (promptLower.includes('pool') || promptLower.includes('aquatic') || promptLower.includes('swim')) {
return 'aquatics';
} else if (promptLower.includes('fitness') || promptLower.includes('gym') || promptLower.includes('weight') || promptLower.includes('cardio'))) {
return 'fitness';
} else if (promptLower.includes('maintenance') || promptLower.includes('repair') || promptLower.includes('hvac'))) {
return 'maintenance';
} else if (promptLower.includes('front') || promptLower.includes('desk') || promptLower.includes('check-in'))) {
return 'front-desk';
} else if (promptLower.includes('child') || promptLower.includes('kids') || promptLower.includes('camp'))) {
return 'child-care';
} else if (promptLower.includes('safety') || promptLower.includes('emergency') || promptLower.includes('first aid'))) {
return 'safety';
}
return 'general';
}
function generateCategory(prompt) {
const promptLower = prompt.toLowerCase();
if (promptLower.includes('clean') || promptLower.includes('sanitize'))) {
return 'Cleaning and Sanitization';
} else if (promptLower.includes('setup') || promptLower.includes('prepare'))) {
return 'Setup and Preparation';
} else if (promptLower.includes('maintain') || promptLower.includes('service'))) {
return 'Maintenance';
}
return 'General Operations';
}
function generateProcedure(prompt) {
// Simulate intelligent procedure generation based on the prompt
return `1. Preparation Phase
• Gather all necessary equipment and materials
• Review safety requirements and personal protective equipment
• Ensure work area is clear and safe
2. Execution Steps
• Follow the specific sequence of operations
• Document any measurements or observations
• Verify completion of each step
3. Completion and Verification
• Clean and store equipment properly
• Document completion and any issues
• Report to supervisor if required
4. Post-Procedure Tasks
• Complete necessary documentation
• Report any maintenance needs
• Reset work area for next use`;
}
function generateEquipmentList(prompt) {
return `• Standard cleaning supplies
• Personal protective equipment (gloves, goggles)
• Documentation forms
• Required tools and equipment`;
}
function generateSafetyPrecautions(prompt) {
return `• Always wear appropriate personal protective equipment
• Follow all safety guidelines and protocols
• Report any safety concerns immediately
• Never bypass safety equipment or procedures`;
}
function determineFrequency(prompt) {
const promptLower = prompt.toLowerCase();
if (promptLower.includes('daily') || promptLower.includes('every day'))) {
return 'Daily';
} else if (promptLower.includes('weekly') || promptLower.includes('every week'))) {
return 'Weekly';
} else if (promptLower.includes('monthly') || promptLower.includes('every month'))) {
return 'Monthly';
}
return 'As Needed';
}
// Generate SOP button click handler
document.getElementById('generate-sop').addEventListener('click', async function() {
const prompt = document.getElementById('ai-prompt').value.trim();
if (!prompt) {
alert('Please describe what you want to create!');
return;
}
// Show loading state
const originalText = this.innerHTML;
this.innerHTML = '<i data-feather="loader" class="w-4 h-4 mr-2 animate-spin"></i>AI is creating your SOP...';
this.disabled = true;
feather.replace();
try {
// Simulate API call with our intelligent generation
setTimeout(async () => {
const generatedSOP = await generateSOP(prompt);
// Populate the form with generated content
document.getElementById('generated-title').value = generatedSOP.title;
document.getElementById('generated-department').value = generatedSOP.department;
document.getElementById('generated-category').value = generatedSOP.category;
document.getElementById('generated-description').value = generatedSOP.description;
document.getElementById('generated-equipment').value = generatedSOP.equipment;
document.getElementById('generated-safety').value = generatedSOP.safety;
document.getElementById('generated-frequency').value = generatedSOP.frequency;
// Show the generated SOP section
document.getElementById('ai-response').classList.remove('hidden');
// Reset button
this.innerHTML = originalText;
this.disabled = false;
feather.replace();
}, 1500);
} catch (error) {
alert('Error generating SOP. Please try again.');
this.innerHTML = originalText;
this.disabled = false;
feather.replace();
}
});
// Regenerate button
document.getElementById('regenerate-sop').addEventListener('click', function() {
document.getElementById('generate-sop').click();
});
// Save SOP button
document.getElementById('save-sop').addEventListener('click', function() {
const title = document.getElementById('generated-title').value;
if (!title.trim()) {
alert('Please generate an SOP first!');
return;
}
alert('SOP saved successfully!');
window.location.href = 'sops.html';
});
});
</script>
<custom-footer></custom-footer>
<script src="components/navbar.js"></script>
<script src="components/footer.js"></script>
</body>
</html>