import PropTypes from 'prop-types';
import dayjs from 'dayjs';
import { HStack } from '@astryxdesign/core/HStack';
import { VStack } from '@astryxdesign/core/VStack';
import { Text } from '@astryxdesign/core/Text';
import { CHIP_LABELS } from './pageContext';
// ==============================|| Doormile AI — welcome state ||============================== //
//
// Shown only when the thread is empty. Deliberately top-weighted and compact
// so the panel never opens on a large blank region: greeting + one line of
// what it can do, then straight into four suggestions.
const greeting = () => {
const h = dayjs().hour();
if (h < 12) return 'Good morning';
if (h < 17) return 'Good afternoon';
return 'Good evening';
};
// A chip, not a row.
//
// These used to be full-width rows: a 26px icon tile, the question, and a
// reveal-on-hover arrow, stacked one per line. That reads fine for four
// suggestions and falls apart at twenty — the panel opened on a wall of
// identical boxes that had to be read top to bottom, and the whole welcome
// state scrolled.
//
// As chips they flow into a block that is scanned rather than read: each one
// is only as wide as its question, so the varying widths give the eye
// something to land on, and twenty of them occupy a few rows instead of
// twenty. The icon stays as a small inline glyph for recognition; the arrow
// is gone, because on a chip it was decoration competing with the label.
const SuggestionChip = ({ item, onAsk }) => {
const Icon = item.icon;
// Display short, ask long. `item.text` is what intents.js matches on, so it
// is what gets asked and what assistive tech announces; the chip only shows
// a trimmed version of it so twenty of them fit in a few rows.
const label = CHIP_LABELS[item.text] || item.text;
return (
);
};
SuggestionChip.propTypes = {
item: PropTypes.shape({ icon: PropTypes.elementType.isRequired, text: PropTypes.string.isRequired }).isRequired,
onAsk: PropTypes.func.isRequired
};
// Exported so AIPanel can render it directly above the composer rather than
// inside the scrolling body. The chips are a way to START a message, so they
// belong with the input, not buried in the welcome copy where they scrolled
// out of reach the moment a conversation began.
export const SuggestionChips = ({ items, onAsk }) => (
{items.map((item) => (
))}
);
SuggestionChips.propTypes = {
items: PropTypes.array.isRequired,
onAsk: PropTypes.func.isRequired
};
const AIWelcome = () => {
return (
{greeting()}How can I help with today’s operations?
I read live orders, riders, vehicles and hubs. Every number comes from a real call — I never estimate one.
);
};
AIWelcome.propTypes = {
onAsk: PropTypes.func
};
export default AIWelcome;