Minor fixes.

This commit is contained in:
Ivan Vasilov committed 2025-08-06 12:29:09 +02:00
1 parent eabe59d729
commit cd663a883b
3 files changed
+15 -9

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ import { v4 as uuidv4 } from 'uuid'
* @param inputs - The array of strings to generate a UUID from
* @returns A deterministic UUID v4 string
*/
export function generateDeterministicUuid(inputs: (string | null)[]): string {
export function generateDeterministicUuid(inputs: (string | undefined | null)[]): string {
const simpleHash = (str: string): number => {
let hash = 0
if (str.length === 0) return hash
@@ -104,18 +104,24 @@ const handlePost = async (req: NextApiRequest, res: NextApiResponse) => {
}
const handleDelete = async (req: NextApiRequest, res: NextApiResponse) => {
const { id } = req.query
const { ids } = req.query
if (!id || typeof id !== 'string') {
return res.status(400).json({ error: 'Snippet ID is required' })
if (!ids || typeof ids !== 'string') {
return res.status(400).json({ error: 'Snippet IDs are required' })
}
const snippetIds = ids.split(',').map((id) => id.trim())
if (snippetIds.length === 0) {
return res.status(400).json({ error: 'No snippet IDs provided' })
}
try {
await deleteSnippet(id)
return res.status(204).send(null)
for (const id of snippetIds) {
await deleteSnippet(id)
}
return res.status(200).send(snippetIds.map((id) => ({ id })))
} catch (error) {
console.error('Error deleting snippet:', error)
return res.status(500).json({ error: 'Failed to delete snippet' })
console.error('Error deleting snippets:', error)
return res.status(500).json({ error: 'Failed to delete snippets' })
}
}
+1 -1
View File
@@ -3,6 +3,7 @@ import { useEffect } from 'react'
import { useParams } from 'common/hooks/useParams'
import { SQLEditor } from 'components/interfaces/SQLEditor/SQLEditor'
import { untitledSnippetTitle } from 'components/interfaces/SQLEditor/SQLEditor.constants'
import DefaultLayout from 'components/layouts/DefaultLayout'
import { EditorBaseLayout } from 'components/layouts/editors/EditorBaseLayout'
import { useEditorType } from 'components/layouts/editors/EditorsLayout.hooks'
@@ -16,7 +17,6 @@ import { createTabId, useTabsStateSnapshot } from 'state/tabs'
import type { NextPageWithLayout } from 'types'
import { Button } from 'ui'
import { Admonition } from 'ui-patterns'
import { untitledSnippetTitle } from 'components/interfaces/SQLEditor/SQLEditor.constants'
const SqlEditor: NextPageWithLayout = () => {
const router = useRouter()