Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Jesus-Puertos/h-ayuntamiento/llms.txt

Use this file to discover all available pages before exploring further.

Overview

This page documents all user-related TypeScript types used in the Zongolica application.

UserProfile

User profile stored in the user_profiles table.
interface UserProfile {
  id: string;
  email: string;
  full_name: string;
  avatar_url: string;
  provider: string;
  onboarding_completed: boolean;
  created_at: string;
  updated_at: string;
}

Field Descriptions

id
string
UUID - Primary key, references auth.users(id)
email
string
User’s email address from authentication provider
full_name
string
User’s full name
avatar_url
string
URL to user’s profile picture (from OAuth provider)
provider
string
Authentication provider (“google”, “facebook”, “email”)
onboarding_completed
boolean
Whether user has completed the onboarding flow
created_at
string
ISO 8601 timestamp of profile creation
updated_at
string
ISO 8601 timestamp of last profile update

Example

{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "email": "juan@example.com",
  "full_name": "Juan Pérez",
  "avatar_url": "https://lh3.googleusercontent.com/a/...",
  "provider": "google",
  "onboarding_completed": true,
  "created_at": "2024-03-15T10:30:00.000Z",
  "updated_at": "2024-03-15T10:30:00.000Z"
}

UserPreferences

User preferences collected during onboarding, stored in the user_preferences table.
interface UserPreferences {
  id?: string;
  user_id: string;
  experiencia: string[];
  duracion: string;
  dificultad: string;
  grupo: string;
  intereses: string[];
  created_at?: string;
}

Field Descriptions

id
string
UUID - Primary key (auto-generated)
user_id
string
UUID - References user_profiles(id)
experiencia
string[]
Types of experiences the user prefersPossible values:
  • “aventura” - Adventure activities
  • “naturaleza” - Nature and landscapes
  • “cultura” - Cultural experiences
  • “gastronomia” - Food and beverages
  • “relax” - Relaxation and wellness
duracion
string
Preferred duration of visitsPossible values:
  • “medio-dia” - Half day (2-4 hours)
  • “dia-completo” - Full day (6-8 hours)
  • “fin-de-semana” - Weekend (2-3 days)
dificultad
string
Physical difficulty level the user is comfortable withPossible values:
  • “facil” - Easy (accessible to all)
  • “moderado” - Moderate (requires some fitness)
  • “dificil” - Difficult (requires good physical condition)
grupo
string
Who the user typically travels withPossible values:
  • “solo” - Solo traveler
  • “pareja” - Couple
  • “familia” - Family with children
  • “amigos” - Friends
intereses
string[]
Specific interests and attractionsPossible values:
  • “cascadas” - Waterfalls
  • “miradores” - Viewpoints
  • “cuevas” - Caves
  • “senderismo” - Hiking
  • “rappel” - Rappelling
  • “kayak” - Kayaking
  • “historia” - History
  • “fotografia” - Photography
created_at
string
ISO 8601 timestamp (auto-generated)

Example

{
  "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
  "user_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "experiencia": ["aventura", "naturaleza"],
  "duracion": "dia-completo",
  "dificultad": "moderado",
  "grupo": "familia",
  "intereses": ["cascadas", "miradores", "senderismo"],
  "created_at": "2024-03-15T10:35:00.000Z"
}

UserFavorite

User’s favorite tourist attractions, stored in the user_favorites table.
interface UserFavorite {
  id: string;
  user_id: string;
  atractivo_slug: string;
  created_at: string;
}

Field Descriptions

id
string
UUID - Primary key (auto-generated)
user_id
string
UUID - References user_profiles(id)
atractivo_slug
string
Slug of the tourist attraction (e.g., “cascada-atlahuitzia”)
created_at
string
ISO 8601 timestamp when favorite was added

Example

{
  "id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
  "user_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "atractivo_slug": "cascada-atlahuitzia",
  "created_at": "2024-03-15T11:00:00.000Z"
}

Authentication Functions

