HTOCHeader.tsx1 match
2import React from "https://esm.sh/react@18.2.0";
34export default function Header() {
5return (
6<header className="bg-indigo-600 text-white shadow-md">
13}
1415export default function App({ initialData }: AppProps) {
16const [properties, setProperties] = useState<Property[]>(initialData.properties);
17const [loading, setLoading] = useState(false);
67- `types.ts` - TypeScript interfaces used throughout the application
8- `utils.ts` - Utility functions for formatting and data manipulation
910## Usage
1// Format price as currency
2export function formatPrice(price: number): string {
3return new Intl.NumberFormat('en-US', {
4style: 'currency',
910// Format number with commas
11export function formatNumber(num: number): string {
12return new Intl.NumberFormat('en-US').format(num);
13}
1415// Format bathrooms (handle .5 for half baths)
16export function formatBathrooms(bathrooms: number): string {
17return bathrooms % 1 === 0 ? bathrooms.toString() : bathrooms.toFixed(1);
18}
21}
2223// Utility functions that work in both browser and Deno
24export function formatDate(dateString: string): string {
25if (!dateString) return '';
26const date = new Date(dateString);
32}
3334export function formatTime(dateString: string): string {
35if (!dateString) return '';
36const date = new Date(dateString);
4243// Validation utilities
44export function validateEmail(email: string): boolean {
45const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
46return re.test(email);
47}
4849export function validateJobPosting(job: Partial<JobPosting>): { valid: boolean; error?: string } {
50if (!job.title || job.title.trim() === '') {
51return { valid: false, error: 'Job title is required' };
1function app() {
2return {
3// State
218},
219220// Utility functions
221formatDate(dateString) {
222if (!dateString) return '';
1# Database Layer
23This directory contains the database schema and query functions for the House Hunter application.
45## Files
67- `migrations.ts` - Contains the database schema definitions and initial data seeding
8- `queries.ts` - Contains functions for querying the database
910## Schema
31## Usage
3233The database is automatically initialized when the application starts. The `runMigrations` function creates the necessary tables and seeds initial data if needed.
HTOCqueries.ts4 matches
3233// Get all properties with optional filtering
34export async function getProperties(filters: PropertyFilters = {}): Promise<Property[]> {
35let query = `SELECT * FROM ${PROPERTIES_TABLE} WHERE 1=1`;
36const params: any[] = [];
8586// Get a single property by ID
87export async function getPropertyById(id: number): Promise<Property | null> {
88const result = await sqlite.execute(
89`SELECT * FROM ${PROPERTIES_TABLE} WHERE id = ?`,
99100// Get cities for dropdown
101export async function getCities(): Promise<string[]> {
102const result = await sqlite.execute(
103`SELECT DISTINCT city FROM ${PROPERTIES_TABLE} ORDER BY city ASC`
108109// Get states for dropdown
110export async function getStates(): Promise<string[]> {
111const result = await sqlite.execute(
112`SELECT DISTINCT state FROM ${PROPERTIES_TABLE} ORDER BY state ASC`
HTOCmigrations.ts2 matches
56// Create tables if they don't exist
7export async function runMigrations() {
8// Properties table
9await sqlite.execute(`
3738// Seed some initial property data
39async function seedInitialData() {
40const properties = [
41{
Jop-Appqueries.ts7 matches
2324// Job Queries
25export async function getAllJobs(): Promise<JobPosting[]> {
26const result = await sqlite.execute(
27`SELECT * FROM ${JOBS_TABLE} ORDER BY created_at DESC`
30}
3132export async function getJobById(id: number): Promise<JobPosting | null> {
33const result = await sqlite.execute(
34`SELECT * FROM ${JOBS_TABLE} WHERE id = ?`,
38}
3940export async function createJob(job: JobPosting): Promise<number> {
41const now = new Date().toISOString();
42const result = await sqlite.execute(
58}
5960export async function updateJob(id: number, job: Partial<JobPosting>): Promise<boolean> {
61const now = new Date().toISOString();
62const currentJob = await getJobById(id);
89}
9091export async function deleteJob(id: number): Promise<boolean> {
92await sqlite.execute(`DELETE FROM ${JOBS_TABLE} WHERE id = ?`, [id]);
93return true;
9596// Chat Queries
97export async function getChatMessages(limit = 50): Promise<ChatMessage[]> {
98const result = await sqlite.execute(
99`SELECT * FROM ${CHAT_MESSAGES_TABLE} ORDER BY created_at DESC LIMIT ?`,
103}
104105export async function addChatMessage(message: ChatMessage): Promise<number> {
106const now = new Date().toISOString();
107const result = await sqlite.execute(