All files / src/features/project-actions handleSaveProject.ts

0% Statements 0/5
0% Branches 0/2
0% Functions 0/1
0% Lines 0/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                                         
import { projectService } from '@/entities/project/model/project.service';
import { exportMergedPNG } from '@/features/project-actions';
import { upsertProject } from '@/entities/project/model';
import type { Project } from '@/shared/types';
import type { AppDispatch } from '@/store';
 
export async function handleSaveProject(dispatch: AppDispatch, activeProject: Project) {
	if (!activeProject) return;
 
	const preview = await exportMergedPNG();
 
	// Save to the Dexie
	const updated = await projectService.updateProject({
		id: activeProject.id,
		changes: { snapshot: preview },
	});
 
	// update in the Redux
	dispatch(upsertProject(updated));
}