Functions for user authentication.

signInWithGoogle()

Initiate Google OAuth sign-in flow.
function signInWithGoogle(redirectPath?: string): Promise<{
  data: AuthResponse | null;
  error: AuthError | null;
}>;
Parameters:
  • redirectPath (optional) - Path to redirect after authentication (default: /turismo?onboarding=1)
Example:
const { data, error } = await signInWithGoogle('/perfil');
if (error) {
  console.error('Sign in failed:', error);
}

signOut()

Sign out the current user.
function signOut(): Promise<{
  error: AuthError | null;
}>;
Example:
const { error } = await signOut();
if (!error) {
  window.location.href = '/';
}

getCurrentUser()

Get the currently authenticated user.
function getCurrentUser(): Promise<User | null>;
Example:
const user = await getCurrentUser();
if (user) {
  console.log('Logged in as:', user.email);
}

Profile Functions

Functions for managing user profiles.

getUserProfile()

Get user profile by ID.
function getUserProfile(userId: string): Promise<{
  data: UserProfile | null;
  error: PostgrestError | null;
}>;

upsertUserProfile()

Create or update user profile.
function upsertUserProfile(
  profile: Partial<UserProfile> & { id: string }
): Promise<{
  data: UserProfile | null;
  error: PostgrestError | null;
}>;

markOnboardingCompleted()

Mark user’s onboarding as completed.
function markOnboardingCompleted(userId: string): Promise<{
  data: UserProfile | null;
  error: PostgrestError | null;
}>;

isOnboardingCompleted()

Check if user has completed onboarding.
function isOnboardingCompleted(userId: string): Promise<boolean>;

getFullProfile()

Get complete user profile with preferences, badges, routes, and favorites.
function getFullProfile(userId: string): Promise<{
  profile: UserProfile | null;
  preferences: UserPreferences | null;
  badges: UserBadge[];
  routes: UserRoute[];
  favorites: UserFavorite[];
}>;
Example:
const profile = await getFullProfile(user.id);
console.log('User has', profile.badges.length, 'badges');
console.log('User has', profile.favorites.length, 'favorites');

Preference Functions

Functions for managing user preferences.

saveUserPreferences()

Save or update user preferences.
function saveUserPreferences(
  preferences: UserPreferences
): Promise<{
  data: UserPreferences | null;
  error: PostgrestError | null;
}>;

getUserPreferences()

Get user preferences.
function getUserPreferences(userId: string): Promise<{
  data: UserPreferences | null;
  error: PostgrestError | null;
}>;
Example:
const { data: prefs, error } = await getUserPreferences(user.id);
if (prefs) {
  console.log('User prefers:', prefs.experiencia);
}

Favorite Functions

Functions for managing favorites.

getUserFavorites()

Get all user favorites.
function getUserFavorites(userId: string): Promise<{
  data: UserFavorite[] | null;
  error: PostgrestError | null;
}>;

addFavorite()

Add an attraction to favorites.
function addFavorite(
  userId: string,
  atractivoSlug: string
): Promise<{
  data: UserFavorite | null;
  error: PostgrestError | null;
}>;

removeFavorite()

Remove an attraction from favorites.
function removeFavorite(
  userId: string,
  atractivoSlug: string
): Promise<{
  error: PostgrestError | null;
}>;

isFavorite()

Check if an attraction is favorited.
function isFavorite(
  userId: string,
  atractivoSlug: string
): Promise<boolean>;

toggleFavorite()

Toggle favorite status (add if not favorited, remove if favorited).
function toggleFavorite(
  userId: string,
  atractivoSlug: string
): Promise<boolean>; // Returns new favorite status
Example:
const isFav = await toggleFavorite(user.id, 'cascada-atlahuitzia');
if (isFav) {
  console.log('Added to favorites');
} else {
  console.log('Removed from favorites');
}

getFavoritesCount()

Get total number of favorites for a user.
function getFavoritesCount(userId: string): Promise<number>;