mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 17:11:17 +00:00
feat(waitlist): add trouble message and improve error handling
Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -56,3 +56,10 @@ export function duplicateEmailMessage(): SystemMessage {
|
|||||||
message: `I appreciate your excitement! You are already on the waitlist. When I am ready, I will reach out again. Have a good ${timeOfDay()} :)`,
|
message: `I appreciate your excitement! You are already on the waitlist. When I am ready, I will reach out again. Have a good ${timeOfDay()} :)`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function troubleMessage(): SystemMessage {
|
||||||
|
return {
|
||||||
|
role: "system",
|
||||||
|
message: `I apologize, but I am having trouble adding you to the waitlist. Could you refresh the page and try again please in a moment?`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { ChatBox } from "~/chat/chat-box"
|
|||||||
import {
|
import {
|
||||||
duplicateEmailMessage,
|
duplicateEmailMessage,
|
||||||
INITLAL_MESSAGES,
|
INITLAL_MESSAGES,
|
||||||
|
troubleMessage,
|
||||||
waitListJoinedMessage,
|
waitListJoinedMessage,
|
||||||
type Message,
|
type Message,
|
||||||
type SystemMessage,
|
type SystemMessage,
|
||||||
@@ -111,10 +112,19 @@ export default function Home() {
|
|||||||
if (fetcher.data?.email && !isAnimatingSend) {
|
if (fetcher.data?.email && !isAnimatingSend) {
|
||||||
setMessages((messages) => [...messages, waitListJoinedMessage(fetcher.data.email)])
|
setMessages((messages) => [...messages, waitListJoinedMessage(fetcher.data.email)])
|
||||||
} else if (fetcher.data?.error) {
|
} else if (fetcher.data?.error) {
|
||||||
if (fetcher.data.error === FormError.Duplicate && !isAnimatingSend) {
|
if (!isAnimatingSend) {
|
||||||
setMessages((messages) => [...messages, duplicateEmailMessage()])
|
let errorMessage: SystemMessage
|
||||||
} else {
|
switch (fetcher.data.error) {
|
||||||
console.error(fetcher.data.error)
|
case FormError.Duplicate:
|
||||||
|
errorMessage = duplicateEmailMessage()
|
||||||
|
break
|
||||||
|
default: {
|
||||||
|
console.error(fetcher.data.error)
|
||||||
|
errorMessage = troubleMessage()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setMessages((messages) => [...messages, errorMessage])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [fetcher.data?.email, fetcher.data?.error, isAnimatingSend])
|
}, [fetcher.data?.email, fetcher.data?.error, isAnimatingSend])
|
||||||
@@ -196,6 +206,12 @@ export default function Home() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{chatBox}
|
{chatBox}
|
||||||
|
<ProgressiveBlur direction="up" className="absolute bottom-0 left-0 right-0 h-24 z-10 pointer-events-none" />
|
||||||
|
<footer className="absolute bottom-4 z-20">
|
||||||
|
<Link to="/privacy" className="text-xs opacity-50 underline">
|
||||||
|
Privacy policy
|
||||||
|
</Link>
|
||||||
|
</footer>
|
||||||
</main>
|
</main>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user