-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproject-modal.tsx
70 lines (65 loc) · 2.19 KB
/
project-modal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React, { useContext, useState } from 'react';
import { ProjectContext, ProjectProvider } from './code-engine/project-context';
export interface Project {
id: string;
projectName: string;
projectPath: string;
createdAt: number;
updatedAt: number;
isActive: boolean;
isDeleted: boolean;
userId: string;
projectPackages: ProjectPackage[];
}
interface ProjectPackage {
name: string;
version: string;
}
const ProjectModal = ({ isOpen, onClose, refetchProjects }) => {
const [projectName, setProjectName] = useState('');
const [description, setDescription] = useState('');
const { createNewProject } = useContext(ProjectContext);
if (!isOpen) return null; // Don't render the modal when it's closed
return (
<div className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50">
<div className="bg-white p-6 rounded-lg shadow-lg w-96 z-50">
<h2 className="text-lg font-semibold mb-4">Create New Project</h2>
<form onSubmit={() => createNewProject(projectName, description)}>
<div className="mb-4">
<label className="block text-sm font-medium">Project Name</label>
<input
type="text"
className="w-full px-3 py-2 border rounded-md"
value={projectName}
onChange={(e) => setProjectName(e.target.value)}
/>
</div>
<div className="mb-4">
<label className="block text-sm font-medium">Description</label>
<textarea
className="w-full px-3 py-2 border rounded-md"
value={description}
onChange={(e) => setDescription(e.target.value)}
/>
</div>
<div className="flex justify-end">
<button
type="button"
className="px-4 py-2 mr-2 bg-gray-300 rounded"
onClick={onClose}
>
Cancel
</button>
<button
type="submit"
className="px-4 py-2 bg-blue-600 text-white rounded"
>
Submit
</button>
</div>
</form>
</div>
</div>
);
};
export default ProjectModal;