From e069ca865cae8a411ef041f498fb8d7e28d75806 Mon Sep 17 00:00:00 2001 From: NotII <46204250+NotII@users.noreply.github.com> Date: Tue, 18 Mar 2025 04:05:16 +0100 Subject: [PATCH] Update NewChatForm.tsx --- components/dashboard/NewChatForm.tsx | 52 ++++++---------------------- 1 file changed, 11 insertions(+), 41 deletions(-) diff --git a/components/dashboard/NewChatForm.tsx b/components/dashboard/NewChatForm.tsx index 3a2cf10..d8fdb83 100644 --- a/components/dashboard/NewChatForm.tsx +++ b/components/dashboard/NewChatForm.tsx @@ -179,11 +179,18 @@ export default function NewChatForm() { const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); - if (!buyerId || !selectedStore) { - toast.error("Please fill all required fields"); + if (!buyerId) { + toast.error("Please select a customer"); return; } + if (vendorStores.length === 0) { + toast.error("No store available. Please create a store first."); + return; + } + + const storeId = vendorStores[0]._id; + setLoading(true); try { const authAxios = getAuthAxios(); @@ -195,7 +202,7 @@ export default function NewChatForm() { const response = await authAxios.post("/chats/create", { buyerId, - storeId: selectedStore, + storeId: storeId, initialMessage: initialMessage.trim() || undefined }); @@ -305,43 +312,6 @@ export default function NewChatForm() { )} -
- - {vendorStores.length === 0 ? ( -
-

- No store available. Please create a store first. -

-
- ) : vendorStores.length === 1 ? ( -
-

- {vendorStores[0].name} -

- -
- ) : ( - - )} -
-