Files
cal.diy/packages/app-store-cli/src/components/DeleteForm.tsx
T
Eunjae LeeandDevin AI 357c2882ad refactor: apply biome formatting to several packages (#27439)
* refactor: apply biome formatting to Phase 1 packages

Packages formatted:
- packages/app-store-cli
- packages/config
- packages/dayjs
- packages/debugging
- packages/embeds/embed-react
- packages/embeds/embed-snippet
- packages/kysely
- packages/platform/constants
- packages/platform/utils
- packages/testing
- packages/tsconfig

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: restore non-null assertions in embed-snippet to fix type error

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: remove ESM import from CommonJS config file

Biome incorrectly added 'import process from node:process' to a CommonJS
file that uses require(). This breaks Jest which expects CommonJS syntax.
The process global is already available in Node.js without explicit import.

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* refactor: exclude packages/embeds from Phase 1 formatting

Per user request, reverting all biome formatting changes in packages/embeds
to handle separately.

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

* fix: restore const enum for BookingLocations

Biome changed 'const enum' to 'enum' which is a semantic change.
Reverting to keep the PR purely formatting-only.

Co-Authored-By: eunjae@cal.com <hey@eunjae.dev>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-02-05 07:24:34 -03:00

108 lines
2.9 KiB
TypeScript

import { Text } from "ink";
import TextInput from "ink-text-input";
import { useEffect, useState } from "react";
import { ImportantText } from "../components/ImportantText";
import { Message } from "../components/Message";
import { BaseAppFork, generateAppFiles } from "../core";
import { getApp } from "../utils/getApp";
export default function DeleteForm({ slug, action }: { slug: string; action: "delete" | "delete-template" }) {
const [confirmedAppSlug, setConfirmedAppSlug] = useState("");
const [state, setState] = useState<
| "INITIALIZED"
| "DELETION_CONFIRMATION_FAILED"
| "DELETION_CONFIRMATION_SUCCESSFUL"
| "DELETION_COMPLETED"
| "APP_NOT_EXISTS"
>("INITIALIZED");
const isTemplate = action === "delete-template";
const app = getApp(slug, isTemplate);
useEffect(() => {
if (!app) {
setState("APP_NOT_EXISTS");
}
}, [app]);
useEffect(() => {
if (state === "DELETION_CONFIRMATION_SUCCESSFUL") {
(async () => {
await BaseAppFork.delete({ slug, isTemplate });
await generateAppFiles();
// successMsg({ text: `App with slug ${slug} has been deleted`, done: true });
setState("DELETION_COMPLETED");
})();
}
}, [slug, state, isTemplate]);
if (state === "INITIALIZED") {
return (
<>
<ImportantText>
Type below the slug of the {isTemplate ? "Template" : "App"} that you want to delete.
</ImportantText>
<Text color="gray" italic>
It would cleanup the app directory and App table and Credential table.
</Text>
<TextInput
value={confirmedAppSlug}
onSubmit={(value) => {
if (value === slug) {
setState("DELETION_CONFIRMATION_SUCCESSFUL");
} else {
setState("DELETION_CONFIRMATION_FAILED");
}
}}
onChange={(val) => {
setConfirmedAppSlug(val);
}}
/>
</>
);
}
if (state === "APP_NOT_EXISTS") {
return (
<Message
message={{
text: `${isTemplate ? "Template" : "App"} with slug ${slug} doesn't exist`,
type: "error",
}}
/>
);
}
if (state === "DELETION_CONFIRMATION_SUCCESSFUL") {
return (
<Message
message={{
text: `Deleting ${isTemplate ? "Template" : "App"}`,
type: "info",
showInProgressIndicator: true,
}}
/>
);
}
if (state === "DELETION_COMPLETED") {
return (
<Message
message={{
text: `${
isTemplate ? "Template" : "App"
} with slug "${slug}" has been deleted. You might need to restart your dev environment`,
type: "success",
}}
/>
);
}
if (state === "DELETION_CONFIRMATION_FAILED") {
return (
<Message
message={{
text: `Slug doesn't match - Should have been ${slug}`,
type: "error",
}}
/>
);
}
return null;
}