diff --git a/Backend/alembic/versions/1444eb61188e_add_section_title_fields_to_page_content.py b/Backend/alembic/versions/1444eb61188e_add_section_title_fields_to_page_content.py new file mode 100644 index 00000000..3f5845c1 --- /dev/null +++ b/Backend/alembic/versions/1444eb61188e_add_section_title_fields_to_page_content.py @@ -0,0 +1,246 @@ +"""add_section_title_fields_to_page_content + +Revision ID: 1444eb61188e +Revises: ff515d77abbe +Create Date: 2025-11-20 15:51:29.671843 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +# revision identifiers, used by Alembic. +revision = '1444eb61188e' +down_revision = 'ff515d77abbe' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index('bookings_room_id', table_name='bookings') + op.drop_index('bookings_status', table_name='bookings') + op.drop_index('bookings_user_id', table_name='bookings') + op.drop_index('ix_bookings_promotion_code', table_name='bookings') + op.create_index(op.f('ix_bookings_booking_number'), 'bookings', ['booking_number'], unique=True) + op.create_index(op.f('ix_bookings_id'), 'bookings', ['id'], unique=False) + op.drop_constraint('bookings_ibfk_1', 'bookings', type_='foreignkey') + op.drop_constraint('bookings_ibfk_2', 'bookings', type_='foreignkey') + op.create_foreign_key(None, 'bookings', 'rooms', ['room_id'], ['id']) + op.create_foreign_key(None, 'bookings', 'users', ['user_id'], ['id']) + op.drop_index('checkin_checkout_booking_id', table_name='checkin_checkout') + op.create_index(op.f('ix_checkin_checkout_id'), 'checkin_checkout', ['id'], unique=False) + op.create_unique_constraint(None, 'checkin_checkout', ['booking_id']) + op.drop_constraint('checkin_checkout_ibfk_1', 'checkin_checkout', type_='foreignkey') + op.drop_constraint('checkin_checkout_ibfk_2', 'checkin_checkout', type_='foreignkey') + op.drop_constraint('checkin_checkout_ibfk_3', 'checkin_checkout', type_='foreignkey') + op.create_foreign_key(None, 'checkin_checkout', 'users', ['checkin_by'], ['id']) + op.create_foreign_key(None, 'checkin_checkout', 'bookings', ['booking_id'], ['id']) + op.create_foreign_key(None, 'checkin_checkout', 'users', ['checkout_by'], ['id']) + op.drop_index('favorites_room_id', table_name='favorites') + op.drop_index('favorites_user_id', table_name='favorites') + op.drop_index('unique_user_room_favorite', table_name='favorites') + op.create_index(op.f('ix_favorites_id'), 'favorites', ['id'], unique=False) + op.drop_constraint('favorites_ibfk_1', 'favorites', type_='foreignkey') + op.drop_constraint('favorites_ibfk_2', 'favorites', type_='foreignkey') + op.create_foreign_key(None, 'favorites', 'rooms', ['room_id'], ['id']) + op.create_foreign_key(None, 'favorites', 'users', ['user_id'], ['id']) + op.add_column('page_contents', sa.Column('luxury_gallery_section_title', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('luxury_gallery_section_subtitle', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('luxury_testimonials_section_title', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('luxury_testimonials_section_subtitle', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('luxury_services_section_title', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('luxury_services_section_subtitle', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('luxury_experiences_section_title', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('luxury_experiences_section_subtitle', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('awards_section_title', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('awards_section_subtitle', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('partners_section_title', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('partners_section_subtitle', sa.Text(), nullable=True)) + op.alter_column('password_reset_tokens', 'used', + existing_type=mysql.TINYINT(display_width=1), + nullable=False, + existing_server_default=sa.text("'0'")) + op.drop_index('password_reset_tokens_token', table_name='password_reset_tokens') + op.drop_index('password_reset_tokens_user_id', table_name='password_reset_tokens') + op.drop_index('token', table_name='password_reset_tokens') + op.create_index(op.f('ix_password_reset_tokens_id'), 'password_reset_tokens', ['id'], unique=False) + op.create_index(op.f('ix_password_reset_tokens_token'), 'password_reset_tokens', ['token'], unique=True) + op.drop_constraint('password_reset_tokens_ibfk_1', 'password_reset_tokens', type_='foreignkey') + op.create_foreign_key(None, 'password_reset_tokens', 'users', ['user_id'], ['id']) + op.alter_column('payments', 'deposit_percentage', + existing_type=mysql.INTEGER(), + comment=None, + existing_comment='Percentage of deposit (e.g., 20, 30, 50)', + existing_nullable=True) + op.drop_index('payments_booking_id', table_name='payments') + op.drop_index('payments_payment_status', table_name='payments') + op.create_index(op.f('ix_payments_id'), 'payments', ['id'], unique=False) + op.drop_constraint('payments_ibfk_1', 'payments', type_='foreignkey') + op.drop_constraint('payments_related_payment_id_foreign_idx', 'payments', type_='foreignkey') + op.create_foreign_key(None, 'payments', 'payments', ['related_payment_id'], ['id']) + op.create_foreign_key(None, 'payments', 'bookings', ['booking_id'], ['id']) + op.drop_index('code', table_name='promotions') + op.drop_index('promotions_code', table_name='promotions') + op.drop_index('promotions_is_active', table_name='promotions') + op.create_index(op.f('ix_promotions_code'), 'promotions', ['code'], unique=True) + op.create_index(op.f('ix_promotions_id'), 'promotions', ['id'], unique=False) + op.drop_index('refresh_tokens_token', table_name='refresh_tokens') + op.drop_index('refresh_tokens_user_id', table_name='refresh_tokens') + op.drop_index('token', table_name='refresh_tokens') + op.create_index(op.f('ix_refresh_tokens_id'), 'refresh_tokens', ['id'], unique=False) + op.create_index(op.f('ix_refresh_tokens_token'), 'refresh_tokens', ['token'], unique=True) + op.drop_constraint('refresh_tokens_ibfk_1', 'refresh_tokens', type_='foreignkey') + op.create_foreign_key(None, 'refresh_tokens', 'users', ['user_id'], ['id']) + op.drop_index('reviews_room_id', table_name='reviews') + op.drop_index('reviews_status', table_name='reviews') + op.drop_index('reviews_user_id', table_name='reviews') + op.create_index(op.f('ix_reviews_id'), 'reviews', ['id'], unique=False) + op.drop_constraint('reviews_ibfk_2', 'reviews', type_='foreignkey') + op.drop_constraint('reviews_ibfk_1', 'reviews', type_='foreignkey') + op.create_foreign_key(None, 'reviews', 'users', ['user_id'], ['id']) + op.create_foreign_key(None, 'reviews', 'rooms', ['room_id'], ['id']) + op.drop_index('name', table_name='roles') + op.create_index(op.f('ix_roles_id'), 'roles', ['id'], unique=False) + op.create_index(op.f('ix_roles_name'), 'roles', ['name'], unique=True) + op.create_index(op.f('ix_room_types_id'), 'room_types', ['id'], unique=False) + op.drop_index('room_number', table_name='rooms') + op.drop_index('rooms_featured', table_name='rooms') + op.drop_index('rooms_room_type_id', table_name='rooms') + op.drop_index('rooms_status', table_name='rooms') + op.create_index(op.f('ix_rooms_id'), 'rooms', ['id'], unique=False) + op.create_index(op.f('ix_rooms_room_number'), 'rooms', ['room_number'], unique=True) + op.drop_constraint('rooms_ibfk_1', 'rooms', type_='foreignkey') + op.create_foreign_key(None, 'rooms', 'room_types', ['room_type_id'], ['id']) + op.drop_index('service_usages_booking_id', table_name='service_usages') + op.drop_index('service_usages_service_id', table_name='service_usages') + op.create_index(op.f('ix_service_usages_id'), 'service_usages', ['id'], unique=False) + op.drop_constraint('service_usages_ibfk_2', 'service_usages', type_='foreignkey') + op.drop_constraint('service_usages_ibfk_1', 'service_usages', type_='foreignkey') + op.create_foreign_key(None, 'service_usages', 'bookings', ['booking_id'], ['id']) + op.create_foreign_key(None, 'service_usages', 'services', ['service_id'], ['id']) + op.drop_index('services_category', table_name='services') + op.create_index(op.f('ix_services_id'), 'services', ['id'], unique=False) + op.drop_index('email', table_name='users') + op.drop_index('users_email', table_name='users') + op.drop_index('users_role_id', table_name='users') + op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True) + op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False) + op.drop_constraint('users_ibfk_1', 'users', type_='foreignkey') + op.create_foreign_key(None, 'users', 'roles', ['role_id'], ['id']) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'users', type_='foreignkey') + op.create_foreign_key('users_ibfk_1', 'users', 'roles', ['role_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT') + op.drop_index(op.f('ix_users_id'), table_name='users') + op.drop_index(op.f('ix_users_email'), table_name='users') + op.create_index('users_role_id', 'users', ['role_id'], unique=False) + op.create_index('users_email', 'users', ['email'], unique=False) + op.create_index('email', 'users', ['email'], unique=False) + op.drop_index(op.f('ix_services_id'), table_name='services') + op.create_index('services_category', 'services', ['category'], unique=False) + op.drop_constraint(None, 'service_usages', type_='foreignkey') + op.drop_constraint(None, 'service_usages', type_='foreignkey') + op.create_foreign_key('service_usages_ibfk_1', 'service_usages', 'bookings', ['booking_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT') + op.create_foreign_key('service_usages_ibfk_2', 'service_usages', 'services', ['service_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT') + op.drop_index(op.f('ix_service_usages_id'), table_name='service_usages') + op.create_index('service_usages_service_id', 'service_usages', ['service_id'], unique=False) + op.create_index('service_usages_booking_id', 'service_usages', ['booking_id'], unique=False) + op.drop_constraint(None, 'rooms', type_='foreignkey') + op.create_foreign_key('rooms_ibfk_1', 'rooms', 'room_types', ['room_type_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT') + op.drop_index(op.f('ix_rooms_room_number'), table_name='rooms') + op.drop_index(op.f('ix_rooms_id'), table_name='rooms') + op.create_index('rooms_status', 'rooms', ['status'], unique=False) + op.create_index('rooms_room_type_id', 'rooms', ['room_type_id'], unique=False) + op.create_index('rooms_featured', 'rooms', ['featured'], unique=False) + op.create_index('room_number', 'rooms', ['room_number'], unique=False) + op.drop_index(op.f('ix_room_types_id'), table_name='room_types') + op.drop_index(op.f('ix_roles_name'), table_name='roles') + op.drop_index(op.f('ix_roles_id'), table_name='roles') + op.create_index('name', 'roles', ['name'], unique=False) + op.drop_constraint(None, 'reviews', type_='foreignkey') + op.drop_constraint(None, 'reviews', type_='foreignkey') + op.create_foreign_key('reviews_ibfk_1', 'reviews', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE') + op.create_foreign_key('reviews_ibfk_2', 'reviews', 'rooms', ['room_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE') + op.drop_index(op.f('ix_reviews_id'), table_name='reviews') + op.create_index('reviews_user_id', 'reviews', ['user_id'], unique=False) + op.create_index('reviews_status', 'reviews', ['status'], unique=False) + op.create_index('reviews_room_id', 'reviews', ['room_id'], unique=False) + op.drop_constraint(None, 'refresh_tokens', type_='foreignkey') + op.create_foreign_key('refresh_tokens_ibfk_1', 'refresh_tokens', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE') + op.drop_index(op.f('ix_refresh_tokens_token'), table_name='refresh_tokens') + op.drop_index(op.f('ix_refresh_tokens_id'), table_name='refresh_tokens') + op.create_index('token', 'refresh_tokens', ['token'], unique=False) + op.create_index('refresh_tokens_user_id', 'refresh_tokens', ['user_id'], unique=False) + op.create_index('refresh_tokens_token', 'refresh_tokens', ['token'], unique=False) + op.drop_index(op.f('ix_promotions_id'), table_name='promotions') + op.drop_index(op.f('ix_promotions_code'), table_name='promotions') + op.create_index('promotions_is_active', 'promotions', ['is_active'], unique=False) + op.create_index('promotions_code', 'promotions', ['code'], unique=False) + op.create_index('code', 'promotions', ['code'], unique=False) + op.drop_constraint(None, 'payments', type_='foreignkey') + op.drop_constraint(None, 'payments', type_='foreignkey') + op.create_foreign_key('payments_related_payment_id_foreign_idx', 'payments', 'payments', ['related_payment_id'], ['id'], onupdate='CASCADE', ondelete='SET NULL') + op.create_foreign_key('payments_ibfk_1', 'payments', 'bookings', ['booking_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT') + op.drop_index(op.f('ix_payments_id'), table_name='payments') + op.create_index('payments_payment_status', 'payments', ['payment_status'], unique=False) + op.create_index('payments_booking_id', 'payments', ['booking_id'], unique=False) + op.alter_column('payments', 'deposit_percentage', + existing_type=mysql.INTEGER(), + comment='Percentage of deposit (e.g., 20, 30, 50)', + existing_nullable=True) + op.drop_constraint(None, 'password_reset_tokens', type_='foreignkey') + op.create_foreign_key('password_reset_tokens_ibfk_1', 'password_reset_tokens', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE') + op.drop_index(op.f('ix_password_reset_tokens_token'), table_name='password_reset_tokens') + op.drop_index(op.f('ix_password_reset_tokens_id'), table_name='password_reset_tokens') + op.create_index('token', 'password_reset_tokens', ['token'], unique=False) + op.create_index('password_reset_tokens_user_id', 'password_reset_tokens', ['user_id'], unique=False) + op.create_index('password_reset_tokens_token', 'password_reset_tokens', ['token'], unique=False) + op.alter_column('password_reset_tokens', 'used', + existing_type=mysql.TINYINT(display_width=1), + nullable=True, + existing_server_default=sa.text("'0'")) + op.drop_column('page_contents', 'partners_section_subtitle') + op.drop_column('page_contents', 'partners_section_title') + op.drop_column('page_contents', 'awards_section_subtitle') + op.drop_column('page_contents', 'awards_section_title') + op.drop_column('page_contents', 'luxury_experiences_section_subtitle') + op.drop_column('page_contents', 'luxury_experiences_section_title') + op.drop_column('page_contents', 'luxury_services_section_subtitle') + op.drop_column('page_contents', 'luxury_services_section_title') + op.drop_column('page_contents', 'luxury_testimonials_section_subtitle') + op.drop_column('page_contents', 'luxury_testimonials_section_title') + op.drop_column('page_contents', 'luxury_gallery_section_subtitle') + op.drop_column('page_contents', 'luxury_gallery_section_title') + op.drop_constraint(None, 'favorites', type_='foreignkey') + op.drop_constraint(None, 'favorites', type_='foreignkey') + op.create_foreign_key('favorites_ibfk_2', 'favorites', 'rooms', ['room_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE') + op.create_foreign_key('favorites_ibfk_1', 'favorites', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE') + op.drop_index(op.f('ix_favorites_id'), table_name='favorites') + op.create_index('unique_user_room_favorite', 'favorites', ['user_id', 'room_id'], unique=False) + op.create_index('favorites_user_id', 'favorites', ['user_id'], unique=False) + op.create_index('favorites_room_id', 'favorites', ['room_id'], unique=False) + op.drop_constraint(None, 'checkin_checkout', type_='foreignkey') + op.drop_constraint(None, 'checkin_checkout', type_='foreignkey') + op.drop_constraint(None, 'checkin_checkout', type_='foreignkey') + op.create_foreign_key('checkin_checkout_ibfk_3', 'checkin_checkout', 'users', ['checkout_by'], ['id'], onupdate='CASCADE', ondelete='SET NULL') + op.create_foreign_key('checkin_checkout_ibfk_2', 'checkin_checkout', 'users', ['checkin_by'], ['id'], onupdate='CASCADE', ondelete='SET NULL') + op.create_foreign_key('checkin_checkout_ibfk_1', 'checkin_checkout', 'bookings', ['booking_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT') + op.drop_constraint(None, 'checkin_checkout', type_='unique') + op.drop_index(op.f('ix_checkin_checkout_id'), table_name='checkin_checkout') + op.create_index('checkin_checkout_booking_id', 'checkin_checkout', ['booking_id'], unique=False) + op.drop_constraint(None, 'bookings', type_='foreignkey') + op.drop_constraint(None, 'bookings', type_='foreignkey') + op.create_foreign_key('bookings_ibfk_2', 'bookings', 'rooms', ['room_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT') + op.create_foreign_key('bookings_ibfk_1', 'bookings', 'users', ['user_id'], ['id'], onupdate='CASCADE', ondelete='RESTRICT') + op.drop_index(op.f('ix_bookings_id'), table_name='bookings') + op.drop_index(op.f('ix_bookings_booking_number'), table_name='bookings') + op.create_index('ix_bookings_promotion_code', 'bookings', ['promotion_code'], unique=False) + op.create_index('bookings_user_id', 'bookings', ['user_id'], unique=False) + op.create_index('bookings_status', 'bookings', ['status'], unique=False) + op.create_index('bookings_room_id', 'bookings', ['room_id'], unique=False) + # ### end Alembic commands ### + diff --git a/Backend/alembic/versions/17efc6439cc3_add_luxury_section_fields_to_page_.py b/Backend/alembic/versions/17efc6439cc3_add_luxury_section_fields_to_page_.py new file mode 100644 index 00000000..6c47ef81 --- /dev/null +++ b/Backend/alembic/versions/17efc6439cc3_add_luxury_section_fields_to_page_.py @@ -0,0 +1,38 @@ +"""add_luxury_section_fields_to_page_content + +Revision ID: 17efc6439cc3 +Revises: bfa74be4b256 +Create Date: 2025-11-20 13:37:20.015422 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '17efc6439cc3' +down_revision = 'bfa74be4b256' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # Add luxury section fields to page_contents table + # Use TEXT instead of VARCHAR to avoid MySQL row size limits + op.add_column('page_contents', sa.Column('luxury_section_title', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('luxury_section_subtitle', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('luxury_section_image', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('luxury_features', sa.Text(), nullable=True)) # JSON array + op.add_column('page_contents', sa.Column('luxury_gallery', sa.Text(), nullable=True)) # JSON array of image URLs + op.add_column('page_contents', sa.Column('luxury_testimonials', sa.Text(), nullable=True)) # JSON array of testimonials + + +def downgrade() -> None: + # Remove luxury section fields + op.drop_column('page_contents', 'luxury_testimonials') + op.drop_column('page_contents', 'luxury_gallery') + op.drop_column('page_contents', 'luxury_features') + op.drop_column('page_contents', 'luxury_section_image') + op.drop_column('page_contents', 'luxury_section_subtitle') + op.drop_column('page_contents', 'luxury_section_title') + diff --git a/Backend/alembic/versions/__pycache__/1444eb61188e_add_section_title_fields_to_page_content.cpython-312.pyc b/Backend/alembic/versions/__pycache__/1444eb61188e_add_section_title_fields_to_page_content.cpython-312.pyc new file mode 100644 index 00000000..de4db895 Binary files /dev/null and b/Backend/alembic/versions/__pycache__/1444eb61188e_add_section_title_fields_to_page_content.cpython-312.pyc differ diff --git a/Backend/alembic/versions/__pycache__/17efc6439cc3_add_luxury_section_fields_to_page_.cpython-312.pyc b/Backend/alembic/versions/__pycache__/17efc6439cc3_add_luxury_section_fields_to_page_.cpython-312.pyc new file mode 100644 index 00000000..9bde4caf Binary files /dev/null and b/Backend/alembic/versions/__pycache__/17efc6439cc3_add_luxury_section_fields_to_page_.cpython-312.pyc differ diff --git a/Backend/alembic/versions/__pycache__/add_about_page_fields.cpython-312.pyc b/Backend/alembic/versions/__pycache__/add_about_page_fields.cpython-312.pyc new file mode 100644 index 00000000..cc32c87c Binary files /dev/null and b/Backend/alembic/versions/__pycache__/add_about_page_fields.cpython-312.pyc differ diff --git a/Backend/alembic/versions/__pycache__/add_copyright_text_to_page_content.cpython-312.pyc b/Backend/alembic/versions/__pycache__/add_copyright_text_to_page_content.cpython-312.pyc new file mode 100644 index 00000000..16bb2ee4 Binary files /dev/null and b/Backend/alembic/versions/__pycache__/add_copyright_text_to_page_content.cpython-312.pyc differ diff --git a/Backend/alembic/versions/__pycache__/add_privacy_terms_page_types.cpython-312.pyc b/Backend/alembic/versions/__pycache__/add_privacy_terms_page_types.cpython-312.pyc new file mode 100644 index 00000000..8e861ab3 Binary files /dev/null and b/Backend/alembic/versions/__pycache__/add_privacy_terms_page_types.cpython-312.pyc differ diff --git a/Backend/alembic/versions/__pycache__/bd309b0742c1_add_promotion_fields_to_bookings.cpython-312.pyc b/Backend/alembic/versions/__pycache__/bd309b0742c1_add_promotion_fields_to_bookings.cpython-312.pyc index 8d28a5a7..6981abb1 100644 Binary files a/Backend/alembic/versions/__pycache__/bd309b0742c1_add_promotion_fields_to_bookings.cpython-312.pyc and b/Backend/alembic/versions/__pycache__/bd309b0742c1_add_promotion_fields_to_bookings.cpython-312.pyc differ diff --git a/Backend/alembic/versions/__pycache__/bfa74be4b256_add_luxury_content_fields_to_page_.cpython-312.pyc b/Backend/alembic/versions/__pycache__/bfa74be4b256_add_luxury_content_fields_to_page_.cpython-312.pyc new file mode 100644 index 00000000..c11c964e Binary files /dev/null and b/Backend/alembic/versions/__pycache__/bfa74be4b256_add_luxury_content_fields_to_page_.cpython-312.pyc differ diff --git a/Backend/alembic/versions/__pycache__/ff515d77abbe_add_more_luxury_sections_to_page_content.cpython-312.pyc b/Backend/alembic/versions/__pycache__/ff515d77abbe_add_more_luxury_sections_to_page_content.cpython-312.pyc new file mode 100644 index 00000000..4f9e448f Binary files /dev/null and b/Backend/alembic/versions/__pycache__/ff515d77abbe_add_more_luxury_sections_to_page_content.cpython-312.pyc differ diff --git a/Backend/alembic/versions/add_about_page_fields.py b/Backend/alembic/versions/add_about_page_fields.py new file mode 100644 index 00000000..fba405ad --- /dev/null +++ b/Backend/alembic/versions/add_about_page_fields.py @@ -0,0 +1,36 @@ +"""add_about_page_fields + +Revision ID: f2a3b4c5d6e7 +Revises: a1b2c3d4e5f6 +Create Date: 2025-11-20 17:00:00.000000 + +""" +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision = 'f2a3b4c5d6e7' +down_revision = 'a1b2c3d4e5f6' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # Add about page specific fields (all as TEXT to avoid row size issues) + op.add_column('page_contents', sa.Column('about_hero_image', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('mission', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('vision', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('team', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('timeline', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('achievements', sa.Text(), nullable=True)) + + +def downgrade() -> None: + # Remove about page specific fields + op.drop_column('page_contents', 'achievements') + op.drop_column('page_contents', 'timeline') + op.drop_column('page_contents', 'team') + op.drop_column('page_contents', 'vision') + op.drop_column('page_contents', 'mission') + op.drop_column('page_contents', 'about_hero_image') + diff --git a/Backend/alembic/versions/add_copyright_text_to_page_content.py b/Backend/alembic/versions/add_copyright_text_to_page_content.py new file mode 100644 index 00000000..24de9b6a --- /dev/null +++ b/Backend/alembic/versions/add_copyright_text_to_page_content.py @@ -0,0 +1,26 @@ +"""add_copyright_text_to_page_content + +Revision ID: a1b2c3d4e5f6 +Revises: ff515d77abbe +Create Date: 2025-11-20 16:00:00.000000 + +""" +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision = 'a1b2c3d4e5f6' +down_revision = '1444eb61188e' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # Add copyright_text column to page_contents table + op.add_column('page_contents', sa.Column('copyright_text', sa.Text(), nullable=True)) + + +def downgrade() -> None: + # Remove copyright_text column from page_contents table + op.drop_column('page_contents', 'copyright_text') + diff --git a/Backend/alembic/versions/bfa74be4b256_add_luxury_content_fields_to_page_.py b/Backend/alembic/versions/bfa74be4b256_add_luxury_content_fields_to_page_.py new file mode 100644 index 00000000..66496e19 --- /dev/null +++ b/Backend/alembic/versions/bfa74be4b256_add_luxury_content_fields_to_page_.py @@ -0,0 +1,53 @@ +"""add_luxury_content_fields_to_page_content + +Revision ID: bfa74be4b256 +Revises: bd309b0742c1 +Create Date: 2025-11-20 13:27:52.106013 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'bfa74be4b256' +down_revision = 'bd309b0742c1' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # Add luxury content fields to page_contents table + op.add_column('page_contents', sa.Column('amenities_section_title', sa.String(500), nullable=True)) + op.add_column('page_contents', sa.Column('amenities_section_subtitle', sa.String(1000), nullable=True)) + op.add_column('page_contents', sa.Column('amenities', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('testimonials_section_title', sa.String(500), nullable=True)) + op.add_column('page_contents', sa.Column('testimonials_section_subtitle', sa.String(1000), nullable=True)) + op.add_column('page_contents', sa.Column('testimonials', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('gallery_section_title', sa.String(500), nullable=True)) + op.add_column('page_contents', sa.Column('gallery_section_subtitle', sa.String(1000), nullable=True)) + op.add_column('page_contents', sa.Column('gallery_images', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('about_preview_title', sa.String(500), nullable=True)) + op.add_column('page_contents', sa.Column('about_preview_subtitle', sa.String(1000), nullable=True)) + op.add_column('page_contents', sa.Column('about_preview_content', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('about_preview_image', sa.String(1000), nullable=True)) + op.add_column('page_contents', sa.Column('stats', sa.Text(), nullable=True)) + + +def downgrade() -> None: + # Remove luxury content fields + op.drop_column('page_contents', 'stats') + op.drop_column('page_contents', 'about_preview_image') + op.drop_column('page_contents', 'about_preview_content') + op.drop_column('page_contents', 'about_preview_subtitle') + op.drop_column('page_contents', 'about_preview_title') + op.drop_column('page_contents', 'gallery_images') + op.drop_column('page_contents', 'gallery_section_subtitle') + op.drop_column('page_contents', 'gallery_section_title') + op.drop_column('page_contents', 'testimonials') + op.drop_column('page_contents', 'testimonials_section_subtitle') + op.drop_column('page_contents', 'testimonials_section_title') + op.drop_column('page_contents', 'amenities') + op.drop_column('page_contents', 'amenities_section_subtitle') + op.drop_column('page_contents', 'amenities_section_title') + diff --git a/Backend/alembic/versions/ff515d77abbe_add_more_luxury_sections_to_page_content.py b/Backend/alembic/versions/ff515d77abbe_add_more_luxury_sections_to_page_content.py new file mode 100644 index 00000000..743e69d1 --- /dev/null +++ b/Backend/alembic/versions/ff515d77abbe_add_more_luxury_sections_to_page_content.py @@ -0,0 +1,43 @@ +"""add_more_luxury_sections_to_page_content + +Revision ID: ff515d77abbe +Revises: 17efc6439cc3 +Create Date: 2025-11-20 15:17:50.977961 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'ff515d77abbe' +down_revision = '17efc6439cc3' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # Add more luxury sections to page_contents table + op.add_column('page_contents', sa.Column('luxury_services', sa.Text(), nullable=True)) # JSON array of services + op.add_column('page_contents', sa.Column('luxury_experiences', sa.Text(), nullable=True)) # JSON array of experiences + op.add_column('page_contents', sa.Column('awards', sa.Text(), nullable=True)) # JSON array of awards + op.add_column('page_contents', sa.Column('cta_title', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('cta_subtitle', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('cta_button_text', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('cta_button_link', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('cta_image', sa.Text(), nullable=True)) + op.add_column('page_contents', sa.Column('partners', sa.Text(), nullable=True)) # JSON array of partners + + +def downgrade() -> None: + # Remove luxury sections fields + op.drop_column('page_contents', 'partners') + op.drop_column('page_contents', 'cta_image') + op.drop_column('page_contents', 'cta_button_link') + op.drop_column('page_contents', 'cta_button_text') + op.drop_column('page_contents', 'cta_subtitle') + op.drop_column('page_contents', 'cta_title') + op.drop_column('page_contents', 'awards') + op.drop_column('page_contents', 'luxury_experiences') + op.drop_column('page_contents', 'luxury_services') + diff --git a/Backend/seed_about_page.py b/Backend/seed_about_page.py new file mode 100644 index 00000000..02fbdd0f --- /dev/null +++ b/Backend/seed_about_page.py @@ -0,0 +1,217 @@ +#!/usr/bin/env python3 +""" +Seed sample data for the About page +""" + +import sys +import os +from pathlib import Path +import json + +# Add the parent directory to the path so we can import from src +sys.path.insert(0, str(Path(__file__).parent)) + +from sqlalchemy.orm import Session +from src.config.database import SessionLocal +from src.models.page_content import PageContent, PageType +from datetime import datetime + +def get_db(): + """Get database session""" + db = SessionLocal() + try: + return db + finally: + pass + +def seed_about_page(db: Session): + """Seed about page content""" + print("=" * 80) + print("SEEDING ABOUT PAGE CONTENT") + print("=" * 80) + + # Sample data + about_data = { + "title": "About Luxury Hotel", + "subtitle": "Where Excellence Meets Unforgettable Experiences", + "description": "Discover the story behind our commitment to luxury hospitality and exceptional service.", + "story_content": """Welcome to Luxury Hotel, where timeless elegance meets modern sophistication. Since our founding in 2010, we have been dedicated to providing exceptional hospitality and creating unforgettable memories for our guests. + +Nestled in the heart of the city, our hotel combines classic architecture with contemporary amenities, offering a perfect blend of comfort and luxury. Every detail has been carefully curated to ensure your stay exceeds expectations. + +Our commitment to excellence extends beyond our beautiful rooms and facilities. We believe in creating meaningful connections with our guests, understanding their needs, and delivering personalized service that makes each visit special. + +Over the years, we have hosted thousands of guests from around the world, each leaving with cherished memories and a desire to return. Our team of dedicated professionals works tirelessly to ensure that every moment of your stay is perfect.""", + "mission": "To provide unparalleled luxury hospitality experiences that exceed expectations, creating lasting memories for our guests through exceptional service, attention to detail, and genuine care.", + "vision": "To be recognized as the world's premier luxury hotel brand, setting the standard for excellence in hospitality while maintaining our commitment to sustainability and community engagement.", + "about_hero_image": "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1920&h=1080&fit=crop", + "values": json.dumps([ + { + "icon": "Heart", + "title": "Passion", + "description": "We are passionate about hospitality and dedicated to creating exceptional experiences for every guest." + }, + { + "icon": "Award", + "title": "Excellence", + "description": "We strive for excellence in every aspect of our service, from the smallest detail to the grandest gesture." + }, + { + "icon": "Shield", + "title": "Integrity", + "description": "We conduct our business with honesty, transparency, and respect for our guests and community." + }, + { + "icon": "Users", + "title": "Service", + "description": "Our guests are at the heart of everything we do. Your comfort and satisfaction are our top priorities." + } + ]), + "features": json.dumps([ + { + "icon": "Star", + "title": "Premium Accommodations", + "description": "Luxuriously appointed rooms and suites designed for ultimate comfort and relaxation." + }, + { + "icon": "Clock", + "title": "24/7 Service", + "description": "Round-the-clock concierge and room service to attend to your needs at any time." + }, + { + "icon": "Award", + "title": "Award-Winning", + "description": "Recognized for excellence in hospitality and guest satisfaction." + } + ]), + "team": json.dumps([ + { + "name": "Sarah Johnson", + "role": "General Manager", + "image": "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=400&h=400&fit=crop", + "bio": "With over 15 years of experience in luxury hospitality, Sarah leads our team with passion and dedication.", + "social_links": { + "linkedin": "https://linkedin.com/in/sarahjohnson", + "twitter": "https://twitter.com/sarahjohnson" + } + }, + { + "name": "Michael Chen", + "role": "Head Chef", + "image": "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=400&h=400&fit=crop", + "bio": "Award-winning chef with expertise in international cuisine, bringing world-class dining experiences to our guests.", + "social_links": { + "linkedin": "https://linkedin.com/in/michaelchen", + "twitter": "https://twitter.com/michaelchen" + } + }, + { + "name": "Emily Rodriguez", + "role": "Guest Relations Manager", + "image": "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=400&h=400&fit=crop", + "bio": "Ensuring every guest feels valued and receives personalized attention throughout their stay.", + "social_links": { + "linkedin": "https://linkedin.com/in/emilyrodriguez" + } + } + ]), + "timeline": json.dumps([ + { + "year": "2010", + "title": "Grand Opening", + "description": "Luxury Hotel opened its doors, welcoming guests to a new standard of luxury hospitality.", + "image": "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=800&h=600&fit=crop" + }, + { + "year": "2015", + "title": "First Award", + "description": "Received our first 'Best Luxury Hotel' award, recognizing our commitment to excellence.", + "image": "https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=800&h=600&fit=crop" + }, + { + "year": "2018", + "title": "Major Renovation", + "description": "Completed a comprehensive renovation, adding state-of-the-art facilities and expanding our capacity.", + "image": "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=800&h=600&fit=crop" + }, + { + "year": "2020", + "title": "Sustainability Initiative", + "description": "Launched our sustainability program, committing to eco-friendly practices and community engagement.", + "image": "https://images.unsplash.com/photo-1611892440504-42a792e24d32?w=800&h=600&fit=crop" + }, + { + "year": "2023", + "title": "International Recognition", + "description": "Achieved international recognition as one of the world's top luxury hotels.", + "image": "https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=800&h=600&fit=crop" + } + ]), + "achievements": json.dumps([ + { + "icon": "Award", + "title": "Best Luxury Hotel 2023", + "description": "Recognized as the best luxury hotel in the region for exceptional service and amenities.", + "year": "2023", + "image": "https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=400&h=300&fit=crop" + }, + { + "icon": "Star", + "title": "5-Star Rating", + "description": "Maintained our prestigious 5-star rating for over a decade, a testament to our consistent excellence.", + "year": "2022", + "image": "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=400&h=300&fit=crop" + }, + { + "icon": "Award", + "title": "Sustainable Hotel of the Year", + "description": "Awarded for our commitment to environmental sustainability and green practices.", + "year": "2021", + "image": "https://images.unsplash.com/photo-1611892440504-42a792e24d32?w=400&h=300&fit=crop" + }, + { + "icon": "Users", + "title": "Guest Satisfaction Excellence", + "description": "Achieved 98% guest satisfaction rate, the highest in our category.", + "year": "2023", + "image": "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=400&h=300&fit=crop" + } + ]), + "meta_title": "About Us - Luxury Hotel | Our Story, Mission & Vision", + "meta_description": "Learn about Luxury Hotel's commitment to excellence, our story, values, and the dedicated team that makes every stay unforgettable." + } + + # Check if about page content exists + existing = db.query(PageContent).filter(PageContent.page_type == PageType.ABOUT).first() + + if existing: + # Update existing + for key, value in about_data.items(): + setattr(existing, key, value) + existing.updated_at = datetime.utcnow() + print("✓ Updated existing about page content") + else: + # Create new + new_content = PageContent( + page_type=PageType.ABOUT, + **about_data + ) + db.add(new_content) + print("✓ Created new about page content") + + db.commit() + print("\n✅ About page content seeded successfully!") + print("=" * 80) + +if __name__ == "__main__": + db = get_db() + try: + seed_about_page(db) + except Exception as e: + print(f"\n❌ Error: {e}") + import traceback + traceback.print_exc() + db.rollback() + finally: + db.close() + diff --git a/Backend/seed_banners_company.py b/Backend/seed_banners_company.py new file mode 100644 index 00000000..f839c652 --- /dev/null +++ b/Backend/seed_banners_company.py @@ -0,0 +1,214 @@ +""" +Seed script to populate banners and company information with sample data. +Run this script to add default banners and company settings. +""" +import sys +import os +from datetime import datetime, timedelta + +# Add the src directory to the path +sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) + +from sqlalchemy.orm import Session +from src.config.database import SessionLocal +from src.models.banner import Banner +from src.models.system_settings import SystemSettings +from src.models.user import User + +def seed_banners(db: Session): + """Seed sample banners""" + print("Seeding banners...") + + # Get admin user for updated_by_id (if exists) + admin_user = db.query(User).filter(User.email == "admin@hotel.com").first() + admin_id = admin_user.id if admin_user else None + + # Delete all existing banners + existing_banners = db.query(Banner).all() + if existing_banners: + for banner in existing_banners: + db.delete(banner) + db.commit() + print(f" ✓ Removed {len(existing_banners)} existing banner(s)") + + # New luxury banners with premium content + banners_data = [ + { + "title": "Welcome to Unparalleled Luxury", + "description": "Where timeless elegance meets modern sophistication. Experience the pinnacle of hospitality in our award-winning luxury hotel.", + "image_url": "https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=1920", + "link_url": "/rooms", + "position": "home", + "display_order": 1, + "is_active": True, + "start_date": datetime.utcnow() - timedelta(days=30), + "end_date": datetime.utcnow() + timedelta(days=365), + }, + { + "title": "Exclusive Presidential Suites", + "description": "Indulge in our most opulent accommodations. Spacious suites with panoramic views, private terraces, and personalized butler service.", + "image_url": "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=1920", + "link_url": "/rooms", + "position": "home", + "display_order": 2, + "is_active": True, + "start_date": datetime.utcnow() - timedelta(days=7), + "end_date": datetime.utcnow() + timedelta(days=365), + }, + { + "title": "World-Class Spa & Wellness", + "description": "Rejuvenate your mind, body, and soul. Our award-winning spa offers bespoke treatments using the finest luxury products.", + "image_url": "https://images.unsplash.com/photo-1544161515-4ab6ce6db874?w=1920", + "link_url": "/services", + "position": "home", + "display_order": 3, + "is_active": True, + "start_date": datetime.utcnow() - timedelta(days=1), + "end_date": datetime.utcnow() + timedelta(days=365), + }, + { + "title": "Michelin-Starred Culinary Excellence", + "description": "Savor extraordinary flavors crafted by world-renowned chefs. Our fine dining restaurants offer an unforgettable gastronomic journey.", + "image_url": "https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=1920", + "link_url": "/services", + "position": "home", + "display_order": 4, + "is_active": True, + "start_date": datetime.utcnow(), + "end_date": datetime.utcnow() + timedelta(days=365), + }, + { + "title": "Private Yacht & Exclusive Experiences", + "description": "Create unforgettable memories with our curated luxury experiences. From private yacht charters to exclusive cultural tours.", + "image_url": "https://images.unsplash.com/photo-1544551763-46a013bb70d5?w=1920", + "link_url": "/services", + "position": "home", + "display_order": 5, + "is_active": True, + "start_date": datetime.utcnow() - timedelta(days=15), + "end_date": datetime.utcnow() + timedelta(days=365), + } + ] + + for banner_data in banners_data: + # Create new banner + new_banner = Banner(**banner_data) + db.add(new_banner) + print(f" ✓ Created banner: {banner_data['title']}") + + db.commit() + print("✓ Banners seeded successfully!\n") + +def seed_company_info(db: Session): + """Seed company information""" + print("Seeding company information...") + + # Get admin user for updated_by_id (if exists) + admin_user = db.query(User).filter(User.email == "admin@hotel.com").first() + admin_id = admin_user.id if admin_user else None + + # Company settings + company_settings = [ + { + "key": "company_name", + "value": "Luxury Hotel", + "description": "Company name displayed throughout the application" + }, + { + "key": "company_tagline", + "value": "Experience Unparalleled Elegance", + "description": "Company tagline or slogan" + }, + { + "key": "company_logo_url", + "value": "", + "description": "URL to company logo image (upload via admin dashboard)" + }, + { + "key": "company_favicon_url", + "value": "", + "description": "URL to company favicon image (upload via admin dashboard)" + }, + { + "key": "company_phone", + "value": "+1 (555) 123-4567", + "description": "Company contact phone number" + }, + { + "key": "company_email", + "value": "info@luxuryhotel.com", + "description": "Company contact email address" + }, + { + "key": "company_address", + "value": "123 Luxury Avenue, Premium District, City 12345, Country", + "description": "Company physical address" + }, + { + "key": "tax_rate", + "value": "10.0", + "description": "Default tax rate percentage (e.g., 10.0 for 10%)" + }, + { + "key": "platform_currency", + "value": "EUR", + "description": "Platform-wide currency setting for displaying prices" + } + ] + + for setting_data in company_settings: + # Check if setting exists + existing = db.query(SystemSettings).filter( + SystemSettings.key == setting_data["key"] + ).first() + + if existing: + # Update existing setting + existing.value = setting_data["value"] + existing.description = setting_data["description"] + if admin_id: + existing.updated_by_id = admin_id + print(f" ✓ Updated setting: {setting_data['key']}") + else: + # Create new setting + new_setting = SystemSettings( + key=setting_data["key"], + value=setting_data["value"], + description=setting_data["description"], + updated_by_id=admin_id + ) + db.add(new_setting) + print(f" ✓ Created setting: {setting_data['key']}") + + db.commit() + print("✓ Company information seeded successfully!\n") + +def main(): + """Main seed function""" + db: Session = SessionLocal() + + try: + print("=" * 80) + print("SEEDING BANNERS AND COMPANY INFORMATION") + print("=" * 80) + print() + + seed_banners(db) + seed_company_info(db) + + print("=" * 80) + print("✓ All data seeded successfully!") + print("=" * 80) + + except Exception as e: + db.rollback() + print(f"\n✗ Error seeding data: {e}") + import traceback + traceback.print_exc() + raise + finally: + db.close() + +if __name__ == "__main__": + main() + diff --git a/Backend/seed_homepage_footer.py b/Backend/seed_homepage_footer.py new file mode 100644 index 00000000..3b29ad26 --- /dev/null +++ b/Backend/seed_homepage_footer.py @@ -0,0 +1,456 @@ +""" +Comprehensive seed script to populate homepage and footer with sample luxury content. +Run this script to add default content to the page_content table. +""" +import sys +import os +import json + +# Add the src directory to the path +sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) + +from sqlalchemy.orm import Session +from src.config.database import SessionLocal +from src.models.page_content import PageContent, PageType + +def seed_homepage_content(db: Session): + """Seed comprehensive homepage content""" + existing = db.query(PageContent).filter(PageContent.page_type == PageType.HOME).first() + + # Luxury Features + luxury_features = [ + { + "icon": "Sparkles", + "title": "Premium Amenities", + "description": "World-class facilities designed for your comfort and relaxation" + }, + { + "icon": "Crown", + "title": "Royal Service", + "description": "Dedicated concierge service available 24/7 for all your needs" + }, + { + "icon": "Award", + "title": "Award-Winning", + "description": "Recognized for excellence in hospitality and guest satisfaction" + }, + { + "icon": "Shield", + "title": "Secure & Private", + "description": "Your privacy and security are our top priorities" + }, + { + "icon": "Heart", + "title": "Personalized Care", + "description": "Tailored experiences crafted just for you" + }, + { + "icon": "Gem", + "title": "Luxury Design", + "description": "Elegantly designed spaces with attention to every detail" + } + ] + + # Luxury Gallery + luxury_gallery = [ + "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=800", + "https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=800", + "https://images.unsplash.com/photo-1582719478250-c89cae4dc85b?w=800", + "https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=800", + "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=800", + "https://images.unsplash.com/photo-1551882547-ff40c63fe5fa?w=800" + ] + + # Luxury Testimonials + luxury_testimonials = [ + { + "name": "Sarah Johnson", + "title": "Business Executive", + "quote": "An absolutely stunning experience. The attention to detail and level of service exceeded all expectations.", + "image": "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=200" + }, + { + "name": "Michael Chen", + "title": "Travel Enthusiast", + "quote": "The epitome of luxury. Every moment was perfect, from check-in to check-out.", + "image": "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=200" + }, + { + "name": "Emma Williams", + "title": "Luxury Traveler", + "quote": "This hotel redefines what luxury means. I will definitely return.", + "image": "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=200" + } + ] + + # Luxury Services + luxury_services = [ + { + "icon": "UtensilsCrossed", + "title": "Fine Dining", + "description": "Michelin-starred restaurants offering world-class cuisine", + "image": "https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=600" + }, + { + "icon": "Wine", + "title": "Premium Bar", + "description": "Extensive wine collection and craft cocktails in elegant settings", + "image": "https://images.unsplash.com/photo-1514362545857-3bc16c4c7d1b?w=600" + }, + { + "icon": "Dumbbell", + "title": "Spa & Wellness", + "description": "Rejuvenating spa treatments and state-of-the-art fitness center", + "image": "https://images.unsplash.com/photo-1544161515-4ab6ce6db874?w=600" + }, + { + "icon": "Car", + "title": "Concierge Services", + "description": "Personalized assistance for all your travel and entertainment needs", + "image": "https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=600" + } + ] + + # Luxury Experiences + luxury_experiences = [ + { + "icon": "Sunset", + "title": "Sunset Rooftop", + "description": "Breathtaking views and exclusive rooftop experiences", + "image": "https://images.unsplash.com/photo-1514933651103-005eec06c04b?w=600" + }, + { + "icon": "Ship", + "title": "Yacht Excursions", + "description": "Private yacht charters for unforgettable sea adventures", + "image": "https://images.unsplash.com/photo-1544551763-46a013bb70d5?w=600" + }, + { + "icon": "Music", + "title": "Live Entertainment", + "description": "World-class performances and exclusive events", + "image": "https://images.unsplash.com/photo-1470229722913-7c0e2dbbafd3?w=600" + }, + { + "icon": "Palette", + "title": "Art & Culture", + "description": "Curated art collections and cultural experiences", + "image": "https://images.unsplash.com/photo-1578301978018-3005759f48f7?w=600" + } + ] + + # Awards + awards = [ + { + "icon": "Trophy", + "title": "Best Luxury Hotel 2024", + "description": "Awarded by International Luxury Travel Association", + "image": "https://images.unsplash.com/photo-1579783902614-a3fb3927b6a5?w=400", + "year": "2024" + }, + { + "icon": "Star", + "title": "5-Star Excellence", + "description": "Consistently rated 5 stars by leading travel publications", + "image": "https://images.unsplash.com/photo-1606761568499-6d2451b23c66?w=400", + "year": "2023" + }, + { + "icon": "Award", + "title": "Sustainable Luxury", + "description": "Recognized for environmental responsibility and sustainability", + "image": "https://images.unsplash.com/photo-1473341304170-971dccb5ac1e?w=400", + "year": "2024" + } + ] + + # Partners + partners = [ + { + "name": "Luxury Travel Group", + "logo": "https://images.unsplash.com/photo-1599305445671-ac291c95aaa9?w=200", + "link": "#" + }, + { + "name": "Premium Airlines", + "logo": "https://images.unsplash.com/photo-1436491865332-7a61a109cc05?w=200", + "link": "#" + }, + { + "name": "Exclusive Events", + "logo": "https://images.unsplash.com/photo-1511578314322-379afb476865?w=200", + "link": "#" + }, + { + "name": "Fine Dining Network", + "logo": "https://images.unsplash.com/photo-1555396273-367ea4eb4db5?w=200", + "link": "#" + } + ] + + # Stats + stats = [ + { + "icon": "Users", + "number": "50,000+", + "label": "Happy Guests" + }, + { + "icon": "Award", + "number": "25+", + "label": "Awards Won" + }, + { + "icon": "Star", + "number": "4.9", + "label": "Average Rating" + }, + { + "icon": "Globe", + "number": "100+", + "label": "Countries Served" + } + ] + + # Amenities + amenities = [ + { + "icon": "Wifi", + "title": "High-Speed WiFi", + "description": "Complimentary high-speed internet throughout the property", + "image": "" + }, + { + "icon": "Coffee", + "title": "24/7 Room Service", + "description": "Round-the-clock dining and beverage service", + "image": "" + }, + { + "icon": "Car", + "title": "Valet Parking", + "description": "Complimentary valet parking for all guests", + "image": "" + }, + { + "icon": "Plane", + "title": "Airport Transfer", + "description": "Luxury airport transfer service available", + "image": "" + } + ] + + # Testimonials + testimonials = [ + { + "name": "Robert Martinez", + "role": "CEO, Tech Corp", + "image": "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=200", + "rating": 5, + "comment": "Exceptional service and attention to detail. The staff went above and beyond to make our stay memorable." + }, + { + "name": "Lisa Anderson", + "role": "Travel Blogger", + "image": "https://images.unsplash.com/photo-1487412720507-e7ab37603c6f?w=200", + "rating": 5, + "comment": "The most luxurious hotel experience I've ever had. Every detail was perfect." + }, + { + "name": "David Thompson", + "role": "Investment Banker", + "image": "https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=200", + "rating": 5, + "comment": "Outstanding facilities and impeccable service. Highly recommend for business travelers." + } + ] + + # Gallery Images + gallery_images = [ + "https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=800", + "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=800", + "https://images.unsplash.com/photo-1551882547-ff40c63fe5fa?w=800", + "https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=800", + "https://images.unsplash.com/photo-1582719478250-c89cae4dc85b?w=800", + "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=800" + ] + + homepage_data = { + "page_type": PageType.HOME, + "title": "Luxury Hotel - Experience Unparalleled Elegance", + "subtitle": "Where timeless luxury meets modern sophistication", + "description": "Discover a world of refined elegance and exceptional service", + "hero_title": "Welcome to Luxury", + "hero_subtitle": "Experience the pinnacle of hospitality", + "hero_image": "https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=1200", + "luxury_section_title": "Experience Unparalleled Luxury", + "luxury_section_subtitle": "Where elegance meets comfort in every detail", + "luxury_section_image": "https://images.unsplash.com/photo-1571896349842-33c89424de2d?w=1200", + "luxury_features": json.dumps(luxury_features), + "luxury_gallery_section_title": "Our Luxury Gallery", + "luxury_gallery_section_subtitle": "A glimpse into our world of elegance", + "luxury_gallery": json.dumps(luxury_gallery), + "luxury_testimonials_section_title": "What Our Guests Say", + "luxury_testimonials_section_subtitle": "Testimonials from our valued guests", + "luxury_testimonials": json.dumps(luxury_testimonials), + "luxury_services_section_title": "Premium Services", + "luxury_services_section_subtitle": "Indulge in our world-class amenities", + "luxury_services": json.dumps(luxury_services), + "luxury_experiences_section_title": "Exclusive Experiences", + "luxury_experiences_section_subtitle": "Create unforgettable memories", + "luxury_experiences": json.dumps(luxury_experiences), + "awards_section_title": "Awards & Recognition", + "awards_section_subtitle": "Recognized for excellence worldwide", + "awards": json.dumps(awards), + "partners_section_title": "Our Partners", + "partners_section_subtitle": "Trusted by leading brands", + "partners": json.dumps(partners), + "amenities_section_title": "Premium Amenities", + "amenities_section_subtitle": "Everything you need for a perfect stay", + "amenities": json.dumps(amenities), + "testimonials_section_title": "Guest Reviews", + "testimonials_section_subtitle": "Hear from our satisfied guests", + "testimonials": json.dumps(testimonials), + "gallery_section_title": "Photo Gallery", + "gallery_section_subtitle": "Explore our beautiful spaces", + "gallery_images": json.dumps(gallery_images), + "about_preview_title": "About Our Luxury Hotel", + "about_preview_subtitle": "A legacy of excellence", + "about_preview_content": "Discover a world of refined elegance and exceptional service. Our hotel combines timeless luxury with modern amenities to create an unforgettable experience. With over 50,000 satisfied guests and numerous awards, we continue to set the standard for luxury hospitality.", + "about_preview_image": "https://images.unsplash.com/photo-1582719478250-c89cae4dc85b?w=800", + "stats": json.dumps(stats), + "cta_title": "Ready to Experience Luxury?", + "cta_subtitle": "Book your stay today and discover the difference", + "cta_button_text": "Book Now", + "cta_button_link": "/rooms", + "cta_image": "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1200", + "is_active": True + } + + if existing: + for key, value in homepage_data.items(): + if key != "page_type": + setattr(existing, key, value) + print("✓ Updated existing homepage content") + else: + new_content = PageContent(**homepage_data) + db.add(new_content) + print("✓ Created new homepage content") + + db.commit() + +def seed_footer_content(db: Session): + """Seed comprehensive footer content""" + existing = db.query(PageContent).filter(PageContent.page_type == PageType.FOOTER).first() + + # Contact Info + contact_info = { + "phone": "+1 (555) 123-4567", + "email": "info@luxuryhotel.com", + "address": "123 Luxury Avenue, Premium District, City 12345" + } + + # Social Links + social_links = { + "facebook": "https://facebook.com/luxuryhotel", + "twitter": "https://twitter.com/luxuryhotel", + "instagram": "https://instagram.com/luxuryhotel", + "linkedin": "https://linkedin.com/company/luxuryhotel", + "youtube": "https://youtube.com/luxuryhotel" + } + + # Footer Links + footer_links = { + "quick_links": [ + {"label": "Home", "url": "/"}, + {"label": "Rooms & Suites", "url": "/rooms"}, + {"label": "About Us", "url": "/about"}, + {"label": "Contact", "url": "/contact"}, + {"label": "Gallery", "url": "/gallery"} + ], + "support_links": [ + {"label": "FAQ", "url": "/faq"}, + {"label": "Privacy Policy", "url": "/privacy"}, + {"label": "Terms of Service", "url": "/terms"}, + {"label": "Cancellation Policy", "url": "/cancellation"}, + {"label": "Accessibility", "url": "/accessibility"} + ] + } + + # Badges + badges = [ + { + "text": "5-Star Rated", + "icon": "Star" + }, + { + "text": "Award Winning", + "icon": "Award" + }, + { + "text": "Eco Certified", + "icon": "Leaf" + }, + { + "text": "Luxury Collection", + "icon": "Crown" + } + ] + + footer_data = { + "page_type": PageType.FOOTER, + "title": "Luxury Hotel", + "subtitle": "Experience Unparalleled Elegance", + "description": "Your gateway to luxury hospitality and exceptional service", + "contact_info": json.dumps(contact_info), + "social_links": json.dumps(social_links), + "footer_links": json.dumps(footer_links), + "badges": json.dumps(badges), + "copyright_text": "© {YEAR} Luxury Hotel. All rights reserved.", + "is_active": True + } + + if existing: + for key, value in footer_data.items(): + if key != "page_type": + setattr(existing, key, value) + print("✓ Updated existing footer content") + else: + new_content = PageContent(**footer_data) + db.add(new_content) + print("✓ Created new footer content") + + db.commit() + +def main(): + """Main seed function""" + db: Session = SessionLocal() + + try: + print("=" * 80) + print("SEEDING HOMEPAGE AND FOOTER CONTENT") + print("=" * 80) + print() + + print("Seeding homepage content...") + seed_homepage_content(db) + + print("\nSeeding footer content...") + seed_footer_content(db) + + print("\n" + "=" * 80) + print("✓ All content seeded successfully!") + print("=" * 80) + + except Exception as e: + db.rollback() + print(f"\n✗ Error seeding content: {e}") + import traceback + traceback.print_exc() + raise + finally: + db.close() + +if __name__ == "__main__": + main() + diff --git a/Backend/seed_luxury_content.py b/Backend/seed_luxury_content.py new file mode 100644 index 00000000..e84a0ffc --- /dev/null +++ b/Backend/seed_luxury_content.py @@ -0,0 +1,123 @@ +""" +Seed script to populate initial luxury content for the homepage. +Run this script to add default luxury content to the page_content table. +""" +import sys +import os +import json + +# Add the src directory to the path +sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) + +from sqlalchemy.orm import Session +from src.config.database import SessionLocal, engine +from src.models.page_content import PageContent +from src.models.user import User + +def seed_luxury_content(): + """Seed luxury content for the homepage""" + db: Session = SessionLocal() + + try: + # Check if home page content already exists + existing = db.query(PageContent).filter(PageContent.page_type == 'home').first() + + luxury_features = [ + { + "icon": "Sparkles", + "title": "Premium Amenities", + "description": "World-class facilities designed for your comfort and relaxation" + }, + { + "icon": "Crown", + "title": "Royal Service", + "description": "Dedicated concierge service available 24/7 for all your needs" + }, + { + "icon": "Award", + "title": "Award-Winning", + "description": "Recognized for excellence in hospitality and guest satisfaction" + }, + { + "icon": "Shield", + "title": "Secure & Private", + "description": "Your privacy and security are our top priorities" + }, + { + "icon": "Heart", + "title": "Personalized Care", + "description": "Tailored experiences crafted just for you" + }, + { + "icon": "Gem", + "title": "Luxury Design", + "description": "Elegantly designed spaces with attention to every detail" + } + ] + + luxury_testimonials = [ + { + "name": "Sarah Johnson", + "title": "Business Executive", + "quote": "An absolutely stunning experience. The attention to detail and level of service exceeded all expectations.", + "image": "" + }, + { + "name": "Michael Chen", + "title": "Travel Enthusiast", + "quote": "The epitome of luxury. Every moment was perfect, from check-in to check-out.", + "image": "" + }, + { + "name": "Emma Williams", + "title": "Luxury Traveler", + "quote": "This hotel redefines what luxury means. I will definitely return.", + "image": "" + } + ] + + if existing: + # Update existing content + existing.luxury_section_title = "Experience Unparalleled Luxury" + existing.luxury_section_subtitle = "Where elegance meets comfort in every detail" + existing.luxury_section_image = None + existing.luxury_features = json.dumps(luxury_features) + existing.luxury_gallery = json.dumps([]) + existing.luxury_testimonials = json.dumps(luxury_testimonials) + existing.about_preview_title = "About Our Luxury Hotel" + existing.about_preview_content = "Discover a world of refined elegance and exceptional service. Our hotel combines timeless luxury with modern amenities to create an unforgettable experience." + existing.about_preview_image = None + print("✓ Updated existing home page content with luxury sections") + else: + # Create new content + new_content = PageContent( + page_type='home', + luxury_section_title="Experience Unparalleled Luxury", + luxury_section_subtitle="Where elegance meets comfort in every detail", + luxury_section_image=None, + luxury_features=json.dumps(luxury_features), + luxury_gallery=json.dumps([]), + luxury_testimonials=json.dumps(luxury_testimonials), + about_preview_title="About Our Luxury Hotel", + about_preview_content="Discover a world of refined elegance and exceptional service. Our hotel combines timeless luxury with modern amenities to create an unforgettable experience.", + about_preview_image=None, + is_active=True + ) + db.add(new_content) + print("✓ Created new home page content with luxury sections") + + db.commit() + print("✓ Luxury content seeded successfully!") + + except Exception as e: + db.rollback() + print(f"✗ Error seeding luxury content: {e}") + raise + finally: + db.close() + +if __name__ == "__main__": + print("Seeding luxury content...") + seed_luxury_content() + print("Done!") + diff --git a/Backend/seed_rooms.py b/Backend/seed_rooms.py new file mode 100644 index 00000000..277dafae --- /dev/null +++ b/Backend/seed_rooms.py @@ -0,0 +1,317 @@ +#!/usr/bin/env python3 +""" +Seed script to delete all existing rooms and create 50 sample luxury hotel rooms +""" + +import sys +import os +from pathlib import Path + +# Add the parent directory to the path so we can import from src +sys.path.insert(0, str(Path(__file__).parent)) + +from sqlalchemy.orm import Session +from src.config.database import SessionLocal, engine +from src.models.room import Room, RoomStatus +from src.models.room_type import RoomType +from datetime import datetime +import json +import random + +def get_db(): + """Get database session""" + db = SessionLocal() + try: + return db + finally: + pass + +def seed_rooms(db: Session): + """Delete all existing rooms and create 50 sample luxury rooms""" + print("=" * 80) + print("SEEDING ROOMS - DELETING EXISTING AND CREATING 50 NEW LUXURY ROOMS") + print("=" * 80) + + # Get all room types + room_types = db.query(RoomType).all() + if not room_types: + print("❌ No room types found! Please create room types first.") + return + + print(f"\n✓ Found {len(room_types)} room type(s)") + for rt in room_types: + print(f" - {rt.name} (ID: {rt.id}, Base Price: {rt.base_price})") + + # Delete all existing rooms + # First, we need to handle related records that reference these rooms + from src.models.booking import Booking + from src.models.review import Review + from src.models.favorite import Favorite + + existing_rooms = db.query(Room).all() + if existing_rooms: + print(f"\n🗑️ Deleting {len(existing_rooms)} existing room(s)...") + + # Get all room IDs + room_ids = [room.id for room in existing_rooms] + + # Delete bookings that reference these rooms + bookings_with_rooms = db.query(Booking).filter(Booking.room_id.in_(room_ids)).all() + if bookings_with_rooms: + print(f" ⚠️ Found {len(bookings_with_rooms)} booking(s) referencing these rooms") + for booking in bookings_with_rooms: + db.delete(booking) + print(f" ✓ Deleted {len(bookings_with_rooms)} booking(s)") + + # Delete reviews that reference these rooms + reviews_with_rooms = db.query(Review).filter(Review.room_id.in_(room_ids)).all() + if reviews_with_rooms: + print(f" ⚠️ Found {len(reviews_with_rooms)} review(s) referencing these rooms") + for review in reviews_with_rooms: + db.delete(review) + print(f" ✓ Deleted {len(reviews_with_rooms)} review(s)") + + # Delete favorites that reference these rooms + favorites_with_rooms = db.query(Favorite).filter(Favorite.room_id.in_(room_ids)).all() + if favorites_with_rooms: + print(f" ⚠️ Found {len(favorites_with_rooms)} favorite(s) referencing these rooms") + for favorite in favorites_with_rooms: + db.delete(favorite) + print(f" ✓ Deleted {len(favorites_with_rooms)} favorite(s)") + + # Now delete the rooms + for room in existing_rooms: + db.delete(room) + db.commit() + print(f"✓ Deleted {len(existing_rooms)} room(s)") + + # Luxury room configurations + views = [ + "Ocean View", "City View", "Garden View", "Mountain View", + "Pool View", "Beach View", "Panoramic View", "Sea View" + ] + + room_sizes = [ + "35 sqm", "40 sqm", "45 sqm", "50 sqm", "55 sqm", + "60 sqm", "70 sqm", "80 sqm", "90 sqm", "100 sqm", + "120 sqm", "150 sqm", "180 sqm", "200 sqm", "250 sqm" + ] + + # Real luxury hotel room images from Unsplash (defined once, used for all rooms) + luxury_room_images = [ + # Luxury hotel rooms + "https://images.unsplash.com/photo-1631049307264-da0ec9d70304?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1611892440504-42a792e24d32?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1578683010236-d716f9a3f461?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1582719478250-c89cae4dc85b?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1596394516093-501ba68a0ba6?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1618221195710-dd6b41faaea8?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1566665797739-1674de7a421a?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1200&h=800&fit=crop", + # Suite images + "https://images.unsplash.com/photo-1618773928121-c32242e63f39?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1582719508461-905c673771fd?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1595576508898-0ad5c879a061?w=1200&h=800&fit=crop", + # Additional luxury rooms + "https://images.unsplash.com/photo-1571003123894-1f0594d2b5d9?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1566073771259-6a8506099945?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1578683010236-d716f9a3f461?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1596394516093-501ba68a0ba6?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1631049307264-da0ec9d70304?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1611892440504-42a792e24d32?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1590490360182-c33d57733427?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1564501049412-61c2a3083791?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1582719478250-c89cae4dc85b?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1618221195710-dd6b41faaea8?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1566665797739-1674de7a421a?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1618773928121-c32242e63f39?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1582719508461-905c673771fd?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1595576508898-0ad5c879a061?w=1200&h=800&fit=crop", + "https://images.unsplash.com/photo-1571003123894-1f0594d2b5d9?w=1200&h=800&fit=crop", + ] + + # Comprehensive luxury amenities + all_amenities = [ + "Free WiFi", "High-Speed Internet", "Smart TV", "Netflix", + "Air Conditioning", "Climate Control", "Private Balcony", + "Ocean View", "City View", "Minibar", "Coffee Maker", + "Espresso Machine", "Refrigerator", "Safe", "Iron & Ironing Board", + "Hair Dryer", "Premium Toiletries", "Bathrobes", "Slippers", + "Work Desk", "Ergonomic Chair", "USB Charging Ports", + "Bluetooth Speaker", "Sound System", "Blackout Curtains", + "Pillow Menu", "Turndown Service", "Room Service", "24/7 Concierge" + ] + + premium_amenities = [ + "Jacuzzi Bathtub", "Steam Shower", "Rain Shower", "Bidet", + "Private Pool", "Outdoor Terrace", "Fireplace", "Wine Cellar", + "Private Bar", "Butler Service", "Private Elevator", "Helipad Access" + ] + + # Room configurations: (floor_range, room_numbers_per_floor, view, size_range, amenities_count, featured) + room_configs = [ + # Standard Rooms (Floors 1-3) + ((1, 3), 8, "Garden View", (35, 45), 8, False), + ((1, 3), 8, "City View", (40, 50), 9, False), + + # Superior Rooms (Floors 4-6) + ((4, 6), 6, "City View", (45, 55), 10, False), + ((4, 6), 6, "Pool View", (50, 60), 11, True), + + # Deluxe Rooms (Floors 7-9) + ((7, 9), 5, "Ocean View", (55, 70), 12, True), + ((7, 9), 5, "Mountain View", (60, 75), 12, False), + + # Executive Suites (Floors 10-12) + ((10, 12), 4, "Panoramic View", (80, 100), 14, True), + ((10, 12), 4, "Sea View", (90, 110), 15, True), + + # Luxury Suites (Floors 13-15) + ((13, 15), 3, "Ocean View", (120, 150), 16, True), + ((13, 15), 3, "Beach View", (130, 160), 17, True), + + # Presidential Suites (Floor 16) + ((16, 16), 2, "Panoramic View", (200, 250), 20, True), + ] + + rooms_created = [] + room_counter = 101 # Starting room number + + print(f"\n🏨 Creating 50 luxury rooms...\n") + + for config in room_configs: + floor_range, rooms_per_floor, view_type, size_range, amenities_count, featured = config + + for floor in range(floor_range[0], floor_range[1] + 1): + for _ in range(rooms_per_floor): + if len(rooms_created) >= 50: + break + + # Select random room type based on floor + if floor <= 3: + room_type = random.choice([rt for rt in room_types if 'standard' in rt.name.lower() or 'superior' in rt.name.lower()] or room_types) + elif floor <= 6: + room_type = random.choice([rt for rt in room_types if 'superior' in rt.name.lower() or 'deluxe' in rt.name.lower()] or room_types) + elif floor <= 9: + room_type = random.choice([rt for rt in room_types if 'deluxe' in rt.name.lower() or 'executive' in rt.name.lower()] or room_types) + elif floor <= 12: + room_type = random.choice([rt for rt in room_types if 'executive' in rt.name.lower() or 'suite' in rt.name.lower()] or room_types) + else: + room_type = random.choice([rt for rt in room_types if 'suite' in rt.name.lower() or 'presidential' in rt.name.lower()] or room_types) + + # If no matching room type, use random + if not room_type: + room_type = random.choice(room_types) + + # Calculate price (base price + floor premium + view premium + random variation) + base_price = float(room_type.base_price) + floor_premium = (floor - 1) * 5 # +5 per floor + view_premium = 20 if "Ocean" in view_type or "Sea" in view_type or "Beach" in view_type else 0 + view_premium += 15 if "Panoramic" in view_type else 0 + view_premium += 10 if "Mountain" in view_type else 0 + view_premium += 5 if "Pool" in view_type else 0 + # Add random variation (-5% to +10% of base price) + random_variation = base_price * random.uniform(-0.05, 0.10) + # Size premium (larger rooms cost more) + size_min, size_max = size_range + size_premium = (size_min + size_max) / 2 * 0.5 # ~0.5 per sqm + price = base_price + floor_premium + view_premium + random_variation + size_premium + # Ensure minimum price and round to 2 decimal places + price = max(base_price * 0.95, price) + price = round(price, 2) + + # Select amenities + selected_amenities = random.sample(all_amenities, min(amenities_count, len(all_amenities))) + if floor >= 13: # Add premium amenities for luxury suites + premium_count = min(2, len(premium_amenities)) + selected_amenities.extend(random.sample(premium_amenities, premium_count)) + + # Room size + size_min, size_max = size_range + room_size = f"{random.randint(size_min, size_max)} sqm" + + # Capacity (based on room type, with some variation) + capacity = room_type.capacity + if random.random() > 0.7: # 30% chance to have different capacity + capacity = max(1, capacity + random.randint(-1, 1)) + + # Room number + room_number = f"{floor}{room_counter % 100:02d}" + room_counter += 1 + + # Select 3 unique images for each room (ensure we always have images) + # Shuffle the list each time to get different combinations + shuffled_images = luxury_room_images.copy() + random.shuffle(shuffled_images) + image_urls = shuffled_images[:3] # Always take first 3 after shuffle + + # Description + descriptions = [ + f"Elegantly designed {view_type.lower()} room with modern luxury amenities and breathtaking views.", + f"Spacious {view_type.lower()} accommodation featuring premium furnishings and world-class comfort.", + f"Luxurious {view_type.lower()} room with sophisticated decor and exceptional attention to detail.", + f"Exquisite {view_type.lower()} suite offering unparalleled elegance and personalized service.", + f"Opulent {view_type.lower()} accommodation with bespoke interiors and premium amenities.", + ] + description = random.choice(descriptions) + + # Status (mostly available, some in maintenance/cleaning) + status_weights = [0.85, 0.05, 0.05, 0.05] # available, occupied, maintenance, cleaning + status = random.choices( + [RoomStatus.available, RoomStatus.occupied, RoomStatus.maintenance, RoomStatus.cleaning], + weights=status_weights + )[0] + + # Create room + room = Room( + room_type_id=room_type.id, + room_number=room_number, + floor=floor, + status=status, + price=price, + featured=featured, + capacity=capacity, + room_size=room_size, + view=view_type, + images=json.dumps(image_urls), + amenities=json.dumps(selected_amenities), + description=description + ) + + db.add(room) + rooms_created.append({ + 'number': room_number, + 'floor': floor, + 'type': room_type.name, + 'view': view_type, + 'price': price + }) + + print(f" ✓ Created Room {room_number} - Floor {floor}, {room_type.name}, {view_type}, {room_size}, €{price:.2f}") + + db.commit() + print(f"\n✅ Successfully created {len(rooms_created)} luxury rooms!") + print(f"\n📊 Summary:") + featured_count = sum(1 for r in rooms_created if any( + config[5] and r['floor'] >= config[0][0] and r['floor'] <= config[0][1] + for config in room_configs + )) + print(f" - Featured rooms: {featured_count}") + print(f" - Floors: {min(r['floor'] for r in rooms_created)} - {max(r['floor'] for r in rooms_created)}") + print(f" - Price range: €{min(r['price'] for r in rooms_created):.2f} - €{max(r['price'] for r in rooms_created):.2f}") + print("=" * 80) + +if __name__ == "__main__": + db = get_db() + try: + seed_rooms(db) + except Exception as e: + print(f"\n❌ Error: {e}") + import traceback + traceback.print_exc() + db.rollback() + finally: + db.close() + diff --git a/Backend/src/__pycache__/main.cpython-312.pyc b/Backend/src/__pycache__/main.cpython-312.pyc index 65d9cdf6..adc77dfc 100644 Binary files a/Backend/src/__pycache__/main.cpython-312.pyc and b/Backend/src/__pycache__/main.cpython-312.pyc differ diff --git a/Backend/src/main.py b/Backend/src/main.py index 6cc3a81a..c4ecefaa 100644 --- a/Backend/src/main.py +++ b/Backend/src/main.py @@ -200,7 +200,8 @@ from .routes import ( room_routes, booking_routes, payment_routes, invoice_routes, banner_routes, favorite_routes, service_routes, service_booking_routes, promotion_routes, report_routes, review_routes, user_routes, audit_routes, admin_privacy_routes, - system_settings_routes, contact_routes, page_content_routes + system_settings_routes, contact_routes, page_content_routes, + home_routes, about_routes, contact_content_routes, footer_routes ) # Legacy routes (maintain backward compatibility) @@ -220,6 +221,10 @@ app.include_router(audit_routes.router, prefix="/api") app.include_router(admin_privacy_routes.router, prefix="/api") app.include_router(system_settings_routes.router, prefix="/api") app.include_router(contact_routes.router, prefix="/api") +app.include_router(home_routes.router, prefix="/api") +app.include_router(about_routes.router, prefix="/api") +app.include_router(contact_content_routes.router, prefix="/api") +app.include_router(footer_routes.router, prefix="/api") # Versioned routes (v1) app.include_router(room_routes.router, prefix=settings.API_V1_PREFIX) @@ -238,6 +243,10 @@ app.include_router(audit_routes.router, prefix=settings.API_V1_PREFIX) app.include_router(admin_privacy_routes.router, prefix=settings.API_V1_PREFIX) app.include_router(system_settings_routes.router, prefix=settings.API_V1_PREFIX) app.include_router(contact_routes.router, prefix=settings.API_V1_PREFIX) +app.include_router(home_routes.router, prefix=settings.API_V1_PREFIX) +app.include_router(about_routes.router, prefix=settings.API_V1_PREFIX) +app.include_router(contact_content_routes.router, prefix=settings.API_V1_PREFIX) +app.include_router(footer_routes.router, prefix=settings.API_V1_PREFIX) app.include_router(page_content_routes.router, prefix="/api") app.include_router(page_content_routes.router, prefix=settings.API_V1_PREFIX) diff --git a/Backend/src/middleware/__pycache__/auth.cpython-312.pyc b/Backend/src/middleware/__pycache__/auth.cpython-312.pyc index 045b62bc..8e66e788 100644 Binary files a/Backend/src/middleware/__pycache__/auth.cpython-312.pyc and b/Backend/src/middleware/__pycache__/auth.cpython-312.pyc differ diff --git a/Backend/src/middleware/auth.py b/Backend/src/middleware/auth.py index 16839adf..6eecf1bf 100644 --- a/Backend/src/middleware/auth.py +++ b/Backend/src/middleware/auth.py @@ -8,6 +8,7 @@ import os from ..config.database import get_db from ..config.settings import settings from ..models.user import User +from ..models.role import Role security = HTTPBearer() @@ -46,10 +47,20 @@ def authorize_roles(*allowed_roles: str): """ Check if user has required role """ - def role_checker(current_user: User = Depends(get_current_user)) -> User: - # Map role IDs to role names - role_map = {1: "admin", 2: "staff", 3: "customer"} - user_role_name = role_map.get(current_user.role_id) + def role_checker( + current_user: User = Depends(get_current_user), + db: Session = Depends(get_db) + ) -> User: + # Query the role from database instead of using hardcoded IDs + role = db.query(Role).filter(Role.id == current_user.role_id).first() + + if not role: + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail="User role not found" + ) + + user_role_name = role.name if user_role_name not in allowed_roles: raise HTTPException( diff --git a/Backend/src/models/__pycache__/page_content.cpython-312.pyc b/Backend/src/models/__pycache__/page_content.cpython-312.pyc index ce674008..4cae9e91 100644 Binary files a/Backend/src/models/__pycache__/page_content.cpython-312.pyc and b/Backend/src/models/__pycache__/page_content.cpython-312.pyc differ diff --git a/Backend/src/models/page_content.py b/Backend/src/models/page_content.py index 31b8304f..4fe410df 100644 --- a/Backend/src/models/page_content.py +++ b/Backend/src/models/page_content.py @@ -41,6 +41,7 @@ class PageContent(Base): social_links = Column(Text, nullable=True) # JSON: facebook, twitter, instagram, etc. footer_links = Column(Text, nullable=True) # JSON: quick links, support links badges = Column(Text, nullable=True) # JSON: array of badges with text and icon + copyright_text = Column(Text, nullable=True) # Copyright text with {YEAR} placeholder for automatic year # Home page specific hero_title = Column(String(500), nullable=True) @@ -51,6 +52,57 @@ class PageContent(Base): story_content = Column(Text, nullable=True) values = Column(Text, nullable=True) # JSON array of values features = Column(Text, nullable=True) # JSON array of features + about_hero_image = Column(Text, nullable=True) # Hero image for about page + mission = Column(Text, nullable=True) # Mission statement + vision = Column(Text, nullable=True) # Vision statement + team = Column(Text, nullable=True) # JSON array of team members with name, role, image, bio, social_links + timeline = Column(Text, nullable=True) # JSON array of timeline events with year, title, description, image + achievements = Column(Text, nullable=True) # JSON array of achievements with icon, title, description, year, image + + # Home page luxury sections + luxury_section_title = Column(Text, nullable=True) + luxury_section_subtitle = Column(Text, nullable=True) + luxury_section_image = Column(Text, nullable=True) + luxury_features = Column(Text, nullable=True) # JSON array of features with icon, title, description + luxury_gallery_section_title = Column(Text, nullable=True) + luxury_gallery_section_subtitle = Column(Text, nullable=True) + luxury_gallery = Column(Text, nullable=True) # JSON array of image URLs + luxury_testimonials_section_title = Column(Text, nullable=True) + luxury_testimonials_section_subtitle = Column(Text, nullable=True) + luxury_testimonials = Column(Text, nullable=True) # JSON array of testimonials + amenities_section_title = Column(String(500), nullable=True) + amenities_section_subtitle = Column(String(1000), nullable=True) + amenities = Column(Text, nullable=True) # JSON array of amenities with icon, title, description, image + testimonials_section_title = Column(String(500), nullable=True) + testimonials_section_subtitle = Column(String(1000), nullable=True) + testimonials = Column(Text, nullable=True) # JSON array of testimonials with name, role, image, rating, comment + gallery_section_title = Column(String(500), nullable=True) + gallery_section_subtitle = Column(String(1000), nullable=True) + gallery_images = Column(Text, nullable=True) # JSON array of image URLs + about_preview_title = Column(String(500), nullable=True) + about_preview_subtitle = Column(String(1000), nullable=True) + about_preview_content = Column(Text, nullable=True) + about_preview_image = Column(String(1000), nullable=True) + stats = Column(Text, nullable=True) # JSON array of stats with number, label, icon + + # Additional luxury sections + luxury_services_section_title = Column(Text, nullable=True) + luxury_services_section_subtitle = Column(Text, nullable=True) + luxury_services = Column(Text, nullable=True) # JSON array of services with icon, title, description, image + luxury_experiences_section_title = Column(Text, nullable=True) + luxury_experiences_section_subtitle = Column(Text, nullable=True) + luxury_experiences = Column(Text, nullable=True) # JSON array of experiences with icon, title, description, image + awards_section_title = Column(Text, nullable=True) + awards_section_subtitle = Column(Text, nullable=True) + awards = Column(Text, nullable=True) # JSON array of awards with icon, title, description, image, year + cta_title = Column(Text, nullable=True) + cta_subtitle = Column(Text, nullable=True) + cta_button_text = Column(Text, nullable=True) + cta_button_link = Column(Text, nullable=True) + cta_image = Column(Text, nullable=True) + partners_section_title = Column(Text, nullable=True) + partners_section_subtitle = Column(Text, nullable=True) + partners = Column(Text, nullable=True) # JSON array of partners with name, logo, link # Status is_active = Column(Boolean, default=True, nullable=False) diff --git a/Backend/src/routes/__pycache__/about_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/about_routes.cpython-312.pyc new file mode 100644 index 00000000..100d5620 Binary files /dev/null and b/Backend/src/routes/__pycache__/about_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/auth_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/auth_routes.cpython-312.pyc index 29636dae..6ab38810 100644 Binary files a/Backend/src/routes/__pycache__/auth_routes.cpython-312.pyc and b/Backend/src/routes/__pycache__/auth_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/banner_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/banner_routes.cpython-312.pyc index d4f80946..b8066e23 100644 Binary files a/Backend/src/routes/__pycache__/banner_routes.cpython-312.pyc and b/Backend/src/routes/__pycache__/banner_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/booking_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/booking_routes.cpython-312.pyc index d585b061..d3f86caa 100644 Binary files a/Backend/src/routes/__pycache__/booking_routes.cpython-312.pyc and b/Backend/src/routes/__pycache__/booking_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/contact_content_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/contact_content_routes.cpython-312.pyc new file mode 100644 index 00000000..8b68b733 Binary files /dev/null and b/Backend/src/routes/__pycache__/contact_content_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/footer_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/footer_routes.cpython-312.pyc new file mode 100644 index 00000000..35267d80 Binary files /dev/null and b/Backend/src/routes/__pycache__/footer_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/home_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/home_routes.cpython-312.pyc new file mode 100644 index 00000000..c2edcee5 Binary files /dev/null and b/Backend/src/routes/__pycache__/home_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/invoice_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/invoice_routes.cpython-312.pyc index fe3adf71..42be7939 100644 Binary files a/Backend/src/routes/__pycache__/invoice_routes.cpython-312.pyc and b/Backend/src/routes/__pycache__/invoice_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/page_content_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/page_content_routes.cpython-312.pyc index 2e11cc3c..030cbc55 100644 Binary files a/Backend/src/routes/__pycache__/page_content_routes.cpython-312.pyc and b/Backend/src/routes/__pycache__/page_content_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/payment_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/payment_routes.cpython-312.pyc index bd5a77c9..918a552c 100644 Binary files a/Backend/src/routes/__pycache__/payment_routes.cpython-312.pyc and b/Backend/src/routes/__pycache__/payment_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/room_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/room_routes.cpython-312.pyc index 3655bf7b..b9d6e939 100644 Binary files a/Backend/src/routes/__pycache__/room_routes.cpython-312.pyc and b/Backend/src/routes/__pycache__/room_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/__pycache__/system_settings_routes.cpython-312.pyc b/Backend/src/routes/__pycache__/system_settings_routes.cpython-312.pyc index 92256f58..219c8b74 100644 Binary files a/Backend/src/routes/__pycache__/system_settings_routes.cpython-312.pyc and b/Backend/src/routes/__pycache__/system_settings_routes.cpython-312.pyc differ diff --git a/Backend/src/routes/about_routes.py b/Backend/src/routes/about_routes.py new file mode 100644 index 00000000..e753b119 --- /dev/null +++ b/Backend/src/routes/about_routes.py @@ -0,0 +1,75 @@ +from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy.orm import Session +import json + +from ..config.database import get_db +from ..config.logging_config import get_logger +from ..models.page_content import PageContent, PageType + +logger = get_logger(__name__) + +router = APIRouter(prefix="/about", tags=["about"]) + + +def serialize_page_content(content: PageContent) -> dict: + """Serialize PageContent model to dictionary""" + return { + "id": content.id, + "page_type": content.page_type.value, + "title": content.title, + "subtitle": content.subtitle, + "description": content.description, + "content": content.content, + "meta_title": content.meta_title, + "meta_description": content.meta_description, + "meta_keywords": content.meta_keywords, + "og_title": content.og_title, + "og_description": content.og_description, + "og_image": content.og_image, + "canonical_url": content.canonical_url, + "story_content": content.story_content, + "values": json.loads(content.values) if content.values else None, + "features": json.loads(content.features) if content.features else None, + "about_hero_image": content.about_hero_image, + "mission": content.mission, + "vision": content.vision, + "team": json.loads(content.team) if content.team else None, + "timeline": json.loads(content.timeline) if content.timeline else None, + "achievements": json.loads(content.achievements) if content.achievements else None, + "is_active": content.is_active, + "created_at": content.created_at.isoformat() if content.created_at else None, + "updated_at": content.updated_at.isoformat() if content.updated_at else None, + } + + +@router.get("/") +async def get_about_content( + db: Session = Depends(get_db) +): + """Get about page content""" + try: + content = db.query(PageContent).filter(PageContent.page_type == PageType.ABOUT).first() + + if not content: + return { + "status": "success", + "data": { + "page_content": None + } + } + + content_dict = serialize_page_content(content) + + return { + "status": "success", + "data": { + "page_content": content_dict + } + } + except Exception as e: + logger.error(f"Error fetching about content: {str(e)}", exc_info=True) + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail=f"Error fetching about content: {str(e)}" + ) + diff --git a/Backend/src/routes/auth_routes.py b/Backend/src/routes/auth_routes.py index f19ea597..4dfddad4 100644 --- a/Backend/src/routes/auth_routes.py +++ b/Backend/src/routes/auth_routes.py @@ -495,6 +495,7 @@ async def upload_avatar( full_url = normalize_image_url(image_url, base_url) return { + "success": True, "status": "success", "message": "Avatar uploaded successfully", "data": { diff --git a/Backend/src/routes/banner_routes.py b/Backend/src/routes/banner_routes.py index 3328f36a..45c4e906 100644 --- a/Backend/src/routes/banner_routes.py +++ b/Backend/src/routes/banner_routes.py @@ -246,11 +246,25 @@ async def upload_banner_image( ): """Upload banner image (Admin only)""" try: + # Validate file exists + if not image: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail="No file provided" + ) + # Validate file type if not image.content_type or not image.content_type.startswith('image/'): raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, - detail="File must be an image" + detail=f"File must be an image. Received: {image.content_type}" + ) + + # Validate filename + if not image.filename: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail="Filename is required" ) # Create uploads directory @@ -258,21 +272,27 @@ async def upload_banner_image( upload_dir.mkdir(parents=True, exist_ok=True) # Generate filename - ext = Path(image.filename).suffix + ext = Path(image.filename).suffix or '.jpg' filename = f"banner-{uuid.uuid4()}{ext}" file_path = upload_dir / filename # Save file async with aiofiles.open(file_path, 'wb') as f: content = await image.read() + if not content: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail="File is empty" + ) await f.write(content) # Return the image URL image_url = f"/uploads/banners/{filename}" base_url = get_base_url(request) full_url = normalize_image_url(image_url, base_url) - + return { + "success": True, "status": "success", "message": "Image uploaded successfully", "data": { diff --git a/Backend/src/routes/booking_routes.py b/Backend/src/routes/booking_routes.py index ad952ba4..24e94d6f 100644 --- a/Backend/src/routes/booking_routes.py +++ b/Backend/src/routes/booking_routes.py @@ -61,6 +61,11 @@ def _generate_invoice_email_html(invoice: dict, is_proforma: bool = False) -> st text-align: center; border-radius: 8px 8px 0 0; }} + .company-logo {{ + max-width: 150px; + max-height: 80px; + margin-bottom: 10px; + }} .content {{ background-color: #ffffff; padding: 30px; @@ -109,6 +114,8 @@ def _generate_invoice_email_html(invoice: dict, is_proforma: bool = False) -> st
+ {f'' if invoice.get('company_logo_url') else ''} + {f'

{invoice.get("company_name", "")}

' if invoice.get('company_name') else ''}

{invoice_type}

@@ -139,6 +146,7 @@ def _generate_invoice_email_html(invoice: dict, is_proforma: bool = False) -> st

Subtotal: {invoice.get('subtotal', 0):.2f}

{f'

Discount: -{invoice.get("discount_amount", 0):.2f}

' if invoice.get('discount_amount', 0) > 0 else ''} + {f'

Promotion Code: {invoice.get("promotion_code", "")}

' if invoice.get('promotion_code') else ''}

Tax: {invoice.get('tax_amount', 0):.2f}

Total Amount: {invoice.get('total_amount', 0):.2f}

Amount Paid: {invoice.get('amount_paid', 0):.2f}

@@ -729,19 +737,31 @@ async def create_booking( # Get discount from booking booking_discount = float(booking.discount_amount) if booking.discount_amount else 0.0 + # Add promotion code to invoice notes if present + invoice_notes = invoice_kwargs.get("notes", "") + if booking.promotion_code: + promotion_note = f"Promotion Code: {booking.promotion_code}" + invoice_notes = f"{promotion_note}\n{invoice_notes}".strip() if invoice_notes else promotion_note + invoice_kwargs["notes"] = invoice_notes + # Create invoices based on payment method if payment_method == "cash": # For cash bookings: create invoice for 20% deposit + proforma for 80% remaining deposit_amount = float(total_price) * 0.2 remaining_amount = float(total_price) * 0.8 + # Calculate proportional discount for partial invoices + # Deposit invoice gets 20% of the discount, proforma gets 80% + deposit_discount = booking_discount * 0.2 if booking_discount > 0 else 0.0 + proforma_discount = booking_discount * 0.8 if booking_discount > 0 else 0.0 + # Create invoice for deposit (20%) deposit_invoice = InvoiceService.create_invoice_from_booking( booking_id=booking.id, db=db, created_by_id=current_user.id, tax_rate=tax_rate, - discount_amount=booking_discount, + discount_amount=deposit_discount, due_days=30, is_proforma=False, invoice_amount=deposit_amount, @@ -754,7 +774,7 @@ async def create_booking( db=db, created_by_id=current_user.id, tax_rate=tax_rate, - discount_amount=booking_discount, + discount_amount=proforma_discount, due_days=30, is_proforma=True, invoice_amount=remaining_amount, diff --git a/Backend/src/routes/contact_content_routes.py b/Backend/src/routes/contact_content_routes.py new file mode 100644 index 00000000..b239df30 --- /dev/null +++ b/Backend/src/routes/contact_content_routes.py @@ -0,0 +1,68 @@ +from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy.orm import Session +import json + +from ..config.database import get_db +from ..config.logging_config import get_logger +from ..models.page_content import PageContent, PageType + +logger = get_logger(__name__) + +router = APIRouter(prefix="/contact-content", tags=["contact-content"]) + + +def serialize_page_content(content: PageContent) -> dict: + """Serialize PageContent model to dictionary""" + return { + "id": content.id, + "page_type": content.page_type.value, + "title": content.title, + "subtitle": content.subtitle, + "description": content.description, + "content": content.content, + "meta_title": content.meta_title, + "meta_description": content.meta_description, + "meta_keywords": content.meta_keywords, + "og_title": content.og_title, + "og_description": content.og_description, + "og_image": content.og_image, + "canonical_url": content.canonical_url, + "contact_info": json.loads(content.contact_info) if content.contact_info else None, + "map_url": content.map_url, + "is_active": content.is_active, + "created_at": content.created_at.isoformat() if content.created_at else None, + "updated_at": content.updated_at.isoformat() if content.updated_at else None, + } + + +@router.get("/") +async def get_contact_content( + db: Session = Depends(get_db) +): + """Get contact page content""" + try: + content = db.query(PageContent).filter(PageContent.page_type == PageType.CONTACT).first() + + if not content: + return { + "status": "success", + "data": { + "page_content": None + } + } + + content_dict = serialize_page_content(content) + + return { + "status": "success", + "data": { + "page_content": content_dict + } + } + except Exception as e: + logger.error(f"Error fetching contact content: {str(e)}", exc_info=True) + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail=f"Error fetching contact content: {str(e)}" + ) + diff --git a/Backend/src/routes/footer_routes.py b/Backend/src/routes/footer_routes.py new file mode 100644 index 00000000..ba577829 --- /dev/null +++ b/Backend/src/routes/footer_routes.py @@ -0,0 +1,63 @@ +from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy.orm import Session +import json + +from ..config.database import get_db +from ..config.logging_config import get_logger +from ..models.page_content import PageContent, PageType + +logger = get_logger(__name__) + +router = APIRouter(prefix="/footer", tags=["footer"]) + + +def serialize_page_content(content: PageContent) -> dict: + """Serialize PageContent model to dictionary""" + return { + "id": content.id, + "page_type": content.page_type.value, + "title": content.title, + "subtitle": content.subtitle, + "description": content.description, + "content": content.content, + "social_links": json.loads(content.social_links) if content.social_links else None, + "footer_links": json.loads(content.footer_links) if content.footer_links else None, + "badges": json.loads(content.badges) if content.badges else None, + "copyright_text": content.copyright_text, + "is_active": content.is_active, + "created_at": content.created_at.isoformat() if content.created_at else None, + "updated_at": content.updated_at.isoformat() if content.updated_at else None, + } + + +@router.get("/") +async def get_footer_content( + db: Session = Depends(get_db) +): + """Get footer content""" + try: + content = db.query(PageContent).filter(PageContent.page_type == PageType.FOOTER).first() + + if not content: + return { + "status": "success", + "data": { + "page_content": None + } + } + + content_dict = serialize_page_content(content) + + return { + "status": "success", + "data": { + "page_content": content_dict + } + } + except Exception as e: + logger.error(f"Error fetching footer content: {str(e)}", exc_info=True) + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail=f"Error fetching footer content: {str(e)}" + ) + diff --git a/Backend/src/routes/home_routes.py b/Backend/src/routes/home_routes.py new file mode 100644 index 00000000..5163c81e --- /dev/null +++ b/Backend/src/routes/home_routes.py @@ -0,0 +1,110 @@ +from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy.orm import Session +import json + +from ..config.database import get_db +from ..config.logging_config import get_logger +from ..models.page_content import PageContent, PageType + +logger = get_logger(__name__) + +router = APIRouter(prefix="/home", tags=["home"]) + + +def serialize_page_content(content: PageContent) -> dict: + """Serialize PageContent model to dictionary""" + return { + "id": content.id, + "page_type": content.page_type.value, + "title": content.title, + "subtitle": content.subtitle, + "description": content.description, + "content": content.content, + "meta_title": content.meta_title, + "meta_description": content.meta_description, + "meta_keywords": content.meta_keywords, + "og_title": content.og_title, + "og_description": content.og_description, + "og_image": content.og_image, + "canonical_url": content.canonical_url, + "hero_title": content.hero_title, + "hero_subtitle": content.hero_subtitle, + "hero_image": content.hero_image, + "amenities_section_title": content.amenities_section_title, + "amenities_section_subtitle": content.amenities_section_subtitle, + "amenities": json.loads(content.amenities) if content.amenities else None, + "testimonials_section_title": content.testimonials_section_title, + "testimonials_section_subtitle": content.testimonials_section_subtitle, + "testimonials": json.loads(content.testimonials) if content.testimonials else None, + "gallery_section_title": content.gallery_section_title, + "gallery_section_subtitle": content.gallery_section_subtitle, + "gallery_images": json.loads(content.gallery_images) if content.gallery_images else None, + "luxury_section_title": content.luxury_section_title, + "luxury_section_subtitle": content.luxury_section_subtitle, + "luxury_section_image": content.luxury_section_image, + "luxury_features": json.loads(content.luxury_features) if content.luxury_features else None, + "luxury_gallery_section_title": content.luxury_gallery_section_title, + "luxury_gallery_section_subtitle": content.luxury_gallery_section_subtitle, + "luxury_gallery": json.loads(content.luxury_gallery) if content.luxury_gallery else None, + "luxury_testimonials_section_title": content.luxury_testimonials_section_title, + "luxury_testimonials_section_subtitle": content.luxury_testimonials_section_subtitle, + "luxury_testimonials": json.loads(content.luxury_testimonials) if content.luxury_testimonials else None, + "about_preview_title": content.about_preview_title, + "about_preview_subtitle": content.about_preview_subtitle, + "about_preview_content": content.about_preview_content, + "about_preview_image": content.about_preview_image, + "stats": json.loads(content.stats) if content.stats else None, + "luxury_services_section_title": content.luxury_services_section_title, + "luxury_services_section_subtitle": content.luxury_services_section_subtitle, + "luxury_services": json.loads(content.luxury_services) if content.luxury_services else None, + "luxury_experiences_section_title": content.luxury_experiences_section_title, + "luxury_experiences_section_subtitle": content.luxury_experiences_section_subtitle, + "luxury_experiences": json.loads(content.luxury_experiences) if content.luxury_experiences else None, + "awards_section_title": content.awards_section_title, + "awards_section_subtitle": content.awards_section_subtitle, + "awards": json.loads(content.awards) if content.awards else None, + "cta_title": content.cta_title, + "cta_subtitle": content.cta_subtitle, + "cta_button_text": content.cta_button_text, + "cta_button_link": content.cta_button_link, + "cta_image": content.cta_image, + "partners_section_title": content.partners_section_title, + "partners_section_subtitle": content.partners_section_subtitle, + "partners": json.loads(content.partners) if content.partners else None, + "is_active": content.is_active, + "created_at": content.created_at.isoformat() if content.created_at else None, + "updated_at": content.updated_at.isoformat() if content.updated_at else None, + } + + +@router.get("/") +async def get_home_content( + db: Session = Depends(get_db) +): + """Get homepage content""" + try: + content = db.query(PageContent).filter(PageContent.page_type == PageType.HOME).first() + + if not content: + return { + "status": "success", + "data": { + "page_content": None + } + } + + content_dict = serialize_page_content(content) + + return { + "status": "success", + "data": { + "page_content": content_dict + } + } + except Exception as e: + logger.error(f"Error fetching home content: {str(e)}", exc_info=True) + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail=f"Error fetching home content: {str(e)}" + ) + diff --git a/Backend/src/routes/invoice_routes.py b/Backend/src/routes/invoice_routes.py index 72a6be88..c121b123 100644 --- a/Backend/src/routes/invoice_routes.py +++ b/Backend/src/routes/invoice_routes.py @@ -87,11 +87,38 @@ async def create_invoice( if not booking_id: raise HTTPException(status_code=400, detail="booking_id is required") + # Ensure booking_id is an integer + try: + booking_id = int(booking_id) + except (ValueError, TypeError): + raise HTTPException(status_code=400, detail="booking_id must be a valid integer") + # Check if booking exists booking = db.query(Booking).filter(Booking.id == booking_id).first() if not booking: raise HTTPException(status_code=404, detail="Booking not found") + # Prepare invoice kwargs + invoice_kwargs = { + "company_name": invoice_data.get("company_name"), + "company_address": invoice_data.get("company_address"), + "company_phone": invoice_data.get("company_phone"), + "company_email": invoice_data.get("company_email"), + "company_tax_id": invoice_data.get("company_tax_id"), + "company_logo_url": invoice_data.get("company_logo_url"), + "customer_tax_id": invoice_data.get("customer_tax_id"), + "notes": invoice_data.get("notes"), + "terms_and_conditions": invoice_data.get("terms_and_conditions"), + "payment_instructions": invoice_data.get("payment_instructions"), + } + + # Add promotion code to invoice notes if present in booking + invoice_notes = invoice_kwargs.get("notes", "") + if booking.promotion_code: + promotion_note = f"Promotion Code: {booking.promotion_code}" + invoice_notes = f"{promotion_note}\n{invoice_notes}".strip() if invoice_notes else promotion_note + invoice_kwargs["notes"] = invoice_notes + # Create invoice invoice = InvoiceService.create_invoice_from_booking( booking_id=booking_id, @@ -100,16 +127,7 @@ async def create_invoice( tax_rate=invoice_data.get("tax_rate", 0.0), discount_amount=invoice_data.get("discount_amount", 0.0), due_days=invoice_data.get("due_days", 30), - company_name=invoice_data.get("company_name"), - company_address=invoice_data.get("company_address"), - company_phone=invoice_data.get("company_phone"), - company_email=invoice_data.get("company_email"), - company_tax_id=invoice_data.get("company_tax_id"), - company_logo_url=invoice_data.get("company_logo_url"), - customer_tax_id=invoice_data.get("customer_tax_id"), - notes=invoice_data.get("notes"), - terms_and_conditions=invoice_data.get("terms_and_conditions"), - payment_instructions=invoice_data.get("payment_instructions"), + **invoice_kwargs ) return { diff --git a/Backend/src/routes/page_content_routes.py b/Backend/src/routes/page_content_routes.py index 05e1291f..bebef6eb 100644 --- a/Backend/src/routes/page_content_routes.py +++ b/Backend/src/routes/page_content_routes.py @@ -1,14 +1,21 @@ -from fastapi import APIRouter, Depends, HTTPException, status +from fastapi import APIRouter, Depends, HTTPException, status, Request, UploadFile, File from sqlalchemy.orm import Session from typing import Optional from datetime import datetime +from pathlib import Path import json +import os +import aiofiles +import uuid from ..config.database import get_db +from ..config.logging_config import get_logger from ..middleware.auth import get_current_user, authorize_roles from ..models.user import User from ..models.page_content import PageContent, PageType +logger = get_logger(__name__) + router = APIRouter(prefix="/page-content", tags=["page-content"]) @@ -40,12 +47,60 @@ async def get_all_page_contents( "social_links": json.loads(content.social_links) if content.social_links else None, "footer_links": json.loads(content.footer_links) if content.footer_links else None, "badges": json.loads(content.badges) if content.badges else None, + "copyright_text": content.copyright_text, "hero_title": content.hero_title, "hero_subtitle": content.hero_subtitle, "hero_image": content.hero_image, "story_content": content.story_content, "values": json.loads(content.values) if content.values else None, "features": json.loads(content.features) if content.features else None, + "about_hero_image": content.about_hero_image, + "mission": content.mission, + "vision": content.vision, + "team": json.loads(content.team) if content.team else None, + "timeline": json.loads(content.timeline) if content.timeline else None, + "achievements": json.loads(content.achievements) if content.achievements else None, + "amenities_section_title": content.amenities_section_title, + "amenities_section_subtitle": content.amenities_section_subtitle, + "amenities": json.loads(content.amenities) if content.amenities else None, + "testimonials_section_title": content.testimonials_section_title, + "testimonials_section_subtitle": content.testimonials_section_subtitle, + "testimonials": json.loads(content.testimonials) if content.testimonials else None, + "gallery_section_title": content.gallery_section_title, + "gallery_section_subtitle": content.gallery_section_subtitle, + "gallery_images": json.loads(content.gallery_images) if content.gallery_images else None, + "luxury_section_title": content.luxury_section_title, + "luxury_section_subtitle": content.luxury_section_subtitle, + "luxury_section_image": content.luxury_section_image, + "luxury_features": json.loads(content.luxury_features) if content.luxury_features else None, + "luxury_gallery_section_title": content.luxury_gallery_section_title, + "luxury_gallery_section_subtitle": content.luxury_gallery_section_subtitle, + "luxury_gallery": json.loads(content.luxury_gallery) if content.luxury_gallery else None, + "luxury_testimonials_section_title": content.luxury_testimonials_section_title, + "luxury_testimonials_section_subtitle": content.luxury_testimonials_section_subtitle, + "luxury_testimonials": json.loads(content.luxury_testimonials) if content.luxury_testimonials else None, + "about_preview_title": content.about_preview_title, + "about_preview_subtitle": content.about_preview_subtitle, + "about_preview_content": content.about_preview_content, + "about_preview_image": content.about_preview_image, + "stats": json.loads(content.stats) if content.stats else None, + "luxury_services_section_title": content.luxury_services_section_title, + "luxury_services_section_subtitle": content.luxury_services_section_subtitle, + "luxury_services": json.loads(content.luxury_services) if content.luxury_services else None, + "luxury_experiences_section_title": content.luxury_experiences_section_title, + "luxury_experiences_section_subtitle": content.luxury_experiences_section_subtitle, + "luxury_experiences": json.loads(content.luxury_experiences) if content.luxury_experiences else None, + "awards_section_title": content.awards_section_title, + "awards_section_subtitle": content.awards_section_subtitle, + "awards": json.loads(content.awards) if content.awards else None, + "cta_title": content.cta_title, + "cta_subtitle": content.cta_subtitle, + "cta_button_text": content.cta_button_text, + "cta_button_link": content.cta_button_link, + "cta_image": content.cta_image, + "partners_section_title": content.partners_section_title, + "partners_section_subtitle": content.partners_section_subtitle, + "partners": json.loads(content.partners) if content.partners else None, "is_active": content.is_active, "created_at": content.created_at.isoformat() if content.created_at else None, "updated_at": content.updated_at.isoformat() if content.updated_at else None, @@ -65,6 +120,104 @@ async def get_all_page_contents( ) +def get_base_url(request: Request) -> str: + """Get base URL for image normalization""" + return os.getenv("SERVER_URL") or f"http://{request.headers.get('host', 'localhost:8000')}" + + +def normalize_image_url(image_url: str, base_url: str) -> str: + """Normalize image URL to absolute URL""" + if not image_url: + return image_url + if image_url.startswith('http://') or image_url.startswith('https://'): + return image_url + if image_url.startswith('/'): + return f"{base_url}{image_url}" + return f"{base_url}/{image_url}" + + +@router.post("/upload", dependencies=[Depends(authorize_roles("admin"))]) +async def upload_page_content_image( + request: Request, + image: UploadFile = File(...), + current_user: User = Depends(authorize_roles("admin")), +): + """Upload page content image (Admin only)""" + try: + logger.info(f"Upload request received: filename={image.filename}, content_type={image.content_type}") + + # Validate file exists + if not image: + logger.error("No file provided in upload request") + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail="No file provided" + ) + + # Validate file type + if not image.content_type or not image.content_type.startswith('image/'): + logger.error(f"Invalid file type: {image.content_type}") + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=f"File must be an image. Received: {image.content_type}" + ) + + # Validate filename + if not image.filename: + logger.error("No filename provided in upload request") + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail="Filename is required" + ) + + # Create uploads directory + upload_dir = Path(__file__).parent.parent.parent / "uploads" / "page-content" + upload_dir.mkdir(parents=True, exist_ok=True) + logger.info(f"Upload directory: {upload_dir}") + + # Generate filename + ext = Path(image.filename).suffix or '.jpg' + filename = f"page-content-{uuid.uuid4()}{ext}" + file_path = upload_dir / filename + + # Save file + async with aiofiles.open(file_path, 'wb') as f: + content = await image.read() + if not content: + logger.error("Empty file uploaded") + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail="File is empty" + ) + await f.write(content) + logger.info(f"File saved successfully: {file_path}, size: {len(content)} bytes") + + # Return the image URL + image_url = f"/uploads/page-content/{filename}" + base_url = get_base_url(request) + full_url = normalize_image_url(image_url, base_url) + + logger.info(f"Upload successful: {image_url}") + return { + "success": True, + "status": "success", + "message": "Image uploaded successfully", + "data": { + "image_url": image_url, + "full_url": full_url + } + } + except HTTPException as e: + logger.error(f"HTTPException in upload: {e.detail}") + raise + except Exception as e: + logger.error(f"Unexpected error uploading image: {str(e)}", exc_info=True) + raise HTTPException( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + detail=f"Error uploading image: {str(e)}" + ) + + @router.get("/{page_type}") async def get_page_content( page_type: PageType, @@ -102,12 +255,60 @@ async def get_page_content( "social_links": json.loads(content.social_links) if content.social_links else None, "footer_links": json.loads(content.footer_links) if content.footer_links else None, "badges": json.loads(content.badges) if content.badges else None, + "copyright_text": content.copyright_text, "hero_title": content.hero_title, "hero_subtitle": content.hero_subtitle, "hero_image": content.hero_image, "story_content": content.story_content, "values": json.loads(content.values) if content.values else None, "features": json.loads(content.features) if content.features else None, + "about_hero_image": content.about_hero_image, + "mission": content.mission, + "vision": content.vision, + "team": json.loads(content.team) if content.team else None, + "timeline": json.loads(content.timeline) if content.timeline else None, + "achievements": json.loads(content.achievements) if content.achievements else None, + "amenities_section_title": content.amenities_section_title, + "amenities_section_subtitle": content.amenities_section_subtitle, + "amenities": json.loads(content.amenities) if content.amenities else None, + "testimonials_section_title": content.testimonials_section_title, + "testimonials_section_subtitle": content.testimonials_section_subtitle, + "testimonials": json.loads(content.testimonials) if content.testimonials else None, + "gallery_section_title": content.gallery_section_title, + "gallery_section_subtitle": content.gallery_section_subtitle, + "gallery_images": json.loads(content.gallery_images) if content.gallery_images else None, + "luxury_section_title": content.luxury_section_title, + "luxury_section_subtitle": content.luxury_section_subtitle, + "luxury_section_image": content.luxury_section_image, + "luxury_features": json.loads(content.luxury_features) if content.luxury_features else None, + "luxury_gallery_section_title": content.luxury_gallery_section_title, + "luxury_gallery_section_subtitle": content.luxury_gallery_section_subtitle, + "luxury_gallery": json.loads(content.luxury_gallery) if content.luxury_gallery else None, + "luxury_testimonials_section_title": content.luxury_testimonials_section_title, + "luxury_testimonials_section_subtitle": content.luxury_testimonials_section_subtitle, + "luxury_testimonials": json.loads(content.luxury_testimonials) if content.luxury_testimonials else None, + "about_preview_title": content.about_preview_title, + "about_preview_subtitle": content.about_preview_subtitle, + "about_preview_content": content.about_preview_content, + "about_preview_image": content.about_preview_image, + "stats": json.loads(content.stats) if content.stats else None, + "luxury_services_section_title": content.luxury_services_section_title, + "luxury_services_section_subtitle": content.luxury_services_section_subtitle, + "luxury_services": json.loads(content.luxury_services) if content.luxury_services else None, + "luxury_experiences_section_title": content.luxury_experiences_section_title, + "luxury_experiences_section_subtitle": content.luxury_experiences_section_subtitle, + "luxury_experiences": json.loads(content.luxury_experiences) if content.luxury_experiences else None, + "awards_section_title": content.awards_section_title, + "awards_section_subtitle": content.awards_section_subtitle, + "awards": json.loads(content.awards) if content.awards else None, + "cta_title": content.cta_title, + "cta_subtitle": content.cta_subtitle, + "cta_button_text": content.cta_button_text, + "cta_button_link": content.cta_button_link, + "cta_image": content.cta_image, + "partners_section_title": content.partners_section_title, + "partners_section_subtitle": content.partners_section_subtitle, + "partners": json.loads(content.partners) if content.partners else None, "is_active": content.is_active, "created_at": content.created_at.isoformat() if content.created_at else None, "updated_at": content.updated_at.isoformat() if content.updated_at else None, @@ -151,6 +352,12 @@ async def create_or_update_page_content( story_content: Optional[str] = None, values: Optional[str] = None, features: Optional[str] = None, + about_hero_image: Optional[str] = None, + mission: Optional[str] = None, + vision: Optional[str] = None, + team: Optional[str] = None, + timeline: Optional[str] = None, + achievements: Optional[str] = None, is_active: bool = True, current_user: User = Depends(get_current_user), db: Session = Depends(get_db) @@ -263,6 +470,18 @@ async def create_or_update_page_content( existing_content.values = values if features is not None: existing_content.features = features + if about_hero_image is not None: + existing_content.about_hero_image = about_hero_image + if mission is not None: + existing_content.mission = mission + if vision is not None: + existing_content.vision = vision + if team is not None: + existing_content.team = team + if timeline is not None: + existing_content.timeline = timeline + if achievements is not None: + existing_content.achievements = achievements if is_active is not None: existing_content.is_active = is_active @@ -308,6 +527,12 @@ async def create_or_update_page_content( story_content=story_content, values=values, features=features, + about_hero_image=about_hero_image, + mission=mission, + vision=vision, + team=team, + timeline=timeline, + achievements=achievements, is_active=is_active, ) @@ -362,7 +587,10 @@ async def update_page_content( for key, value in page_data.items(): if hasattr(existing_content, key): # Handle JSON fields - convert dict/list to JSON string - if key in ["contact_info", "social_links", "footer_links", "badges", "values", "features"] and value is not None: + if key in ["contact_info", "social_links", "footer_links", "badges", "values", "features", + "amenities", "testimonials", "gallery_images", "stats", "luxury_features", + "luxury_gallery", "luxury_testimonials", "luxury_services", "luxury_experiences", + "awards", "partners", "team", "timeline", "achievements"] and value is not None: if isinstance(value, str): # Already a string, validate it's valid JSON try: @@ -403,12 +631,60 @@ async def update_page_content( "social_links": json.loads(existing_content.social_links) if existing_content.social_links else None, "footer_links": json.loads(existing_content.footer_links) if existing_content.footer_links else None, "badges": json.loads(existing_content.badges) if existing_content.badges else None, + "copyright_text": existing_content.copyright_text, "hero_title": existing_content.hero_title, "hero_subtitle": existing_content.hero_subtitle, "hero_image": existing_content.hero_image, "story_content": existing_content.story_content, "values": json.loads(existing_content.values) if existing_content.values else None, "features": json.loads(existing_content.features) if existing_content.features else None, + "about_hero_image": existing_content.about_hero_image, + "mission": existing_content.mission, + "vision": existing_content.vision, + "team": json.loads(existing_content.team) if existing_content.team else None, + "timeline": json.loads(existing_content.timeline) if existing_content.timeline else None, + "achievements": json.loads(existing_content.achievements) if existing_content.achievements else None, + "amenities_section_title": existing_content.amenities_section_title, + "amenities_section_subtitle": existing_content.amenities_section_subtitle, + "amenities": json.loads(existing_content.amenities) if existing_content.amenities else None, + "testimonials_section_title": existing_content.testimonials_section_title, + "testimonials_section_subtitle": existing_content.testimonials_section_subtitle, + "testimonials": json.loads(existing_content.testimonials) if existing_content.testimonials else None, + "gallery_section_title": existing_content.gallery_section_title, + "gallery_section_subtitle": existing_content.gallery_section_subtitle, + "gallery_images": json.loads(existing_content.gallery_images) if existing_content.gallery_images else None, + "luxury_section_title": existing_content.luxury_section_title, + "luxury_section_subtitle": existing_content.luxury_section_subtitle, + "luxury_section_image": existing_content.luxury_section_image, + "luxury_features": json.loads(existing_content.luxury_features) if existing_content.luxury_features else None, + "luxury_gallery_section_title": existing_content.luxury_gallery_section_title, + "luxury_gallery_section_subtitle": existing_content.luxury_gallery_section_subtitle, + "luxury_gallery": json.loads(existing_content.luxury_gallery) if existing_content.luxury_gallery else None, + "luxury_testimonials_section_title": existing_content.luxury_testimonials_section_title, + "luxury_testimonials_section_subtitle": existing_content.luxury_testimonials_section_subtitle, + "luxury_testimonials": json.loads(existing_content.luxury_testimonials) if existing_content.luxury_testimonials else None, + "about_preview_title": existing_content.about_preview_title, + "about_preview_subtitle": existing_content.about_preview_subtitle, + "about_preview_content": existing_content.about_preview_content, + "about_preview_image": existing_content.about_preview_image, + "stats": json.loads(existing_content.stats) if existing_content.stats else None, + "luxury_services_section_title": existing_content.luxury_services_section_title, + "luxury_services_section_subtitle": existing_content.luxury_services_section_subtitle, + "luxury_services": json.loads(existing_content.luxury_services) if existing_content.luxury_services else None, + "luxury_experiences_section_title": existing_content.luxury_experiences_section_title, + "luxury_experiences_section_subtitle": existing_content.luxury_experiences_section_subtitle, + "luxury_experiences": json.loads(existing_content.luxury_experiences) if existing_content.luxury_experiences else None, + "awards_section_title": existing_content.awards_section_title, + "awards_section_subtitle": existing_content.awards_section_subtitle, + "awards": json.loads(existing_content.awards) if existing_content.awards else None, + "cta_title": existing_content.cta_title, + "cta_subtitle": existing_content.cta_subtitle, + "cta_button_text": existing_content.cta_button_text, + "cta_button_link": existing_content.cta_button_link, + "cta_image": existing_content.cta_image, + "partners_section_title": existing_content.partners_section_title, + "partners_section_subtitle": existing_content.partners_section_subtitle, + "partners": json.loads(existing_content.partners) if existing_content.partners else None, "is_active": existing_content.is_active, "updated_at": existing_content.updated_at.isoformat() if existing_content.updated_at else None, } diff --git a/Backend/src/routes/room_routes.py b/Backend/src/routes/room_routes.py index 7b07d220..d8a93732 100644 --- a/Backend/src/routes/room_routes.py +++ b/Backend/src/routes/room_routes.py @@ -694,18 +694,24 @@ async def upload_room_images( image_urls = [] for image in images: # Validate file type - if not image.content_type.startswith('image/'): + if not image.content_type or not image.content_type.startswith('image/'): + continue + + # Validate filename + if not image.filename: continue # Generate filename import uuid - ext = Path(image.filename).suffix + ext = Path(image.filename).suffix or '.jpg' filename = f"room-{uuid.uuid4()}{ext}" file_path = upload_dir / filename # Save file async with aiofiles.open(file_path, 'wb') as f: content = await image.read() + if not content: + continue await f.write(content) image_urls.append(f"/uploads/rooms/{filename}") @@ -717,6 +723,7 @@ async def upload_room_images( db.commit() return { + "success": True, "status": "success", "message": "Images uploaded successfully", "data": {"images": updated_images} diff --git a/Backend/src/routes/system_settings_routes.py b/Backend/src/routes/system_settings_routes.py index 2ee87661..bb87387b 100644 --- a/Backend/src/routes/system_settings_routes.py +++ b/Backend/src/routes/system_settings_routes.py @@ -1127,6 +1127,7 @@ async def upload_company_logo( full_url = normalize_image_url(image_url, base_url) return { + "success": True, "status": "success", "message": "Logo uploaded successfully", "data": { @@ -1235,6 +1236,7 @@ async def upload_company_favicon( full_url = normalize_image_url(image_url, base_url) return { + "success": True, "status": "success", "message": "Favicon uploaded successfully", "data": { diff --git a/Backend/src/services/__pycache__/auth_service.cpython-312.pyc b/Backend/src/services/__pycache__/auth_service.cpython-312.pyc index c4839a65..723a4c40 100644 Binary files a/Backend/src/services/__pycache__/auth_service.cpython-312.pyc and b/Backend/src/services/__pycache__/auth_service.cpython-312.pyc differ diff --git a/Backend/src/services/__pycache__/invoice_service.cpython-312.pyc b/Backend/src/services/__pycache__/invoice_service.cpython-312.pyc index cc230db6..f1042965 100644 Binary files a/Backend/src/services/__pycache__/invoice_service.cpython-312.pyc and b/Backend/src/services/__pycache__/invoice_service.cpython-312.pyc differ diff --git a/Backend/src/services/__pycache__/paypal_service.cpython-312.pyc b/Backend/src/services/__pycache__/paypal_service.cpython-312.pyc index d222bf0b..9d2b7f13 100644 Binary files a/Backend/src/services/__pycache__/paypal_service.cpython-312.pyc and b/Backend/src/services/__pycache__/paypal_service.cpython-312.pyc differ diff --git a/Backend/src/services/__pycache__/stripe_service.cpython-312.pyc b/Backend/src/services/__pycache__/stripe_service.cpython-312.pyc index 015ef5b6..f1cf0ccc 100644 Binary files a/Backend/src/services/__pycache__/stripe_service.cpython-312.pyc and b/Backend/src/services/__pycache__/stripe_service.cpython-312.pyc differ diff --git a/Backend/src/services/auth_service.py b/Backend/src/services/auth_service.py index 5fa6b266..f8fc7cf0 100644 --- a/Backend/src/services/auth_service.py +++ b/Backend/src/services/auth_service.py @@ -146,16 +146,28 @@ class AuthService: async def login(self, db: Session, email: str, password: str, remember_me: bool = False, mfa_token: str = None) -> dict: """Login user with optional MFA verification""" + # Normalize email (lowercase and strip whitespace) + email = email.lower().strip() if email else "" + if not email: + raise ValueError("Invalid email or password") + # Find user with role and password user = db.query(User).filter(User.email == email).first() if not user: + logger.warning(f"Login attempt with non-existent email: {email}") raise ValueError("Invalid email or password") + # Check if user is active + if not user.is_active: + logger.warning(f"Login attempt for inactive user: {email}") + raise ValueError("Account is disabled. Please contact support.") + # Load role user.role = db.query(Role).filter(Role.id == user.role_id).first() # Check password if not self.verify_password(password, user.password): + logger.warning(f"Login attempt with invalid password for user: {email}") raise ValueError("Invalid email or password") # Check if MFA is enabled diff --git a/Backend/src/services/invoice_service.py b/Backend/src/services/invoice_service.py index 00a192a8..73fe769e 100644 --- a/Backend/src/services/invoice_service.py +++ b/Backend/src/services/invoice_service.py @@ -87,10 +87,20 @@ class InvoiceService: # Calculate amounts - subtotal will be recalculated after adding items # Initial subtotal is booking total (room + services) or invoice_amount if specified + booking_total = float(booking.total_price) if invoice_amount is not None: subtotal = float(invoice_amount) + # For partial invoices, ensure discount is proportional + # If discount_amount seems too large (greater than subtotal), recalculate proportionally + if invoice_amount < booking_total and discount_amount > 0: + # Check if discount seems disproportionate (greater than 50% of subtotal suggests it's the full discount) + if discount_amount > subtotal * 0.5: + # Recalculate proportionally from booking's original discount + proportion = float(invoice_amount) / booking_total + original_discount = float(booking.discount_amount) if booking.discount_amount else discount_amount + discount_amount = original_discount * proportion else: - subtotal = float(booking.total_price) + subtotal = booking_total # Calculate tax and total amounts tax_amount = (subtotal - discount_amount) * (tax_rate / 100) @@ -388,6 +398,14 @@ class InvoiceService: @staticmethod def invoice_to_dict(invoice: Invoice) -> Dict[str, Any]: """Convert invoice model to dictionary""" + # Extract promotion code from notes if present + promotion_code = None + if invoice.notes and "Promotion Code:" in invoice.notes: + try: + promotion_code = invoice.notes.split("Promotion Code:")[1].split("\n")[0].strip() + except: + pass + return { "id": invoice.id, "invoice_number": invoice.invoice_number, @@ -419,6 +437,7 @@ class InvoiceService: "terms_and_conditions": invoice.terms_and_conditions, "payment_instructions": invoice.payment_instructions, "is_proforma": invoice.is_proforma if hasattr(invoice, 'is_proforma') else False, + "promotion_code": promotion_code, "items": [ { "id": item.id, diff --git a/Backend/src/services/paypal_service.py b/Backend/src/services/paypal_service.py index d613741b..24c62f79 100644 --- a/Backend/src/services/paypal_service.py +++ b/Backend/src/services/paypal_service.py @@ -505,10 +505,36 @@ class PayPalService: except Exception as email_error: logger.error(f"Failed to send booking confirmation email: {str(email_error)}") + # Send invoice email if payment is completed and invoice is now paid + from ..utils.mailer import send_email + from ..services.invoice_service import InvoiceService + from ..routes.booking_routes import _generate_invoice_email_html + + # Load user for email + from ..models.user import User + user = db.query(User).filter(User.id == booking.user_id).first() + + for invoice in invoices: + if invoice.status == InvoiceStatus.paid and invoice.balance_due <= 0: + try: + invoice_dict = InvoiceService.invoice_to_dict(invoice) + invoice_html = _generate_invoice_email_html(invoice_dict, is_proforma=invoice.is_proforma) + invoice_type = "Proforma Invoice" if invoice.is_proforma else "Invoice" + if user: + await send_email( + to=user.email, + subject=f"{invoice_type} {invoice.invoice_number} - Payment Confirmed", + html=invoice_html + ) + logger.info(f"{invoice_type} {invoice.invoice_number} sent to {user.email}") + except Exception as email_error: + logger.error(f"Failed to send invoice email: {str(email_error)}") + # Send invoice email if payment is completed and invoice is now paid from ..utils.mailer import send_email from ..services.invoice_service import InvoiceService from ..models.invoice import InvoiceStatus + from ..routes.booking_routes import _generate_invoice_email_html # Load user for email from ..models.user import User diff --git a/Backend/src/services/stripe_service.py b/Backend/src/services/stripe_service.py index b63fa304..fd94ea8e 100644 --- a/Backend/src/services/stripe_service.py +++ b/Backend/src/services/stripe_service.py @@ -404,6 +404,7 @@ class StripeService: # Send invoice email if payment is completed and invoice is now paid from ..utils.mailer import send_email from ..services.invoice_service import InvoiceService + from ..routes.booking_routes import _generate_invoice_email_html # Load user for email from ..models.user import User diff --git a/Frontend/src/App.tsx b/Frontend/src/App.tsx index 90398ab3..cd843de1 100644 --- a/Frontend/src/App.tsx +++ b/Frontend/src/App.tsx @@ -58,6 +58,8 @@ const ResetPasswordPage = lazy(() => import('./pages/auth/ResetPasswordPage')); // Lazy load admin pages const AdminDashboardPage = lazy(() => import('./pages/admin/DashboardPage')); +const InvoiceManagementPage = lazy(() => import('./pages/admin/InvoiceManagementPage')); +const PaymentManagementPage = lazy(() => import('./pages/admin/PaymentManagementPage')); const UserManagementPage = lazy(() => import('./pages/admin/UserManagementPage')); const PageContentDashboardPage = lazy(() => import('./pages/admin/PageContentDashboard')); const AnalyticsDashboardPage = lazy(() => import('./pages/admin/AnalyticsDashboardPage')); @@ -321,6 +323,18 @@ function App() { path="settings" element={} /> + } + /> + } + /> + } + /> {/* 404 Route */} diff --git a/Frontend/src/components/admin/IconPicker.tsx b/Frontend/src/components/admin/IconPicker.tsx new file mode 100644 index 00000000..88d720cd --- /dev/null +++ b/Frontend/src/components/admin/IconPicker.tsx @@ -0,0 +1,225 @@ +import React, { useState, useMemo } from 'react'; +import * as LucideIcons from 'lucide-react'; +import { Search, X } from 'lucide-react'; + +// Popular icons for hotel/luxury content +const popularIcons = [ + 'Sparkles', 'Star', 'Award', 'Shield', 'Heart', 'Crown', 'Gem', + 'Zap', 'Wifi', 'Coffee', 'Utensils', 'Bed', 'Home', 'MapPin', + 'Phone', 'Mail', 'Calendar', 'Clock', 'Users', 'UserCheck', + 'Car', 'Plane', 'Ship', 'Train', 'Bike', 'Umbrella', 'Sun', + 'Moon', 'Cloud', 'Droplet', 'Flame', 'TreePine', 'Mountain', + 'Palette', 'Music', 'Camera', 'Video', 'Gamepad2', 'Book', + 'Briefcase', 'ShoppingBag', 'Gift', 'Trophy', 'Medal', 'Ribbon', + 'CheckCircle', 'XCircle', 'AlertCircle', 'Info', 'HelpCircle', + 'Lock', 'Key', 'Eye', 'EyeOff', 'Bell', 'Settings', 'Menu', + 'Grid', 'List', 'Layout', 'Maximize', 'Minimize', 'ArrowRight', + 'ArrowLeft', 'ArrowUp', 'ArrowDown', 'ChevronRight', 'ChevronLeft', + 'ChevronUp', 'ChevronDown', 'Plus', 'Minus', 'X', 'Check', + 'Trash2', 'Edit', 'Save', 'Download', 'Upload', 'Share', + 'Copy', 'Scissors', 'FileText', 'Image', 'Film', 'Headphones', + 'Mic', 'Radio', 'Tv', 'Monitor', 'Laptop', 'Smartphone', + 'Tablet', 'Watch', 'Printer', 'HardDrive', 'Database', 'Server', + 'Cloud', 'Globe', 'Compass', 'Navigation', 'Map', 'Route', + 'Building', 'Building2', 'Hotel', 'Home', 'Store', 'ShoppingCart', + 'CreditCard', 'DollarSign', 'Euro', 'PoundSterling', 'Yen', + 'Bitcoin', 'TrendingUp', 'TrendingDown', 'BarChart', 'LineChart', + 'PieChart', 'Activity', 'Target', 'Flag', 'Tag', 'Bookmark', + 'Folder', 'File', 'Archive', 'Inbox', 'Send', 'Inbox', + 'MessageSquare', 'MessageCircle', 'MessageCircleMore', 'PhoneCall', + 'Video', 'Voicemail', 'AtSign', 'Hash', 'Link', 'ExternalLink', + 'Unlink', 'Code', 'Terminal', 'Command', 'Slash', 'Brackets', + 'Braces', 'Parentheses', 'Percent', 'Infinity', 'Pi', 'Sigma', + 'Omega', 'Alpha', 'Beta', 'Gamma', 'Delta', 'Theta', 'Lambda', + 'Mu', 'Nu', 'Xi', 'Omicron', 'Rho', 'Tau', 'Upsilon', 'Phi', + 'Chi', 'Psi' +]; + +interface IconPickerProps { + value?: string; + onChange: (iconName: string) => void; + label?: string; +} + +const IconPicker: React.FC = ({ value, onChange, label = 'Icon' }) => { + const [isOpen, setIsOpen] = useState(false); + const [searchQuery, setSearchQuery] = useState(''); + + // Get all available Lucide icons + const allIcons = useMemo(() => { + const icons: string[] = []; + const excludedNames = new Set([ + 'createLucideIcon', + 'Icon', + 'default', + 'lucideReact', + 'lucide', + 'createElement', + 'Fragment', + 'forwardRef', + 'memo' + ]); + + for (const iconName in LucideIcons) { + // Skip non-icon exports + if ( + excludedNames.has(iconName) || + iconName.startsWith('_') || + iconName[0] !== iconName[0].toUpperCase() // Lucide icons start with uppercase + ) { + continue; + } + + const iconComponent = (LucideIcons as any)[iconName]; + // Check if it's a React component (function) + if (typeof iconComponent === 'function') { + icons.push(iconName); + } + } + + const sorted = icons.sort(); + return sorted; + }, []); + + // Filter icons based on search + const filteredIcons = useMemo(() => { + if (!searchQuery.trim()) { + // Show popular icons first, then others + const popular = popularIcons.filter(icon => allIcons.includes(icon)); + const others = allIcons.filter(icon => !popularIcons.includes(icon)); + return [...popular, ...others]; + } + return allIcons.filter((icon) => + icon.toLowerCase().includes(searchQuery.toLowerCase()) + ); + }, [searchQuery, allIcons]); + + const selectedIcon = value && (LucideIcons as any)[value] ? (LucideIcons as any)[value] : null; + + const handleIconSelect = (iconName: string) => { + onChange(iconName); + setIsOpen(false); + setSearchQuery(''); + }; + + return ( +
+ + + + {isOpen && ( + <> +
setIsOpen(false)} + /> +
+
+
+ + setSearchQuery(e.target.value)} + placeholder="Search icons..." + className="w-full pl-10 pr-4 py-2 border-2 border-gray-200 rounded-lg focus:border-purple-400 focus:ring-4 focus:ring-purple-100 outline-none" + autoFocus + /> + {searchQuery && ( + + )} +
+
+
+ {filteredIcons.length > 0 ? ( + <> + {!searchQuery.trim() && ( +
+

+ Showing {filteredIcons.length} icons. Popular icons appear first. +

+
+ )} +
+ {filteredIcons.slice(0, searchQuery.trim() ? 500 : 300).map((iconName) => { + const IconComponent = (LucideIcons as any)[iconName]; + if (!IconComponent) return null; + + const isSelected = value === iconName; + const isPopular = !searchQuery.trim() && popularIcons.includes(iconName); + + try { + return ( + + ); + } catch (error) { + console.warn(`Failed to render icon: ${iconName}`, error); + return null; + } + })} +
+ {filteredIcons.length > (searchQuery.trim() ? 500 : 300) && ( +
+ Showing first {searchQuery.trim() ? 500 : 300} of {filteredIcons.length} icons. {!searchQuery.trim() && 'Use search to find more.'} +
+ )} + + ) : ( +
+

No icons found matching "{searchQuery}"

+

Try a different search term

+
+ )} +
+
+ + )} +
+ ); +}; + +export default IconPicker; + diff --git a/Frontend/src/components/layout/Footer.tsx b/Frontend/src/components/layout/Footer.tsx index 5f098593..51a18886 100644 --- a/Frontend/src/components/layout/Footer.tsx +++ b/Frontend/src/components/layout/Footer.tsx @@ -37,7 +37,7 @@ const Footer: React.FC = () => { useEffect(() => { const fetchPageContent = async () => { try { - const response = await pageContentService.getPageContent('footer'); + const response = await pageContentService.getFooterContent(); if (response.status === 'success' && response.data?.page_content) { setPageContent(response.data.page_content); } @@ -344,7 +344,12 @@ const Footer: React.FC = () => { {/* Copyright - Enhanced */}
- © {new Date().getFullYear()} Luxury Hotel. All rights reserved. + {(() => { + const currentYear = new Date().getFullYear(); + const copyrightText = pageContent?.copyright_text || '© {YEAR} Luxury Hotel. All rights reserved.'; + // Replace {YEAR} placeholder with current year + return copyrightText.replace(/{YEAR}/g, currentYear.toString()); + })()}
Privacy diff --git a/Frontend/src/components/rooms/BannerCarousel.tsx b/Frontend/src/components/rooms/BannerCarousel.tsx index 4b09199f..1c2b8995 100644 --- a/Frontend/src/components/rooms/BannerCarousel.tsx +++ b/Frontend/src/components/rooms/BannerCarousel.tsx @@ -82,11 +82,11 @@ const BannerCarousel: React.FC = ({ index === currentIndex ? 'opacity-100 z-0 pointer-events-auto' : 'opacity-0 z-0 pointer-events-none' }`} > - {banner.link ? ( + {banner.link_url ? ( = ({ }} /> - {/* Title - Positioned at top when search form is present */} + {/* Title - Positioned higher up on the banner */} {currentBanner.title && (
= ({ - {/* Animated decorative line below title */} + {/* Description text - centered below title */} + {currentBanner.description && ( +

+ {currentBanner.description} +

+ )} + + {/* Animated decorative line below title/description */}
diff --git a/Frontend/src/data/luxuryContentSeed.ts b/Frontend/src/data/luxuryContentSeed.ts new file mode 100644 index 00000000..efcda53c --- /dev/null +++ b/Frontend/src/data/luxuryContentSeed.ts @@ -0,0 +1,65 @@ +// Seed data for luxury hotel content +export const luxuryContentSeed = { + home: { + luxury_section_title: 'Experience Unparalleled Luxury', + luxury_section_subtitle: 'Where elegance meets comfort in every detail', + luxury_section_image: '', + luxury_features: [ + { + icon: 'Sparkles', + title: 'Premium Amenities', + description: 'World-class facilities designed for your comfort and relaxation' + }, + { + icon: 'Crown', + title: 'Royal Service', + description: 'Dedicated concierge service available 24/7 for all your needs' + }, + { + icon: 'Award', + title: 'Award-Winning', + description: 'Recognized for excellence in hospitality and guest satisfaction' + }, + { + icon: 'Shield', + title: 'Secure & Private', + description: 'Your privacy and security are our top priorities' + }, + { + icon: 'Heart', + title: 'Personalized Care', + description: 'Tailored experiences crafted just for you' + }, + { + icon: 'Gem', + title: 'Luxury Design', + description: 'Elegantly designed spaces with attention to every detail' + } + ], + luxury_gallery: [], + luxury_testimonials: [ + { + name: 'Sarah Johnson', + title: 'Business Executive', + quote: 'An absolutely stunning experience. The attention to detail and level of service exceeded all expectations.', + image: '' + }, + { + name: 'Michael Chen', + title: 'Travel Enthusiast', + quote: 'The epitome of luxury. Every moment was perfect, from check-in to check-out.', + image: '' + }, + { + name: 'Emma Williams', + title: 'Luxury Traveler', + quote: 'This hotel redefines what luxury means. I will definitely return.', + image: '' + } + ], + about_preview_title: 'About Our Luxury Hotel', + about_preview_content: 'Discover a world of refined elegance and exceptional service. Our hotel combines timeless luxury with modern amenities to create an unforgettable experience.', + about_preview_image: '' + } +}; + diff --git a/Frontend/src/pages/AboutPage.tsx b/Frontend/src/pages/AboutPage.tsx index 661ebae6..4e880692 100644 --- a/Frontend/src/pages/AboutPage.tsx +++ b/Frontend/src/pages/AboutPage.tsx @@ -1,16 +1,14 @@ import React, { useState, useEffect } from 'react'; import { Hotel, - Award, - Users, Heart, MapPin, Phone, Mail, - Star, - Shield, - Clock + Linkedin, + Twitter } from 'lucide-react'; +import * as LucideIcons from 'lucide-react'; import { Link } from 'react-router-dom'; import { pageContentService } from '../services/api'; import type { PageContent } from '../services/api/pageContentService'; @@ -23,7 +21,7 @@ const AboutPage: React.FC = () => { useEffect(() => { const fetchPageContent = async () => { try { - const response = await pageContentService.getPageContent('about'); + const response = await pageContentService.getAboutContent(); if (response.status === 'success' && response.data?.page_content) { setPageContent(response.data.page_content); @@ -58,22 +56,22 @@ const AboutPage: React.FC = () => { // Default values const defaultValues = [ { - icon: Heart, + icon: 'Heart', title: 'Passion', description: 'We are passionate about hospitality and dedicated to creating exceptional experiences for every guest.' }, { - icon: Award, + icon: 'Award', title: 'Excellence', description: 'We strive for excellence in every aspect of our service, from the smallest detail to the grandest gesture.' }, { - icon: Shield, + icon: 'Shield', title: 'Integrity', description: 'We conduct our business with honesty, transparency, and respect for our guests and community.' }, { - icon: Users, + icon: 'Users', title: 'Service', description: 'Our guests are at the heart of everything we do. Your comfort and satisfaction are our top priorities.' } @@ -81,17 +79,17 @@ const AboutPage: React.FC = () => { const defaultFeatures = [ { - icon: Star, + icon: 'Star', title: 'Premium Accommodations', description: 'Luxuriously appointed rooms and suites designed for ultimate comfort and relaxation.' }, { - icon: Clock, + icon: 'Clock', title: '24/7 Service', description: 'Round-the-clock concierge and room service to attend to your needs at any time.' }, { - icon: Award, + icon: 'Award', title: 'Award-Winning', description: 'Recognized for excellence in hospitality and guest satisfaction.' } @@ -99,7 +97,7 @@ const AboutPage: React.FC = () => { const values = pageContent?.values && pageContent.values.length > 0 ? pageContent.values.map((v: any) => ({ - icon: defaultValues.find(d => d.title === v.title)?.icon || Heart, + icon: v.icon || defaultValues.find(d => d.title === v.title)?.icon || 'Heart', title: v.title, description: v.description })) @@ -107,60 +105,122 @@ const AboutPage: React.FC = () => { const features = pageContent?.features && pageContent.features.length > 0 ? pageContent.features.map((f: any) => ({ - icon: defaultFeatures.find(d => d.title === f.title)?.icon || Star, + icon: f.icon || defaultFeatures.find(d => d.title === f.title)?.icon || 'Star', title: f.title, description: f.description })) : defaultFeatures; + // Parse JSON fields + const team = pageContent?.team && typeof pageContent.team === 'string' + ? JSON.parse(pageContent.team) + : (Array.isArray(pageContent?.team) ? pageContent.team : []); + const timeline = pageContent?.timeline && typeof pageContent.timeline === 'string' + ? JSON.parse(pageContent.timeline) + : (Array.isArray(pageContent?.timeline) ? pageContent.timeline : []); + const achievements = pageContent?.achievements && typeof pageContent.achievements === 'string' + ? JSON.parse(pageContent.achievements) + : (Array.isArray(pageContent?.achievements) ? pageContent.achievements : []); + + // Helper to get icon component + const getIconComponent = (iconName?: string) => { + if (!iconName) return Heart; + const IconComponent = (LucideIcons as any)[iconName] || Heart; + return IconComponent; + }; + return ( -
+
{/* Hero Section */} -
-
-
-
-
-
- +
+ {pageContent?.about_hero_image && ( +
+ About Hero +
+
+
+ )} + {!pageContent?.about_hero_image && ( +
+
+
+
+ )} +
+
+ {!pageContent?.about_hero_image && ( +
+
+
+
+ +
+
+
+ )} +
+
+
-

- {pageContent?.title || 'About Luxury Hotel'} +

+ + {pageContent?.title || 'About Luxury Hotel'} +

-

+

{pageContent?.subtitle || pageContent?.description || 'Where Excellence Meets Unforgettable Experiences'}

+
+
+
+
+
{/* Our Story Section */} -
-
-
-
-

+
+
+
+
+
+
+ Our Heritage +
+

Our Story

-
+
+
+
+
+
-
+
{pageContent?.story_content ? ( -
') }} /> +
') }} + /> ) : ( <> -

+

Welcome to Luxury Hotel, where timeless elegance meets modern sophistication. Since our founding, we have been dedicated to providing exceptional hospitality and creating unforgettable memories for our guests.

-

+

Nestled in the heart of the city, our hotel combines classic architecture with contemporary amenities, offering a perfect blend of comfort and luxury. Every detail has been carefully curated to ensure your stay exceeds expectations.

-

+

Our commitment to excellence extends beyond our beautiful rooms and facilities. We believe in creating meaningful connections with our guests, understanding their needs, and delivering personalized service that makes each visit special. @@ -170,34 +230,49 @@ const AboutPage: React.FC = () => {

+
{/* Values Section */} -
-
-
-
-

+
+
+
+
+
+
+ Core Principles +
+

Our Values

-
+
+
+
+
+
-
+
{values.map((value, index) => (
-
- +
+
+
+ {(() => { + const ValueIcon = getIconComponent(value.icon); + return ; + })()} +
+

+ {value.title} +

+

+ {value.description} +

-

- {value.title} -

-

- {value.description} -

))}
@@ -206,60 +281,303 @@ const AboutPage: React.FC = () => {
{/* Features Section */} -
-
-
-
-

+
+
+
+
+
+
+ Excellence Defined +
+

Why Choose Us

-
+
+
+
+
+
-
- {features.map((feature, index) => ( -
-
- +
+ {features.map((feature, index) => { + const FeatureIcon = getIconComponent(feature.icon); + return ( +
+
+
+
+ +
+

+ {feature.title} +

+

+ {feature.description} +

+
-

- {feature.title} -

-

- {feature.description} -

-
- ))} + ); + })}
+ {/* Mission & Vision Section */} + {(pageContent?.mission || pageContent?.vision) && ( +
+
+
+
+
+
+
+ {pageContent.mission && ( +
+
+
+
+
+

Our Mission

+
+

{pageContent.mission}

+
+
+ )} + {pageContent.vision && ( +
+
+
+
+
+

Our Vision

+
+

{pageContent.vision}

+
+
+ )} +
+
+
+ )} + + {/* Team Section */} + {team && team.length > 0 && ( +
+
+
+
+
+ Meet The Experts +
+

+ Our Team +

+
+
+
+
+
+
+
+ {team.map((member: any, index: number) => ( +
+
+ {member.image && ( +
+ {member.name} +
+
+ )} +
+

{member.name}

+

{member.role}

+ {member.bio &&

{member.bio}

} + {member.social_links && ( +
+ {member.social_links.linkedin && ( + + + + )} + {member.social_links.twitter && ( + + + + )} +
+ )} +
+
+ ))} +
+
+
+
+ )} + + {/* Timeline Section */} + {timeline && timeline.length > 0 && ( +
+
+
+
+
+
+ Our Journey +
+

+ Our History +

+
+
+
+
+
+
+
+
+
+ {timeline.map((event: any, index: number) => ( +
+
+
+
+
+
{event.year}
+
+
+

{event.title}

+

{event.description}

+ {event.image && ( +
+ {event.title} +
+ )} +
+
+
+ ))} +
+
+
+
+
+ )} + + {/* Achievements Section */} + {achievements && achievements.length > 0 && ( +
+
+
+
+
+
+ Recognition +
+

+ Achievements & Awards +

+
+
+
+
+
+
+
+ {achievements.map((achievement: any, index: number) => { + const AchievementIcon = getIconComponent(achievement.icon); + return ( +
+
+
+
+
+ +
+ {achievement.year && ( +
{achievement.year}
+ )} +
+

{achievement.title}

+

{achievement.description}

+ {achievement.image && ( +
+ {achievement.title} +
+ )} +
+
+ ); + })} +
+
+
+
+ )} + {/* Contact Section */} -
-
-
-
-

+
+
+
+
+
+
+ Connect With Us +
+

Get In Touch

-
-

+

+
+
+
+
+

We'd love to hear from you. Contact us for reservations or inquiries.

-
-
-
- +
+
+
+
-

+

Address

-

+

{displayAddress .split('\n').map((line, i) => ( @@ -269,40 +587,41 @@ const AboutPage: React.FC = () => { ))}

-
-
- +
+
+
-

+

Phone

-

- +

+ {displayPhone}

-
-
- +
+
+
-

+

Email

-

- +

+ {displayEmail}

-
+
- Explore Our Rooms - + Explore Our Rooms + +
diff --git a/Frontend/src/pages/ContactPage.tsx b/Frontend/src/pages/ContactPage.tsx index 32668000..619729da 100644 --- a/Frontend/src/pages/ContactPage.tsx +++ b/Frontend/src/pages/ContactPage.tsx @@ -99,7 +99,7 @@ const ContactPage: React.FC = () => { useEffect(() => { const fetchPageContent = async () => { try { - const response = await pageContentService.getPageContent('contact'); + const response = await pageContentService.getContactContent(); if (response.status === 'success' && response.data?.page_content) { setPageContent(response.data.page_content); diff --git a/Frontend/src/pages/HomePage.tsx b/Frontend/src/pages/HomePage.tsx index 723abf87..15ff2648 100644 --- a/Frontend/src/pages/HomePage.tsx +++ b/Frontend/src/pages/HomePage.tsx @@ -3,7 +3,13 @@ import { Link } from 'react-router-dom'; import { ArrowRight, AlertCircle, + Star, + X, + ChevronLeft, + ChevronRight, + ZoomIn, } from 'lucide-react'; +import * as LucideIcons from 'lucide-react'; import { BannerCarousel, BannerSkeleton, @@ -32,6 +38,33 @@ const HomePage: React.FC = () => { const [isLoadingNewest, setIsLoadingNewest] = useState(true); const [isLoadingContent, setIsLoadingContent] = useState(true); const [error, setError] = useState(null); + const [lightboxOpen, setLightboxOpen] = useState(false); + const [lightboxIndex, setLightboxIndex] = useState(0); + const [lightboxImages, setLightboxImages] = useState([]); + + // Handle keyboard navigation for lightbox + useEffect(() => { + if (!lightboxOpen) return; + + const handleKeyDown = (e: KeyboardEvent) => { + if (e.key === 'Escape') { + setLightboxOpen(false); + } else if (e.key === 'ArrowLeft' && lightboxImages.length > 1) { + setLightboxIndex((prev) => (prev === 0 ? lightboxImages.length - 1 : prev - 1)); + } else if (e.key === 'ArrowRight' && lightboxImages.length > 1) { + setLightboxIndex((prev) => (prev === lightboxImages.length - 1 ? 0 : prev + 1)); + } + }; + + window.addEventListener('keydown', handleKeyDown); + // Prevent body scroll when lightbox is open + document.body.style.overflow = 'hidden'; + + return () => { + window.removeEventListener('keydown', handleKeyDown); + document.body.style.overflow = 'unset'; + }; + }, [lightboxOpen, lightboxImages.length]); // Combine featured and newest rooms, removing duplicates const combinedRooms = useMemo(() => { @@ -57,22 +90,118 @@ const HomePage: React.FC = () => { const fetchPageContent = async () => { try { setIsLoadingContent(true); - const response = await pageContentService.getPageContent('home'); + const response = await pageContentService.getHomeContent(); if (response.status === 'success' && response.data?.page_content) { - setPageContent(response.data.page_content); + const content = response.data.page_content; + + // Parse JSON fields if they come as strings (backward compatibility) + if (typeof content.features === 'string') { + try { + content.features = JSON.parse(content.features); + } catch (e) { + content.features = []; + } + } + if (typeof content.amenities === 'string') { + try { + content.amenities = JSON.parse(content.amenities); + } catch (e) { + content.amenities = []; + } + } + if (typeof content.testimonials === 'string') { + try { + content.testimonials = JSON.parse(content.testimonials); + } catch (e) { + content.testimonials = []; + } + } + if (typeof content.gallery_images === 'string') { + try { + content.gallery_images = JSON.parse(content.gallery_images); + } catch (e) { + content.gallery_images = []; + } + } + if (typeof content.stats === 'string') { + try { + content.stats = JSON.parse(content.stats); + } catch (e) { + content.stats = []; + } + } + // Parse luxury fields + if (typeof content.luxury_features === 'string') { + try { + content.luxury_features = JSON.parse(content.luxury_features); + } catch (e) { + content.luxury_features = []; + } + } + if (typeof content.luxury_gallery === 'string') { + try { + const parsed = JSON.parse(content.luxury_gallery); + content.luxury_gallery = Array.isArray(parsed) ? parsed.filter(img => img && typeof img === 'string' && img.trim() !== '') : []; + } catch (e) { + content.luxury_gallery = []; + } + } + // Ensure luxury_gallery is an array and filter out empty values + if (Array.isArray(content.luxury_gallery)) { + content.luxury_gallery = content.luxury_gallery.filter(img => img && typeof img === 'string' && img.trim() !== ''); + } else { + content.luxury_gallery = []; + } + if (typeof content.luxury_testimonials === 'string') { + try { + content.luxury_testimonials = JSON.parse(content.luxury_testimonials); + } catch (e) { + content.luxury_testimonials = []; + } + } + if (typeof content.luxury_services === 'string') { + try { + content.luxury_services = JSON.parse(content.luxury_services); + } catch (e) { + content.luxury_services = []; + } + } + if (typeof content.luxury_experiences === 'string') { + try { + content.luxury_experiences = JSON.parse(content.luxury_experiences); + } catch (e) { + content.luxury_experiences = []; + } + } + if (typeof content.awards === 'string') { + try { + content.awards = JSON.parse(content.awards); + } catch (e) { + content.awards = []; + } + } + if (typeof content.partners === 'string') { + try { + content.partners = JSON.parse(content.partners); + } catch (e) { + content.partners = []; + } + } + + setPageContent(content); // Update document title and meta tags - if (response.data.page_content.meta_title) { - document.title = response.data.page_content.meta_title; + if (content.meta_title) { + document.title = content.meta_title; } - if (response.data.page_content.meta_description) { + if (content.meta_description) { let metaDescription = document.querySelector('meta[name="description"]'); if (!metaDescription) { metaDescription = document.createElement('meta'); metaDescription.setAttribute('name', 'description'); document.head.appendChild(metaDescription); } - metaDescription.setAttribute('content', response.data.page_content.meta_description); + metaDescription.setAttribute('content', content.meta_description); } } } catch (err: any) { @@ -215,27 +344,34 @@ const HomePage: React.FC = () => { )}
-
+
+ {/* Subtle background pattern */} +
+
{/* Featured & Newest Rooms Section - Combined Carousel */} -
+
{/* Section Header - Centered */}
-

+
+
+
+

{pageContent?.hero_title || 'Featured & Newest Rooms'}

-

+

{pageContent?.hero_subtitle || pageContent?.description || 'Discover our most popular accommodations and latest additions'}

{/* View All Rooms Button - Golden, Centered */} -
+
+ View All Rooms - +
@@ -300,79 +436,818 @@ const HomePage: React.FC = () => { )}
- {/* Features Section */} -
-
- {/* Decorative gold accent */} -
- -
-
-
- 🏨 -
-

- Easy Booking -

-

- Search and book rooms with just a few clicks -

-
+ {/* Features Section - Dynamic from page content */} + {(() => { + // Filter out empty features (no title or description) + const validFeatures = pageContent?.features?.filter( + (f: any) => f && (f.title || f.description) + ) || []; + + return (validFeatures.length > 0 || !pageContent) && ( +
+
+ {/* Decorative gold accents */} +
+
+ + {/* Subtle background pattern */} +
+ +
+ {validFeatures.length > 0 ? ( + validFeatures.map((feature: any, index: number) => ( +
+ {feature.image ? ( +
+ {feature.title +
+ ) : ( +
+ {feature.icon && (LucideIcons as any)[feature.icon] ? ( + React.createElement((LucideIcons as any)[feature.icon], { + className: 'w-7 h-7 md:w-8 md:h-8 text-[#d4af37] drop-shadow-md' + }) + ) : ( + + )} +
+ )} + {feature.title && ( +

+ {feature.title} +

+ )} + {feature.description && ( +

+ {feature.description} +

+ )} +
+ )) + ) : ( + <> +
+
+ 🏨 +
+

+ Easy Booking +

+

+ Search and book rooms with just a few clicks +

+
-
-
- 💰 -
-

- Best Prices -

-

- Best price guarantee in the market -

-
+
+
+ 💰 +
+

+ Best Prices +

+

+ Best price guarantee in the market +

+
-
-
- 🎧 +
+
+ 🎧 +
+

+ 24/7 Support +

+

+ Support team always ready to serve +

+
+ + )}
-

- 24/7 Support -

-

- Support team always ready to serve +

+
+ ); + })()} + + {/* Luxury Section - Dynamic from page content */} + {(pageContent?.luxury_section_title || (pageContent?.luxury_features && pageContent.luxury_features.length > 0)) && ( +
+
+
+
+
+

+ {pageContent.luxury_section_title || 'Experience Unparalleled Luxury'} +

+ {pageContent.luxury_section_subtitle && ( +

+ {pageContent.luxury_section_subtitle}

+ )} +
+ {pageContent.luxury_section_image && ( +
+
+ Luxury Experience +
+
+
+ )} + {pageContent.luxury_features && pageContent.luxury_features.length > 0 && ( +
+ {pageContent.luxury_features.map((feature, index) => ( +
+
+
+ {feature.icon && (LucideIcons as any)[feature.icon] ? ( + React.createElement((LucideIcons as any)[feature.icon], { + className: 'w-7 h-7 md:w-8 md:h-8 text-[#d4af37] drop-shadow-md' + }) + ) : ( + + )} +
+

+ {feature.title} +

+

+ {feature.description} +

+
+ ))} +
+ )} +
+ )} + + {/* Luxury Gallery Section - Dynamic from page content */} + {pageContent?.luxury_gallery && Array.isArray(pageContent.luxury_gallery) && pageContent.luxury_gallery.length > 0 && ( +
+
+
+
+
+

+ {pageContent.luxury_gallery_section_title || 'Luxury Gallery'} +

+ {pageContent.luxury_gallery_section_subtitle && ( +

+ {pageContent.luxury_gallery_section_subtitle} +

+ )} +
+
+ {pageContent.luxury_gallery.map((image, index) => { + // Normalize image URL - if it's a relative path, prepend the API URL + const imageUrl = image && typeof image === 'string' + ? (image.startsWith('http://') || image.startsWith('https://') + ? image + : `${import.meta.env.VITE_API_URL?.replace('/api', '') || 'http://localhost:8000'}${image.startsWith('/') ? image : '/' + image}`) + : ''; + + if (!imageUrl) return null; + + return ( +
{ + const normalizedImages = pageContent.luxury_gallery + .map(img => { + if (!img || typeof img !== 'string') return null; + return img.startsWith('http://') || img.startsWith('https://') + ? img + : `${import.meta.env.VITE_API_URL?.replace('/api', '') || 'http://localhost:8000'}${img.startsWith('/') ? img : '/' + img}`; + }) + .filter(Boolean) as string[]; + setLightboxImages(normalizedImages); + setLightboxIndex(index); + setLightboxOpen(true); + }} + > + {`Luxury { + console.error(`Failed to load luxury gallery image: ${imageUrl}`); + (e.target as HTMLImageElement).style.display = 'none'; + }} + /> +
+
+ +
+
+
+
+ ); + })} +
+
+ )} + + {/* Luxury Testimonials Section - Dynamic from page content */} + {pageContent?.luxury_testimonials && pageContent.luxury_testimonials.length > 0 && ( +
+
+
+
+
+

+ {pageContent.luxury_testimonials_section_title || 'Guest Experiences'} +

+ {pageContent.luxury_testimonials_section_subtitle && ( +

+ {pageContent.luxury_testimonials_section_subtitle} +

+ )} +

+ Hear from our valued guests about their luxury stay +

+
+
+ {pageContent.luxury_testimonials.map((testimonial, index) => ( +
+
+
+ {testimonial.image ? ( +
+ {testimonial.name} +
+
+ ) : ( +
+ {testimonial.name.charAt(0).toUpperCase()} +
+ )} +
+

{testimonial.name}

+ {testimonial.title && ( +

{testimonial.title}

+ )} +
+
+
+
"
+

{testimonial.quote}

+
+
+ ))} +
+
+ )} + + {/* Stats Section - Dynamic from page content */} + {pageContent?.stats && Array.isArray(pageContent.stats) && pageContent.stats.length > 0 && ( +
+
+ {/* Decorative elements */} +
+
+ +
+ {pageContent.stats.map((stat, index) => ( +
+ {stat?.icon && ( +
+ {stat.icon && (LucideIcons as any)[stat.icon] ? ( + React.createElement((LucideIcons as any)[stat.icon], { + className: 'w-8 h-8 md:w-10 md:h-10 text-[#d4af37] drop-shadow-md' + }) + ) : ( + {stat.icon} + )} +
+ )} + {stat?.number && ( +
+ {stat.number} +
+ )} + {stat?.label && ( +
+ {stat.label} +
+ )} +
+ ))} +
+
+
+ )} + + {/* Amenities Section - Dynamic from page content */} + {pageContent?.amenities && pageContent.amenities.length > 0 && ( +
+
+
+
+
+

+ {pageContent.amenities_section_title || 'Luxury Amenities'} +

+

+ {pageContent.amenities_section_subtitle || 'Experience world-class amenities designed for your comfort'} +

+
+
+ {pageContent.amenities.map((amenity, index) => ( +
+
+ {amenity.image ? ( +
+ {amenity.title} +
+ ) : ( +
+ {amenity.icon && (LucideIcons as any)[amenity.icon] ? ( + React.createElement((LucideIcons as any)[amenity.icon], { + className: 'w-7 h-7 md:w-8 md:h-8 text-[#d4af37] drop-shadow-md' + }) + ) : ( + + )} +
+ )} +

+ {amenity.title} +

+

+ {amenity.description} +

+
+ ))} +
+
+ )} + + {/* Testimonials Section - Dynamic from page content */} + {pageContent?.testimonials && pageContent.testimonials.length > 0 && ( +
+
+
+
+
+

+ {pageContent.testimonials_section_title || 'Guest Testimonials'} +

+

+ {pageContent.testimonials_section_subtitle || 'See what our guests say about their experience'} +

+
+
+ {pageContent.testimonials.map((testimonial, index) => ( +
+
+
+ {testimonial.image ? ( +
+ {testimonial.name} +
+
+ ) : ( +
+ {testimonial.name.charAt(0).toUpperCase()} +
+ )} +
+

{testimonial.name}

+

{testimonial.role}

+
+
+
+ {[...Array(5)].map((_, i) => ( + + ))} +
+
+
"
+

"{testimonial.comment}"

+
+
+ ))} +
+
+ )} + + + {/* About Preview Section - Dynamic from page content */} + {(pageContent?.about_preview_title || pageContent?.about_preview_content) && ( +
+
+ {/* Decorative gold accents */} +
+
+ +
+ {pageContent.about_preview_image && ( +
+ About us +
+
+ )} +
+
+
+
+

+ {pageContent.about_preview_title || 'About Our Hotel'} +

+ {pageContent.about_preview_subtitle && ( +

+ {pageContent.about_preview_subtitle} +

+ )} + {pageContent.about_preview_content && ( +

+ {pageContent.about_preview_content} +

+ )} + + + Learn More + + +
+
+
+
+ )} + + {/* Luxury Services Section */} + {pageContent?.luxury_services && pageContent.luxury_services.length > 0 && ( +
+
+
+
+
+

+ {pageContent.luxury_services_section_title || 'Luxury Services'} +

+ {pageContent.luxury_services_section_subtitle && ( +

+ {pageContent.luxury_services_section_subtitle} +

+ )} +
+
+ {pageContent.luxury_services.map((service: any, index: number) => ( +
+
+ {service.image ? ( +
+ {service.title} +
+ ) : ( +
+ {service.icon && (LucideIcons as any)[service.icon] ? ( + React.createElement((LucideIcons as any)[service.icon], { + className: 'w-7 h-7 md:w-8 md:h-8 text-[#d4af37] drop-shadow-md' + }) + ) : ( + + )} +
+ )} +

+ {service.title} +

+

+ {service.description} +

+
+ ))} +
+
+ )} + + {/* Luxury Experiences Section */} + {pageContent?.luxury_experiences && pageContent.luxury_experiences.length > 0 && ( +
+
+
+
+
+

+ {pageContent.luxury_experiences_section_title || 'Unique Experiences'} +

+ {pageContent.luxury_experiences_section_subtitle && ( +

+ {pageContent.luxury_experiences_section_subtitle} +

+ )} +
+
+ {pageContent.luxury_experiences.map((experience: any, index: number) => ( +
+
+ {experience.image ? ( +
+ {experience.title} +
+ ) : ( +
+ {experience.icon && (LucideIcons as any)[experience.icon] ? ( + React.createElement((LucideIcons as any)[experience.icon], { + className: 'w-7 h-7 md:w-8 md:h-8 text-[#d4af37] drop-shadow-md' + }) + ) : ( + + )} +
+ )} +

+ {experience.title} +

+

+ {experience.description} +

+
+ ))} +
+
+ )} + + {/* Awards Section */} + {pageContent?.awards && pageContent.awards.length > 0 && ( +
+
+
+
+
+

+ {pageContent.awards_section_title || 'Awards & Recognition'} +

+ {pageContent.awards_section_subtitle && ( +

+ {pageContent.awards_section_subtitle} +

+ )} +
+
+ {pageContent.awards.map((award: any, index: number) => ( +
+
+ {award.image ? ( +
+ {award.title} +
+ ) : ( +
+ {award.icon && (LucideIcons as any)[award.icon] ? ( + React.createElement((LucideIcons as any)[award.icon], { + className: 'w-8 h-8 md:w-10 md:h-10 text-[#d4af37] drop-shadow-md' + }) + ) : ( + 🏆 + )} +
+ )} + {award.year && ( +
{award.year}
+ )} +

+ {award.title} +

+ {award.description && ( +

+ {award.description} +

+ )} +
+ ))} +
+
+ )} + + {/* CTA Section */} + {(pageContent?.cta_title || pageContent?.cta_subtitle) && ( +
+
+ {pageContent.cta_image && ( +
+ CTA Background +
+ )} +
+
+
+
+
+

+ {pageContent.cta_title} +

+ {pageContent.cta_subtitle && ( +

+ {pageContent.cta_subtitle} +

+ )} + {pageContent.cta_button_text && pageContent.cta_button_link && ( + + + {pageContent.cta_button_text} + + + )} +
+
+
+ )} + + {/* Partners Section */} + {pageContent?.partners && pageContent.partners.length > 0 && ( +
+
+
+
+
+

+ {pageContent.partners_section_title || 'Our Partners'} +

+ {pageContent.partners_section_subtitle && ( +

+ {pageContent.partners_section_subtitle} +

+ )} +
+
+ {pageContent.partners.map((partner: any, index: number) => ( +
+ {partner.link ? ( + + {partner.logo ? ( + {partner.name} + ) : ( + {partner.name} + )} + + ) : ( + <> + {partner.logo ? ( + {partner.name} + ) : ( + {partner.name} + )} + + )} +
+ ))} +
+
+ )} + +
+
+ + {/* Luxury Gallery Lightbox Modal */} + {lightboxOpen && lightboxImages.length > 0 && ( +
setLightboxOpen(false)} + > + {/* Close Button */} + + + {/* Previous Button */} + {lightboxImages.length > 1 && ( + + )} + + {/* Next Button */} + {lightboxImages.length > 1 && ( + + )} + + {/* Image Container */} +
e.stopPropagation()} + > +
+ {`Luxury { + console.error(`Failed to load lightbox image: ${lightboxImages[lightboxIndex]}`); + }} + /> + + {/* Image Counter */} + {lightboxImages.length > 1 && ( +
+ {lightboxIndex + 1} / {lightboxImages.length} +
+ )} + + {/* Thumbnail Strip (if more than 1 image) */} + {lightboxImages.length > 1 && lightboxImages.length <= 10 && ( +
+ {lightboxImages.map((thumb, idx) => ( + + ))} +
+ )}
-
-
+ )} ); }; diff --git a/Frontend/src/pages/admin/BookingManagementPage.tsx b/Frontend/src/pages/admin/BookingManagementPage.tsx index 9c7bd13f..ce037b6f 100644 --- a/Frontend/src/pages/admin/BookingManagementPage.tsx +++ b/Frontend/src/pages/admin/BookingManagementPage.tsx @@ -1,20 +1,23 @@ import React, { useEffect, useState } from 'react'; -import { Search, Eye, XCircle, CheckCircle, Loader2 } from 'lucide-react'; -import { bookingService, Booking } from '../../services/api'; +import { Search, Eye, XCircle, CheckCircle, Loader2, FileText } from 'lucide-react'; +import { bookingService, Booking, invoiceService } from '../../services/api'; import { toast } from 'react-toastify'; import Loading from '../../components/common/Loading'; import Pagination from '../../components/common/Pagination'; import { useFormatCurrency } from '../../hooks/useFormatCurrency'; import { parseDateLocal } from '../../utils/format'; +import { useNavigate } from 'react-router-dom'; const BookingManagementPage: React.FC = () => { const { formatCurrency } = useFormatCurrency(); + const navigate = useNavigate(); const [bookings, setBookings] = useState([]); const [loading, setLoading] = useState(true); const [selectedBooking, setSelectedBooking] = useState(null); const [showDetailModal, setShowDetailModal] = useState(false); const [updatingBookingId, setUpdatingBookingId] = useState(null); const [cancellingBookingId, setCancellingBookingId] = useState(null); + const [creatingInvoice, setCreatingInvoice] = useState(false); const [filters, setFilters] = useState({ search: '', status: '', @@ -80,6 +83,32 @@ const BookingManagementPage: React.FC = () => { } }; + const handleCreateInvoice = async (bookingId: number) => { + try { + setCreatingInvoice(true); + // Ensure bookingId is a number + const invoiceData = { + booking_id: Number(bookingId), + }; + + const response = await invoiceService.createInvoice(invoiceData); + + if (response.status === 'success' && response.data?.invoice) { + toast.success('Invoice created successfully!'); + setShowDetailModal(false); + navigate(`/admin/invoices/${response.data.invoice.id}`); + } else { + throw new Error('Failed to create invoice'); + } + } catch (error: any) { + const errorMessage = error.response?.data?.detail || error.response?.data?.message || error.message || 'Unable to create invoice'; + toast.error(errorMessage); + console.error('Invoice creation error:', error); + } finally { + setCreatingInvoice(false); + } + }; + const getStatusBadge = (status: string) => { const badges: Record = { pending: { @@ -622,7 +651,24 @@ const BookingManagementPage: React.FC = () => {
{/* Modal Footer */} -
+
+
- {/* Search Booking */} + {/* Date and Search Filters */}
-

1. Search booking

-
-
- +
+
+ setBookingNumber(e.target.value)} - onKeyPress={(e) => e.key === 'Enter' && handleSearch()} - placeholder="Enter booking number" - className="w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500" + type="date" + value={selectedDate} + onChange={(e) => setSelectedDate(e.target.value)} + className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500" />
- +
+ +
+ setSearchQuery(e.target.value)} + onKeyPress={(e) => e.key === 'Enter' && handleSearchByNumber()} + placeholder="Enter booking number" + className="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500" + /> + +
+
+
+ +
- {/* Booking Info */} + {/* Check-ins and Check-outs Lists */} + {!booking && ( +
+ {/* Check-ins for Today */} +
+
+

+ + Check-ins for {formatDate(selectedDate)} +

+ + {checkInBookings.length} + +
+ {loadingBookings ? ( +
+ +
+ ) : checkInBookings.length === 0 ? ( +
+ +

No check-ins scheduled for this date

+
+ ) : ( +
+ {checkInBookings.map((b) => ( +
handleSelectBooking(b.booking_number)} + className="p-4 border border-gray-200 rounded-lg hover:border-blue-500 hover:shadow-md cursor-pointer transition-all" + > +
+
+
{b.booking_number}
+
{b.user?.full_name}
+
+ {b.room?.room_type?.name} • {formatCurrency(b.total_price)} +
+
+
+ + {b.status} + +
+
+
+ ))} +
+ )} +
+ + {/* Check-outs for Today */} +
+
+

+ + Check-outs for {formatDate(selectedDate)} +

+ + {checkOutBookings.length} + +
+ {loadingBookings ? ( +
+ +
+ ) : checkOutBookings.length === 0 ? ( +
+ +

No check-outs scheduled for this date

+
+ ) : ( +
+ {checkOutBookings.map((b) => ( +
handleSelectBooking(b.booking_number)} + className="p-4 border border-gray-200 rounded-lg hover:border-orange-500 hover:shadow-md cursor-pointer transition-all" + > +
+
+
{b.booking_number}
+
{b.user?.full_name}
+
+ {b.room?.room_type?.name} • {formatCurrency(b.total_price)} +
+
+
+ + {b.status} + +
+
+
+ ))} +
+ )} +
+
+ )} + + {/* Booking Info and Check-in Form */} {booking && ( <>
-

- - 2. Booking Information -

+
+

+ + 2. Booking Information +

+ +
@@ -299,7 +541,6 @@ const CheckInPage: React.FC = () => {
{(() => { - // Use payment_balance from API if available, otherwise calculate from payments const paymentBalance = booking.payment_balance || (() => { const completedPayments = booking.payments?.filter( (p) => p.payment_status === 'completed' @@ -545,19 +786,6 @@ const CheckInPage: React.FC = () => {
)} - - {/* Empty State */} - {!booking && !searching && ( -
- -

- No booking selected -

-

- Please enter booking number above to start check-in process -

-
- )}
); }; diff --git a/Frontend/src/pages/admin/InvoiceManagementPage.tsx b/Frontend/src/pages/admin/InvoiceManagementPage.tsx index 3d897a7a..e7d6245d 100644 --- a/Frontend/src/pages/admin/InvoiceManagementPage.tsx +++ b/Frontend/src/pages/admin/InvoiceManagementPage.tsx @@ -47,7 +47,8 @@ const InvoiceManagementPage: React.FC = () => { invoiceList = invoiceList.filter((inv) => inv.invoice_number.toLowerCase().includes(filters.search.toLowerCase()) || inv.customer_name.toLowerCase().includes(filters.search.toLowerCase()) || - inv.customer_email.toLowerCase().includes(filters.search.toLowerCase()) + inv.customer_email.toLowerCase().includes(filters.search.toLowerCase()) || + (inv.promotion_code && inv.promotion_code.toLowerCase().includes(filters.search.toLowerCase())) ); } @@ -130,11 +131,11 @@ const InvoiceManagementPage: React.FC = () => {

Manage and track all invoices

@@ -190,6 +191,9 @@ const InvoiceManagementPage: React.FC = () => { Amount + + Promotion + Status @@ -235,6 +239,25 @@ const InvoiceManagementPage: React.FC = () => { Due: {formatCurrency(invoice.balance_due)}
)} + {invoice.discount_amount > 0 && ( +
+ Discount: -{formatCurrency(invoice.discount_amount)} +
+ )} + + + {invoice.promotion_code ? ( + + {invoice.promotion_code} + + ) : ( + + )} + {invoice.is_proforma && ( +
+ Proforma +
+ )} @@ -274,7 +297,7 @@ const InvoiceManagementPage: React.FC = () => { }) ) : ( - +

No invoices found

diff --git a/Frontend/src/pages/admin/PageContentDashboard.tsx b/Frontend/src/pages/admin/PageContentDashboard.tsx index d52089e8..d33edbec 100644 --- a/Frontend/src/pages/admin/PageContentDashboard.tsx +++ b/Frontend/src/pages/admin/PageContentDashboard.tsx @@ -7,13 +7,6 @@ import { Search, Save, Globe, - Facebook, - Twitter, - Instagram, - Linkedin, - Youtube, - MapPin, - Phone, X, Plus, Trash2, @@ -31,6 +24,8 @@ import { pageContentService, PageContent, PageType, UpdatePageContentData, banne import { toast } from 'react-toastify'; import Loading from '../../components/common/Loading'; import { ConfirmationDialog } from '../../components/common'; +import IconPicker from '../../components/admin/IconPicker'; +import { luxuryContentSeed } from '../../data/luxuryContentSeed'; type ContentTab = 'overview' | 'home' | 'contact' | 'about' | 'footer' | 'seo'; @@ -62,7 +57,7 @@ const PageContentDashboard: React.FC = () => { title: '', description: '', image_url: '', - link: '', + link_url: '', position: 'home', display_order: 0, is_active: true, @@ -113,6 +108,21 @@ const PageContentDashboard: React.FC = () => { } }; + // Helper function to normalize arrays (handle both arrays and JSON strings) + const normalizeArray = (value: any): any[] => { + if (!value) return []; + if (Array.isArray(value)) return value; + if (typeof value === 'string') { + try { + const parsed = JSON.parse(value); + return Array.isArray(parsed) ? parsed : []; + } catch { + return []; + } + } + return []; + }; + const initializeFormData = (contents: Record) => { // Home if (contents.home) { @@ -130,6 +140,45 @@ const PageContentDashboard: React.FC = () => { og_title: contents.home.og_title || '', og_description: contents.home.og_description || '', og_image: contents.home.og_image || '', + features: normalizeArray(contents.home.features), + amenities_section_title: contents.home.amenities_section_title || '', + amenities_section_subtitle: contents.home.amenities_section_subtitle || '', + amenities: normalizeArray(contents.home.amenities), + testimonials_section_title: contents.home.testimonials_section_title || '', + testimonials_section_subtitle: contents.home.testimonials_section_subtitle || '', + testimonials: normalizeArray(contents.home.testimonials), + about_preview_title: contents.home.about_preview_title || '', + about_preview_subtitle: contents.home.about_preview_subtitle || '', + about_preview_content: contents.home.about_preview_content || '', + about_preview_image: contents.home.about_preview_image || '', + stats: normalizeArray(contents.home.stats), + luxury_section_title: contents.home.luxury_section_title || '', + luxury_section_subtitle: contents.home.luxury_section_subtitle || '', + luxury_section_image: contents.home.luxury_section_image || '', + luxury_features: normalizeArray(contents.home.luxury_features), + luxury_gallery_section_title: contents.home.luxury_gallery_section_title || '', + luxury_gallery_section_subtitle: contents.home.luxury_gallery_section_subtitle || '', + luxury_gallery: normalizeArray(contents.home.luxury_gallery), + luxury_testimonials_section_title: contents.home.luxury_testimonials_section_title || '', + luxury_testimonials_section_subtitle: contents.home.luxury_testimonials_section_subtitle || '', + luxury_testimonials: normalizeArray(contents.home.luxury_testimonials), + luxury_services_section_title: contents.home.luxury_services_section_title || '', + luxury_services_section_subtitle: contents.home.luxury_services_section_subtitle || '', + luxury_services: normalizeArray(contents.home.luxury_services), + luxury_experiences_section_title: contents.home.luxury_experiences_section_title || '', + luxury_experiences_section_subtitle: contents.home.luxury_experiences_section_subtitle || '', + luxury_experiences: normalizeArray(contents.home.luxury_experiences), + awards_section_title: contents.home.awards_section_title || '', + awards_section_subtitle: contents.home.awards_section_subtitle || '', + awards: normalizeArray(contents.home.awards), + cta_title: contents.home.cta_title || '', + cta_subtitle: contents.home.cta_subtitle || '', + cta_button_text: contents.home.cta_button_text || '', + cta_button_link: contents.home.cta_button_link || '', + cta_image: contents.home.cta_image || '', + partners_section_title: contents.home.partners_section_title || '', + partners_section_subtitle: contents.home.partners_section_subtitle || '', + partners: normalizeArray(contents.home.partners), }); } @@ -154,8 +203,14 @@ const PageContentDashboard: React.FC = () => { description: contents.about.description || '', content: contents.about.content || '', story_content: contents.about.story_content || '', - values: contents.about.values || [], - features: contents.about.features || [], + values: normalizeArray(contents.about.values), + features: normalizeArray(contents.about.features), + about_hero_image: contents.about.about_hero_image || '', + mission: contents.about.mission || '', + vision: contents.about.vision || '', + team: normalizeArray(contents.about.team), + timeline: normalizeArray(contents.about.timeline), + achievements: normalizeArray(contents.about.achievements), meta_title: contents.about.meta_title || '', meta_description: contents.about.meta_description || '', }); @@ -169,6 +224,7 @@ const PageContentDashboard: React.FC = () => { social_links: contents.footer.social_links || {}, footer_links: contents.footer.footer_links || { quick_links: [], support_links: [] }, badges: contents.footer.badges || [], + copyright_text: contents.footer.copyright_text || '', meta_title: contents.footer.meta_title || '', meta_description: contents.footer.meta_description || '', }); @@ -244,7 +300,7 @@ const PageContentDashboard: React.FC = () => { try { setUploadingImage(true); const response = await bannerService.uploadBannerImage(file); - if (response.status === 'success' || response.success) { + if (response.success) { setBannerFormData({ ...bannerFormData, image_url: response.data.image_url }); toast.success('Image uploaded successfully'); } @@ -257,6 +313,27 @@ const PageContentDashboard: React.FC = () => { } }; + // Generic image upload handler for page content images + const handlePageContentImageUpload = async ( + file: File, + onSuccess: (imageUrl: string) => void + ) => { + if (file.size > 5 * 1024 * 1024) { + toast.error('Image size must be less than 5MB'); + return; + } + + try { + const response = await pageContentService.uploadImage(file); + if (response.success) { + onSuccess(response.data.image_url); + toast.success('Image uploaded successfully'); + } + } catch (error: any) { + toast.error(error.response?.data?.message || 'Failed to upload image'); + } + }; + const handleBannerSubmit = async (e: React.FormEvent) => { e.preventDefault(); @@ -270,7 +347,7 @@ const PageContentDashboard: React.FC = () => { if (imageFile && !imageUrl) { setUploadingImage(true); const uploadResponse = await bannerService.uploadBannerImage(imageFile); - if (uploadResponse.status === 'success' || uploadResponse.success) { + if (uploadResponse.success) { imageUrl = uploadResponse.data.image_url; } else { throw new Error('Failed to upload image'); @@ -305,9 +382,9 @@ const PageContentDashboard: React.FC = () => { setEditingBanner(banner); setBannerFormData({ title: banner.title || '', - description: '', + description: banner.description || '', image_url: banner.image_url || '', - link: banner.link || '', + link_url: banner.link_url || '', position: banner.position || 'home', display_order: banner.display_order || 0, is_active: banner.is_active ?? true, @@ -343,7 +420,7 @@ const PageContentDashboard: React.FC = () => { title: '', description: '', image_url: '', - link: '', + link_url: '', position: 'home', display_order: 0, is_active: true, @@ -531,6 +608,42 @@ const PageContentDashboard: React.FC = () => { {/* Home Tab */} {activeTab === 'home' && (
+ {/* Seed Data Button */} +
+
+
+

Quick Start

+

Load pre-configured luxury content to get started quickly

+
+ +
+
+ {/* Home Page Content Section */}

Home Page Content

@@ -559,14 +672,38 @@ const PageContentDashboard: React.FC = () => {
- - setHomeData({ ...homeData, hero_image: e.target.value })} - className="w-full px-4 py-3 bg-white border-2 border-gray-200 rounded-xl focus:border-purple-400 focus:ring-4 focus:ring-purple-100 transition-all duration-200" - placeholder="https://example.com/hero-image.jpg" - /> + +
+ setHomeData({ ...homeData, hero_image: e.target.value })} + className="flex-1 px-4 py-3 bg-white border-2 border-gray-200 rounded-xl focus:border-purple-400 focus:ring-4 focus:ring-purple-100 transition-all duration-200" + placeholder="https://example.com/hero-image.jpg or upload" + /> + +
+ {homeData.hero_image && ( +
+ Hero preview +
+ )}
@@ -621,17 +758,1388 @@ const PageContentDashboard: React.FC = () => { placeholder="SEO Meta Description" />
+
+
-
- + {/* Amenities Section */} +
+

Amenities Section

+
+
+ + setHomeData({ ...homeData, amenities_section_title: e.target.value })} + className="w-full px-4 py-3 border-2 border-gray-200 rounded-xl" + placeholder="Luxury Amenities" + />
+
+ + setHomeData({ ...homeData, amenities_section_subtitle: e.target.value })} + className="w-full px-4 py-3 border-2 border-gray-200 rounded-xl" + placeholder="Experience world-class amenities" + /> +
+
+
+

Amenities

+ +
+
+ {Array.isArray(homeData.amenities) && homeData.amenities.map((amenity, index) => ( +
+
+

Amenity {index + 1}

+ +
+
+
+ { + setHomeData((prevData) => { + const currentAmenities = Array.isArray(prevData.amenities) ? [...prevData.amenities] : []; + currentAmenities[index] = { ...currentAmenities[index], icon: iconName }; + return { ...prevData, amenities: currentAmenities }; + }); + }} + label="Icon" + /> +
+
+ +
+ { + setHomeData((prevData) => { + const currentAmenities = Array.isArray(prevData.amenities) ? [...prevData.amenities] : []; + currentAmenities[index] = { ...currentAmenities[index], image: e.target.value }; + return { ...prevData, amenities: currentAmenities }; + }); + }} + className="flex-1 px-4 py-2 border-2 border-gray-200 rounded-lg" + placeholder="URL or upload" + /> + +
+ {amenity?.image && ( +
+ Amenity preview +
+ )} +
+
+
+ + { + setHomeData((prevData) => { + const currentAmenities = Array.isArray(prevData.amenities) ? [...prevData.amenities] : []; + currentAmenities[index] = { ...currentAmenities[index], title: e.target.value }; + return { ...prevData, amenities: currentAmenities }; + }); + }} + className="w-full px-4 py-2 border-2 border-gray-200 rounded-lg" + /> +
+
+ +