mirror of
https://github.com/johndoe6345789/snippet-pastebin.git
synced 2026-04-24 13:34:55 +00:00
Generated by Spark: Weird issue, I made a snippet from template but it didn't add it to the homepage when I submitted. Can we use sqlite?
This commit is contained in:
@@ -125,10 +125,10 @@ export function SnippetDialog({ open, onOpenChange, onSave, editingSnippet }: Sn
|
||||
<DialogContent className="sm:max-w-[900px] max-h-[90vh] overflow-hidden flex flex-col">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-2xl">
|
||||
{editingSnippet ? strings.snippetDialog.edit.title : strings.snippetDialog.create.title}
|
||||
{editingSnippet?.id ? strings.snippetDialog.edit.title : strings.snippetDialog.create.title}
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
{editingSnippet
|
||||
{editingSnippet?.id
|
||||
? strings.snippetDialog.edit.description
|
||||
: strings.snippetDialog.create.description}
|
||||
</DialogDescription>
|
||||
|
||||
@@ -45,7 +45,7 @@ export function SnippetManager() {
|
||||
}, [snippets, searchQuery])
|
||||
|
||||
const handleSaveSnippet = useCallback((snippetData: Omit<Snippet, 'id' | 'createdAt' | 'updatedAt'>) => {
|
||||
if (editingSnippet) {
|
||||
if (editingSnippet?.id) {
|
||||
setSnippets((currentSnippets) => {
|
||||
const allSnippets = currentSnippets || []
|
||||
return allSnippets.map((s) =>
|
||||
@@ -104,8 +104,7 @@ export function SnippetManager() {
|
||||
const template = templates.find((t) => t.id === templateId)
|
||||
if (!template) return
|
||||
|
||||
const templateSnippet: Snippet = {
|
||||
id: Date.now().toString(),
|
||||
const templateSnippet = {
|
||||
title: template.title,
|
||||
description: template.description,
|
||||
language: template.language,
|
||||
@@ -113,11 +112,9 @@ export function SnippetManager() {
|
||||
category: template.category,
|
||||
hasPreview: template.hasPreview,
|
||||
functionName: template.functionName,
|
||||
createdAt: Date.now(),
|
||||
updatedAt: Date.now(),
|
||||
}
|
||||
} as Partial<Snippet>
|
||||
|
||||
setEditingSnippet(templateSnippet)
|
||||
setEditingSnippet(templateSnippet as Snippet)
|
||||
setDialogOpen(true)
|
||||
}, [])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user