113 lines
4.3 KiB
TypeScript
113 lines
4.3 KiB
TypeScript
import React from 'react';
|
|
import { XCircle, RefreshCw } from 'lucide-react';
|
|
import type { ModuleItem } from '../../types';
|
|
import { normalizeCategory } from '../../utils/category';
|
|
|
|
interface EditModuleModalProps {
|
|
module: ModuleItem | null;
|
|
name: string;
|
|
description: string;
|
|
category: string;
|
|
saving: boolean;
|
|
onNameChange: (val: string) => void;
|
|
onDescriptionChange: (val: string) => void;
|
|
onSave: (e: React.FormEvent) => void;
|
|
onClose: () => void;
|
|
}
|
|
|
|
export const EditModuleModal: React.FC<EditModuleModalProps> = ({
|
|
module,
|
|
name,
|
|
description,
|
|
category,
|
|
saving,
|
|
onNameChange,
|
|
onDescriptionChange,
|
|
onSave,
|
|
onClose,
|
|
}) => {
|
|
if (!module) return null;
|
|
|
|
return (
|
|
<div className="fixed inset-0 z-[150] flex items-center justify-center p-4 bg-slate-950/70 backdrop-blur-sm">
|
|
<div className="bg-white border border-slate-200 rounded-3xl p-6 w-full max-w-lg shadow-2xl space-y-5 animate-in fade-in duration-200">
|
|
<div className="flex items-center justify-between border-b border-slate-100 pb-3">
|
|
<div className="flex items-center gap-2">
|
|
<div
|
|
className="h-8 w-8 rounded-lg flex items-center justify-center font-bold text-white text-xs"
|
|
style={{ backgroundColor: (module as any).color || '#6366F1' }}
|
|
>
|
|
{(module.name || 'M')[0].toUpperCase()}
|
|
</div>
|
|
<div>
|
|
<h3 className="text-sm font-bold text-slate-800">Edit Clinical Module</h3>
|
|
<p className="text-[10px] text-slate-400 font-mono">{module.slug}</p>
|
|
</div>
|
|
</div>
|
|
<button
|
|
type="button"
|
|
onClick={onClose}
|
|
className="text-slate-400 hover:text-slate-600 p-1 cursor-pointer transition-colors"
|
|
>
|
|
<XCircle className="h-5 w-5" />
|
|
</button>
|
|
</div>
|
|
|
|
<form onSubmit={onSave} className="space-y-4">
|
|
<div>
|
|
<label className="block text-[10px] uppercase font-bold text-slate-500 mb-1">Display Name</label>
|
|
<input
|
|
type="text"
|
|
required
|
|
value={name}
|
|
onChange={(e) => onNameChange(e.target.value)}
|
|
className="w-full bg-white border border-slate-200 rounded-xl px-3 py-2 text-xs font-bold text-slate-800 focus:outline-none focus:border-indigo-500"
|
|
/>
|
|
</div>
|
|
|
|
<div>
|
|
<label className="block text-[10px] uppercase font-bold text-slate-500 mb-1">Category</label>
|
|
<input
|
|
type="text"
|
|
readOnly
|
|
disabled
|
|
value={normalizeCategory(category)}
|
|
className="w-full bg-slate-50 border border-slate-200 rounded-xl px-3 py-2 text-xs font-bold text-slate-500 cursor-not-allowed"
|
|
/>
|
|
<p className="text-[10px] text-slate-400 mt-1">
|
|
Category is fixed to keep core Complete Pack entitlements consistent. Use Plans & Pricing to create custom combo bundles.
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<label className="block text-[10px] uppercase font-bold text-slate-500 mb-1">Clinical Description</label>
|
|
<textarea
|
|
rows={3}
|
|
value={description}
|
|
onChange={(e) => onDescriptionChange(e.target.value)}
|
|
className="w-full bg-white border border-slate-200 rounded-xl px-3 py-2 text-xs font-medium text-slate-800 focus:outline-none focus:border-indigo-500"
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex gap-2 pt-2">
|
|
<button
|
|
type="button"
|
|
onClick={onClose}
|
|
className="flex-1 py-2 rounded-xl text-xs font-bold bg-slate-100 hover:bg-slate-200 text-slate-600 transition-colors cursor-pointer"
|
|
>
|
|
Cancel
|
|
</button>
|
|
<button
|
|
type="submit"
|
|
disabled={saving}
|
|
className="flex-1 py-2 rounded-xl text-xs font-bold bg-indigo-600 hover:bg-indigo-500 text-white transition-colors flex items-center justify-center gap-1.5 shadow-sm cursor-pointer disabled:opacity-50"
|
|
>
|
|
{saving ? <RefreshCw className="h-3.5 w-3.5 animate-spin" /> : 'Save Changes'}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|