Skip to content

Replace hardcoded configuration values with environment variables#42

Merged
hassan689 merged 3 commits into
mainfrom
copilot/refactor-hogrdcoded-config-values
Jan 9, 2026
Merged

Replace hardcoded configuration values with environment variables#42
hassan689 merged 3 commits into
mainfrom
copilot/refactor-hogrdcoded-config-values

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 9, 2026

Hardcoded commission rates (0.10/0.90) and Firebase configuration values scattered across 7 files violated 12-factor app principles and required code changes for environment-specific settings.

Changes

Commission Rate Configuration

  • payment_confirmation_screen.dart: Replaced widget.taskAmount * 0.10 with PointsService.calculateCommission() for consistent rate application
  • payment_settings.dart, ai_service.dart: Display strings now dynamically format percentages from PointsService.platformCommissionRate / providerPayoutRate

Before:

final platformCommission = widget.taskAmount * 0.10;
final providerPayout = widget.taskAmount * 0.90;
// ...
'Platform Commission (10%)'

After:

final commissionCalculation = PointsService.calculateCommission(widget.taskAmount);
final platformCommission = commissionCalculation['platformCommission']!;
final providerPayout = commissionCalculation['providerPayout']!;
final platformCommissionRate = PointsService.platformCommissionRate;
// ...
'Platform Commission (${(platformCommissionRate * 100).toStringAsFixed(0)}%)'

Firebase Configuration

  • app_config.dart: Added firebaseAuthActionUrl getter that constructs URLs from FIREBASE_PROJECT_ID
  • fb.dart, loginp.dart, signuppage.dart: Replaced hardcoded 'com.example.connect' and 'https://YOUR_PROJECT_ID.firebaseapp.com/__/auth/action' with AppConfig.appPackageName, AppConfig.firebaseIosBundleId, and AppConfig.firebaseAuthActionUrl

Environment Variables

Uses existing .env.example variables:

  • PLATFORM_COMMISSION_RATE (default: 0.10)
  • PROVIDER_PAYOUT_RATE (default: 0.90)
  • APP_PACKAGE_NAME (default: com.example.connect)
  • FIREBASE_IOS_BUNDLE_ID (default: com.example.connect)
  • FIREBASE_PROJECT_ID (constructs auth URLs)

All defaults maintain current behavior.

Original prompt

This section details on the original issue you should resolve

<issue_title>Hardcoded Configuration Values Instead of Environment Variables</issue_title>
<issue_description>## 🟡 Medium Priority Issue

Problem

Some configuration values are hardcoded in the code instead of using environment variables, reducing flexibility.

Examples

  • Default commission rates in app_config.dart:184,193
  • Some Firebase configuration might be hardcoded
  • Default values that should be configurable

Impact

  • Less flexible configuration
  • Requires code changes to modify settings
  • Not following 12-factor app principles

Expected Behavior

All configurable values should be in environment variables with sensible defaults.

Solution

Move hardcoded values to environment variables:

  1. Add to .env.example
  2. Update app_config.dart to read from environment
  3. Provide sensible defaults

Additional Context

The app already uses environment variables for most configuration, but some values are still hardcoded.</issue_description>

<agent_instructions>you have to do this for the whole project if there are some errors </agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 9, 2026 17:35
Co-authored-by: hassan689 <117458014+hassan689@users.noreply.github.com>
Co-authored-by: hassan689 <117458014+hassan689@users.noreply.github.com>
@hassan689 hassan689 marked this pull request as ready for review January 9, 2026 17:41
@hassan689 hassan689 merged commit 26f4fd2 into main Jan 9, 2026
Copilot AI changed the title [WIP] Refactor hardcoded configuration values to use environment variables Replace hardcoded configuration values with environment variables Jan 9, 2026
Copilot AI requested a review from hassan689 January 9, 2026 17:42
Copilot stopped work on behalf of hassan689 due to an error January 9, 2026 17:42
@hassan689 hassan689 deleted the copilot/refactor-hogrdcoded-config-values branch January 9, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hardcoded Configuration Values Instead of Environment Variables

2 participants