diff --git a/build_web_dev.sh b/build_web_dev.sh index f7d52b3..60b7729 100755 --- a/build_web_dev.sh +++ b/build_web_dev.sh @@ -11,24 +11,32 @@ fi # Copy the .env.development file to .env cp $ENV_FILE_PATH .env +echo "Copied $ENV_FILE_PATH to .env" -# Check if the BASE_HREF variable exists in the .env file -if ! grep -q BASE_HREF .env; then - echo "BASE_HREF not found in .env file" - exit 1 -fi +# Verify .env file contains correct values +source .env -# Extract the BASE_HREF value -BASE_HREF=$(grep BASE_HREF .env | cut -d '=' -f2) - -# Check if the BASE_HREF value is empty if [ -z "$BASE_HREF" ]; then echo "BASE_HREF value is empty" exit 1 fi +if [ -z "$API_URL" ]; then + echo "API_URL value is empty" + exit 1 +fi + +# Print loaded values for verification +echo "Loaded BASE_HREF: $BASE_HREF" +echo "Loaded API_URL: $API_URL" + # Build the web app for development with base href flutter build web --release --base-href "$BASE_HREF" -# Optionally, remove the .env file after the build -# rm .env +# Check if the build was successful +if [ $? -ne 0 ]; then + echo "Flutter dev build failed" + exit 1 +fi + +echo "Flutter dev build succeeded" diff --git a/build_web_production.sh b/build_web_production.sh index 7463034..dd142ef 100755 --- a/build_web_production.sh +++ b/build_web_production.sh @@ -1,34 +1,42 @@ #!/bin/bash -# Define the path to the .env file for production +# Define the path to the .env.production file ENV_FILE_PATH=".env.production" -# Check if the .env file exists +# Check if the .env.production file exists if [ ! -f $ENV_FILE_PATH ]; then echo "$ENV_FILE_PATH does not exist" exit 1 fi -# Copy the .env file for production to .env +# Copy the .env.production file to .env cp $ENV_FILE_PATH .env +echo "Copied $ENV_FILE_PATH to .env" -# Check if the BASE_HREF variable exists in the .env file -if ! grep -q BASE_HREF .env; then - echo "BASE_HREF not found in .env file" - exit 1 -fi +# Verify .env file contains correct values +source .env -# Extract the BASE_HREF value -BASE_HREF=$(grep BASE_HREF .env | cut -d '=' -f2) - -# Check if the BASE_HREF value is empty if [ -z "$BASE_HREF" ]; then echo "BASE_HREF value is empty" exit 1 fi -# Build the web app for production environment with base href +if [ -z "$API_URL" ]; then + echo "API_URL value is empty" + exit 1 +fi + +# Print loaded values for verification +echo "Loaded BASE_HREF: $BASE_HREF" +echo "Loaded API_URL: $API_URL" + +# Build the web app for production with base href flutter build web --release --base-href "$BASE_HREF" -# Optionally, remove the .env file after the build -# rm .env +# Check if the build was successful +if [ $? -ne 0 ]; then + echo "Flutter prod build failed" + exit 1 +fi + +echo "Flutter prod build succeeded" diff --git a/build_web_test.sh b/build_web_test.sh index cee690d..16f4e32 100755 --- a/build_web_test.sh +++ b/build_web_test.sh @@ -1,34 +1,42 @@ #!/bin/bash -# Define the path to the .env file for testing +# Define the path to the .env.test file ENV_FILE_PATH=".env.test" -# Check if the .env file exists +# Check if the .env.test file exists if [ ! -f $ENV_FILE_PATH ]; then echo "$ENV_FILE_PATH does not exist" exit 1 fi -# Copy the .env file for testing to .env +# Copy the .env.test file to .env cp $ENV_FILE_PATH .env +echo "Copied $ENV_FILE_PATH to .env" -# Check if the BASE_HREF variable exists in the .env file -if ! grep -q BASE_HREF .env; then - echo "BASE_HREF not found in .env file" - exit 1 -fi +# Verify .env file contains correct values +source .env -# Extract the BASE_HREF value -BASE_HREF=$(grep BASE_HREF .env | cut -d '=' -f2) - -# Check if the BASE_HREF value is empty if [ -z "$BASE_HREF" ]; then echo "BASE_HREF value is empty" exit 1 fi -# Build the web app for test environment with base href +if [ -z "$API_URL" ]; then + echo "API_URL value is empty" + exit 1 +fi + +# Print loaded values for verification +echo "Loaded BASE_HREF: $BASE_HREF" +echo "Loaded API_URL: $API_URL" + +# Build the web app for the test environment with base href flutter build web --release --base-href "$BASE_HREF" -# Optionally, remove the .env file after the build -# rm .env +# Check if the build was successful +if [ $? -ne 0 ]; then + echo "Flutter test build failed" + exit 1 +fi + +echo "Flutter test build succeeded" diff --git a/lib/hrDashboard.dart b/lib/hrDashboard.dart index 621f0a4..b481adc 100644 --- a/lib/hrDashboard.dart +++ b/lib/hrDashboard.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -451,155 +452,168 @@ class _hrDashboardState extends State { ), ), SizedBox(height: 8), - Row( - children: List.generate( - policyDetails.length, - (index) => Container( - width: 300, - height: policyHeight, - child: GestureDetector( - onTap: () { - Navigator.pushNamed( - context, - 'hrPolicyDetails', - arguments: - policyDetails[ - index]); - }, - child: MouseRegion( - cursor: - SystemMouseCursors - .click, - child: Card( - elevation: 3, - color: - cardColor, // Use the determined color - child: Column( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - ListTile( - title: - SizedBox( - height: 50, - child: Text( - '${policyDetails[index]['policy_name']} - (${policyDetails[index]['type']})', - style: GoogleFonts - .poppins( - fontSize: - 16, - fontWeight: - FontWeight.w500, - color: Color( - 0xFF000000), - height: - 1.5, + SingleChildScrollView( + scrollDirection: + Axis.horizontal, + controller: + ScrollController(), // Adding ScrollController + dragStartBehavior: + DragStartBehavior.start, + child: Row( + children: List.generate( + policyDetails.length, + (index) => Container( + width: 300, + height: policyHeight, + child: GestureDetector( + onTap: () { + Navigator.pushNamed( + context, + 'hrPolicyDetails', + arguments: + policyDetails[ + index]); + }, + child: MouseRegion( + cursor: + SystemMouseCursors + .click, + child: Card( + elevation: 3, + color: + cardColor, // Use the determined color + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + ListTile( + title: + SizedBox( + height: + 50, + child: + Text( + '${policyDetails[index]['policy_name']} - (${policyDetails[index]['type']})', + style: GoogleFonts + .poppins( + fontSize: + 16, + fontWeight: + FontWeight.w500, + color: + Color(0xFF000000), + height: + 1.5, + ), + softWrap: + true, // Allow text to wrap to the next line if needed ), - softWrap: - true, // Allow text to wrap to the next line if needed ), ), - ), - SizedBox( - height: 8), - Padding( - padding: EdgeInsets - .only( - left: - 15, - right: - 15), - child: Row( - children: [ - Expanded( - flex: 4, - child: - Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'Draft', - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Color(0xFF000000), - height: 1.5, + SizedBox( + height: + 8), + Padding( + padding: EdgeInsets.only( + left: + 15, + right: + 15), + child: Row( + children: [ + Expanded( + flex: + 4, + child: + Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Draft', + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF000000), + height: 1.5, + ), ), - ), - Text( - policyDetails[index]['membersCountOfDraft'].toString(), - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.w400, - color: Color(0xFF000000), - height: 1.5, + Text( + policyDetails[index]['membersCountOfDraft'].toString(), + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Color(0xFF000000), + height: 1.5, + ), ), - ), - ], + ], + ), ), - ), - Expanded( - flex: 4, - child: - Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'Enrolled', - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Color(0xFF000000), - height: 1.5, + Expanded( + flex: + 4, + child: + Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Enrolled', + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF000000), + height: 1.5, + ), ), - ), - Text( - policyDetails[index]['membersCountOfEnrolled'].toString(), - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.w400, - color: Color(0xFF000000), - height: 1.5, + Text( + policyDetails[index]['membersCountOfEnrolled'].toString(), + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Color(0xFF000000), + height: 1.5, + ), ), - ), - ], + ], + ), ), - ), - Expanded( - flex: 4, - child: - Column( - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - Text( - 'Total', - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Color(0xFF000000), - height: 1.5, + Expanded( + flex: + 4, + child: + Column( + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + Text( + 'Total', + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Color(0xFF000000), + height: 1.5, + ), ), - ), - Text( - policyDetails[index]['totalMembersCount'].toString(), - style: GoogleFonts.poppins( - fontSize: 16, - fontWeight: FontWeight.w400, - color: Color(0xFF000000), - height: 1.5, + Text( + policyDetails[index]['totalMembersCount'].toString(), + style: GoogleFonts.poppins( + fontSize: 16, + fontWeight: FontWeight.w400, + color: Color(0xFF000000), + height: 1.5, + ), ), - ), - ], + ], + ), ), - ), - ], - ), // Adjust the horizontal padding as needed - ) - ], + ], + ), // Adjust the horizontal padding as needed + ) + ], + ), ), ), ), diff --git a/lib/models/environment.dart b/lib/models/environment.dart index 096ca2a..08badee 100644 --- a/lib/models/environment.dart +++ b/lib/models/environment.dart @@ -1,12 +1,14 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; +import '../home.dart'; + class Environment { static String get fileName { const bool isProduction = bool.fromEnvironment('dart.vm.product', defaultValue: false); - const bool isTest = - bool.fromEnvironment('dart.vm.environment', defaultValue: false); + const bool isTest = bool.fromEnvironment('ENV', defaultValue: false); if (isProduction) { return '.env.production'; @@ -29,3 +31,8 @@ class Environment { return dotenv.env['ENV'] ?? 'ENV not found!'; } } + +Future main() async { + await dotenv.load(fileName: Environment.fileName); + runApp(MyApp()); +}