mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 00:51:20 +00:00
fix(waitlist): fix timeOfDay logic, typo, and add audienceId
Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -12,17 +12,18 @@ export interface SystemMessage {
|
|||||||
export type Message = UserMessage | SystemMessage
|
export type Message = UserMessage | SystemMessage
|
||||||
|
|
||||||
function timeOfDay() {
|
function timeOfDay() {
|
||||||
const now = new Date()
|
const hours = new Date().getHours()
|
||||||
const hours = now.getHours()
|
if (hours >= 5 && hours < 12) {
|
||||||
if (hours >= 6 && hours <= 9) {
|
return "morning"
|
||||||
|
} else if (hours >= 12 && hours < 18) {
|
||||||
|
return "afternoon"
|
||||||
|
} else if (hours >= 18 && hours < 22) {
|
||||||
return "evening"
|
return "evening"
|
||||||
} else if (hours > 9 || hours <= 4) {
|
}
|
||||||
return "night"
|
return "night"
|
||||||
}
|
}
|
||||||
return "day"
|
|
||||||
}
|
|
||||||
|
|
||||||
export const INITLAL_MESSAGES: Message[] = [
|
export const INITIAL_MESSAGES: Message[] = [
|
||||||
{
|
{
|
||||||
role: "user",
|
role: "user",
|
||||||
message: "Who are you?",
|
message: "Who are you?",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Streamdown } from "streamdown"
|
|||||||
import { ChatBox } from "~/chat/chat-box"
|
import { ChatBox } from "~/chat/chat-box"
|
||||||
import {
|
import {
|
||||||
duplicateEmailMessage,
|
duplicateEmailMessage,
|
||||||
INITLAL_MESSAGES,
|
INITIAL_MESSAGES,
|
||||||
troubleMessage,
|
troubleMessage,
|
||||||
waitListJoinedMessage,
|
waitListJoinedMessage,
|
||||||
type Message,
|
type Message,
|
||||||
@@ -62,7 +62,10 @@ export async function action({ request }: Route.ActionArgs) {
|
|||||||
|
|
||||||
const resend = new Resend(process.env.RESEND_API_KEY)
|
const resend = new Resend(process.env.RESEND_API_KEY)
|
||||||
|
|
||||||
|
const audienceId = process.env.RESEND_AUDIENCE_ID!
|
||||||
|
|
||||||
const dup = await resend.contacts.get({
|
const dup = await resend.contacts.get({
|
||||||
|
audienceId,
|
||||||
email,
|
email,
|
||||||
})
|
})
|
||||||
if (dup.data) {
|
if (dup.data) {
|
||||||
@@ -70,13 +73,8 @@ export async function action({ request }: Route.ActionArgs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const res = await resend.contacts.create({
|
const res = await resend.contacts.create({
|
||||||
|
audienceId,
|
||||||
email,
|
email,
|
||||||
segments: [
|
|
||||||
{
|
|
||||||
// resend segment id for "Waitlist" segment
|
|
||||||
id: "b80fb036-74a1-4f7d-bca5-2c035b696071",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
@@ -101,7 +99,7 @@ export async function action({ request }: Route.ActionArgs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const [messages, setMessages] = useState<Message[]>(INITLAL_MESSAGES)
|
const [messages, setMessages] = useState<Message[]>(INITIAL_MESSAGES)
|
||||||
const [emailSent, setEmailSent] = useState("")
|
const [emailSent, setEmailSent] = useState("")
|
||||||
const [isAnimatingSend, setIsAnimatingSend] = useState(false)
|
const [isAnimatingSend, setIsAnimatingSend] = useState(false)
|
||||||
const [logoState, setLogoState] = useState<TAnimatedLogoState>(AnimatedLogoState.Idle)
|
const [logoState, setLogoState] = useState<TAnimatedLogoState>(AnimatedLogoState.Idle)
|
||||||
|
|||||||
Reference in New Issue
Block a user