Skip to content

Commit

Permalink
Ok
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt committed May 3, 2024
1 parent 8aa445e commit 957fa04
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/frontend/pages/datasets/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { modals } from "@mantine/modals"
import { IconCircleMinus, IconPlus } from "@tabler/icons-react"
import { useRouter } from "next/router"
import { useEffect, useState } from "react"
import { notifications } from "@mantine/notifications"

function PromptVariation({ i, variationId, content, onDelete, markSaved }) {
const { variation, update, remove, mutate } =
Expand Down Expand Up @@ -101,8 +102,8 @@ function PromptVariation({ i, variationId, content, onDelete, markSaved }) {
{prompt?.variations?.length > 1 && (
<ActionIcon
onClick={async () => {
onDelete()
await remove()
onDelete()
}}
pos="absolute"
top={-25}
Expand All @@ -117,7 +118,7 @@ function PromptVariation({ i, variationId, content, onDelete, markSaved }) {
)
}

function PromptTab({ isText, promptId, onDelete, markSaved }) {
function PromptTab({ isText, promptId, onDelete, markSaved, canBeDeleted }) {
const {
prompt,
update,
Expand Down Expand Up @@ -215,8 +216,16 @@ function PromptTab({ isText, promptId, onDelete, markSaved }) {
labels: { confirm: "Confirm", cancel: "Cancel" },

onConfirm: async () => {
onDelete()
await remove()
if (canBeDeleted) {
await remove()
onDelete()
} else {
notifications.show({
title: "You can't delete this Prompt",
message: "You need at least one Prompt in your Dataset",
color: "red",
})
}
},
})
}}
Expand Down Expand Up @@ -358,6 +367,7 @@ export default function NewDataset() {
promptId={prompt.id}
isText={dataset?.format === "text"}
markSaved={markSaved}
canBeDeleted={dataset?.prompts?.length > 1}
onDelete={() => {
mutate({
...dataset,
Expand Down

0 comments on commit 957fa04

Please sign in to comment.