TODOs: - [x] Do restart when checkout / restore if there is a DB - [x] List all branches (branch id, name, date) - [x] Allow checking out versions with no DB - [x] safeguard to never delete main branches - [x] create app hook for neon template - [x] weird UX with connector on configure panel - [x] tiny neon logo in connector - [x] deploy to vercel - [x] build forgot password page - [x] what about email setup - [x] lots of imgix errors - [x] edit file - db snapshot - [x] DYAD_DISABLE_DB_PUSH - [ ] update portal doc - [x] switch preview branch to be read-only endpoint - [x] disable supabase sys prompt if neon is enabled - [ ] https://payloadcms.com/docs/upload/storage-adapters - [x] need to use main branch... Phase 2? - [x] generate DB migrations
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
import { IpcClient } from "@/ipc/ipc_client";
|
|
import { showError } from "@/lib/toast";
|
|
import type { CreateAppParams, CreateAppResult } from "@/ipc/ipc_types";
|
|
|
|
export function useCreateApp() {
|
|
const queryClient = useQueryClient();
|
|
|
|
const mutation = useMutation<CreateAppResult, Error, CreateAppParams>({
|
|
mutationFn: async (params: CreateAppParams) => {
|
|
if (!params.name.trim()) {
|
|
throw new Error("App name is required");
|
|
}
|
|
|
|
const ipcClient = IpcClient.getInstance();
|
|
return ipcClient.createApp(params);
|
|
},
|
|
onSuccess: () => {
|
|
// Invalidate apps list to trigger refetch
|
|
queryClient.invalidateQueries({ queryKey: ["apps"] });
|
|
},
|
|
onError: (error) => {
|
|
showError(error);
|
|
},
|
|
});
|
|
|
|
const createApp = async (
|
|
params: CreateAppParams,
|
|
): Promise<CreateAppResult> => {
|
|
return mutation.mutateAsync(params);
|
|
};
|
|
|
|
return {
|
|
createApp,
|
|
isCreating: mutation.isPending,
|
|
error: mutation.error,
|
|
};
|
|
}
|