chat sessions in project view
This commit is contained in:
@@ -186,21 +186,21 @@ export async function fetchProjects() {
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function createProject({ name, description, colour, icon, projectOnly }) {
|
||||
export async function createProject({ name, description, colour, icon, isolated }) {
|
||||
const res = await fetch(`${BASE_URL}/projects`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name, description, colour, icon, projectOnly: projectOnly ? 1 : 0 }),
|
||||
body: JSON.stringify({ name, description, colour, icon, isolated: isolated ? 1 : 0 }),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to create project: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function updateProject(id, { name, description, colour, icon, projectOnly }) {
|
||||
export async function updateProject(id, { name, description, colour, icon, isolated }) {
|
||||
const res = await fetch(`${BASE_URL}/projects/${id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name, description, colour, icon, projectOnly: projectOnly ? 1 : 0}),
|
||||
body: JSON.stringify({ name, description, colour, icon, isolated: isolated ? 1 : 0}),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to update project: ${res.status}`);
|
||||
return res.json();
|
||||
|
||||
@@ -6,7 +6,7 @@ export default function ProjectModal({ project, mode, onSave, onDelete, onClose
|
||||
const [name, setName] = useState(project?.name ?? '');
|
||||
const [description, setDescription] = useState(project?.description ?? '');
|
||||
const [colour, setColour] = useState(project?.colour ?? COLOURS[0]);
|
||||
const [projectOnly, setProjectOnly] = useState(project?.projectOnly === 1);
|
||||
const [isolated, setIsolated] = useState(project?.isolated === 1);
|
||||
const inputRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -16,7 +16,7 @@ export default function ProjectModal({ project, mode, onSave, onDelete, onClose
|
||||
function handleSubmit() {
|
||||
const trimmed = name.trim();
|
||||
if (!trimmed) return;
|
||||
onSave({ name: trimmed, description: description.trim() || null, colour, icon: null, projectOnly });
|
||||
onSave({ name: trimmed, description: description.trim() || null, colour, icon: null, isolated });
|
||||
onClose();
|
||||
}
|
||||
|
||||
@@ -131,20 +131,20 @@ export default function ProjectModal({ project, mode, onSave, onDelete, onClose
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setProjectOnly(i => !i)}
|
||||
onClick={() => setIsolated(i => !i)}
|
||||
style={{
|
||||
width: '40px', height: '22px', borderRadius: '11px', flexShrink: 0,
|
||||
background: projectOnly ? 'var(--accent-hover)' : 'var(--bg-elevated)',
|
||||
background: isolated ? 'var(--accent-hover)' : 'var(--bg-elevated)',
|
||||
border: '1px solid var(--border)',
|
||||
position: 'relative', cursor: 'pointer', transition: 'background 0.2s',
|
||||
}}
|
||||
>
|
||||
<span style={{
|
||||
position: 'absolute', top: '3px',
|
||||
left: projectOnly ? '20px' : '3px',
|
||||
left: isolated ? '20px' : '3px',
|
||||
width: '14px', height: '14px',
|
||||
borderRadius: '50%',
|
||||
background: projectOnly ? 'white' : 'var(--text-muted)',
|
||||
background: isolated ? 'white' : 'var(--text-muted)',
|
||||
transition: 'left 0.2s',
|
||||
}} />
|
||||
</button>
|
||||
|
||||
@@ -72,7 +72,7 @@ export default function ProjectView({ project, onNavigate, onSelectSession, onNe
|
||||
<h1 style={{ fontSize: '22px', fontWeight: 600, color: 'var(--text-primary)' }}>
|
||||
{project.name}
|
||||
</h1>
|
||||
{project.projectOnly === 1 && (
|
||||
{project.isolated === 1 && (
|
||||
<span style={{
|
||||
fontSize: '11px', fontWeight: 500,
|
||||
padding: '2px 8px', borderRadius: '99px',
|
||||
|
||||
BIN
packages/files.zip
Normal file
BIN
packages/files.zip
Normal file
Binary file not shown.
@@ -1,12 +1,12 @@
|
||||
const { getDB } = require('./index');
|
||||
const { parseRow } = require('@nexusai/shared');
|
||||
|
||||
function createProject({ name, description, colour, icon, projectOnly }) {
|
||||
function createProject({ name, description, colour, icon, isolated }) {
|
||||
const db = getDB();
|
||||
const result = db.prepare(`
|
||||
INSERT INTO projects (name, description, colour, icon)
|
||||
VALUES (?, ?, ?, ?)
|
||||
`).run(name, description ?? null, colour ?? null, icon ?? null, projectOnly ?? 0);
|
||||
`).run(name, description ?? null, colour ?? null, icon ?? null, isolated ?? 0);
|
||||
return getProject(result.lastInsertRowid);
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ function getProject(id) {
|
||||
return parseRow(db.prepare(`SELECT * FROM projects WHERE id = ?`).get(id));
|
||||
}
|
||||
|
||||
function updateProject(id, { name, description, colour, icon, projectOnly }) {
|
||||
function updateProject(id, { name, description, colour, icon, isolated }) {
|
||||
const db = getDB();
|
||||
db.prepare(`
|
||||
UPDATE projects SET name = ?, description = ?, colour = ?, icon = ?, projectOnly = ?
|
||||
UPDATE projects SET name = ?, description = ?, colour = ?, icon = ?, isolated = ?
|
||||
WHERE id = ?
|
||||
`).run(name, description ?? null, colour ?? null, icon ?? null, projectOnly ?? 0, id);
|
||||
`).run(name, description ?? null, colour ?? null, icon ?? null, isolated ?? 0, id);
|
||||
return getProject(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ router.get('/', async (req, res) => {
|
||||
});
|
||||
|
||||
router.post('/', async (req, res) => {
|
||||
const { name, description, colour, icon, projectOnly } = req.body;
|
||||
const { name, description, colour, icon, isolated } = req.body;
|
||||
if (!name?.trim()) return res.status(400).json({ error: 'name is required' });
|
||||
try {
|
||||
res.status(201).json(await memory.createProject({ name: name.trim(), description, colour, icon, projectOnly }));
|
||||
res.status(201).json(await memory.createProject({ name: name.trim(), description, colour, icon, isolated }));
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user