fix: move initialLeadState out of use-server file into lead-types.ts
This commit is contained in:
@@ -19,9 +19,9 @@ import {
|
|||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import {
|
import {
|
||||||
createLeadAction,
|
createLeadAction,
|
||||||
initialLeadState,
|
|
||||||
updateLeadAction,
|
updateLeadAction,
|
||||||
} from "@/lib/appwrite/lead-actions";
|
} from "@/lib/appwrite/lead-actions";
|
||||||
|
import { initialLeadState } from "@/lib/appwrite/lead-types";
|
||||||
|
|
||||||
import { LEAD_SOURCE_LABEL, LEAD_STATUS_CONFIG, type LeadRow, type MemberOption } from "./types";
|
import { LEAD_SOURCE_LABEL, LEAD_STATUS_CONFIG, type LeadRow, type MemberOption } from "./types";
|
||||||
|
|
||||||
|
|||||||
@@ -5,20 +5,12 @@ import { AppwriteException, ID, Permission, Role } from "node-appwrite";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { logAudit } from "./audit";
|
import { logAudit } from "./audit";
|
||||||
|
import type { LeadActionState } from "./lead-types";
|
||||||
import { DATABASE_ID, TABLES, type Lead, type LeadStatus } from "./schema";
|
import { DATABASE_ID, TABLES, type Lead, type LeadStatus } from "./schema";
|
||||||
import { createAdminClient } from "./server";
|
import { createAdminClient } from "./server";
|
||||||
import { requireTenant } from "./tenant-guard";
|
import { requireTenant } from "./tenant-guard";
|
||||||
import { leadSchema } from "@/lib/validation/leads";
|
import { leadSchema } from "@/lib/validation/leads";
|
||||||
|
|
||||||
export type LeadActionState = {
|
|
||||||
ok: boolean;
|
|
||||||
error?: string;
|
|
||||||
fieldErrors?: Record<string, string>;
|
|
||||||
leadId?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const initialLeadState: LeadActionState = { ok: false };
|
|
||||||
|
|
||||||
function appwriteError(e: unknown): string {
|
function appwriteError(e: unknown): string {
|
||||||
if (e instanceof AppwriteException) return e.message || "Beklenmeyen bir hata oluştu.";
|
if (e instanceof AppwriteException) return e.message || "Beklenmeyen bir hata oluştu.";
|
||||||
return "Bağlantı hatası. Tekrar deneyin.";
|
return "Bağlantı hatası. Tekrar deneyin.";
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
export type LeadActionState = {
|
||||||
|
ok: boolean;
|
||||||
|
error?: string;
|
||||||
|
fieldErrors?: Record<string, string>;
|
||||||
|
leadId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const initialLeadState: LeadActionState = { ok: false };
|
||||||
Reference in New Issue
Block a user