Skip to main content

People

The People interface represents a person/recipient in the system who can receive scheduled messages.

Type Definition

export interface People {
  id: string;
  name: string;
  phone: string;
}

Properties

id
string
required
Unique identifier for the person record.
name
string
required
The person’s full name. Must not be empty.
This name is displayed in the UI when showing message recipients.
phone
string
required
The person’s phone number in Bangladesh format.

Usage

This type is used throughout the application: In Components:
  • Messages.tsx:50 - Storing people list from API
  • Messages.tsx:56 - Passed to Message component
  • Messages.tsx:70 - Passed to CreateMessageForm
  • Messages.tsx:77 - Message component props
  • Messages.tsx:99 - Passed to MessageUpdateForm
In API Responses:
  • Returned from GET /people/all endpoint
  • Used in person creation operations
In Forms:
  • Used to populate recipient dropdowns in message forms
  • Displayed as options when creating/updating messages
Example Usage:
const response = await fetch('/people/all', {
  headers: {
    Authorization: `Basic ${credentials}`
  }
});

const people: People[] = await response.json();

people.forEach((person: People) => {
  console.log(`${person.name}: ${person.phone}`);
});

Phone Number Validation

The phone number format is enforced using Zod schema validation in server actions:
const personSchema = z.object({
  name: z.string().min(1, "Name cannot be empty"),
  phone: z
    .string()
    .regex(/^8801\d{9}$/, "Invalid phone number format. Must be 8801XXXXXXXXX"),
});
This validation ensures data consistency across the application.

Build docs developers (and LLMs) love