From e9845160baeedfec3db60532fd767a3004dfa25a Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Thu, 15 Aug 2024 11:31:34 +0530 Subject: [PATCH] resolved issues in the companies page --- lib/src/models/company_model.dart | 2 +- .../companies/company_details_and_issues.dart | 68 ++++++++++--------- .../pages/companies/company_list_page.dart | 16 +++-- .../leaderboards/company_scoreboard.dart | 9 +-- .../companies/company_list_provider.dart | 2 +- lib/src/util/api/issues_api.dart | 2 +- 6 files changed, 55 insertions(+), 44 deletions(-) diff --git a/lib/src/models/company_model.dart b/lib/src/models/company_model.dart index 71d8784fc3..bb2ef83237 100644 --- a/lib/src/models/company_model.dart +++ b/lib/src/models/company_model.dart @@ -60,7 +60,7 @@ class Company { parsedJson["closed"] ?? 0, parsedJson["issue_count"] ?? 0, DateTime.parse(parsedJson["modified"]), - parsedJson["logo"].toString(), + parsedJson["logo"] ?? "", parsedJson["top"] ?? "", parsedJson["twitter"], parsedJson["facebook"], diff --git a/lib/src/pages/companies/company_details_and_issues.dart b/lib/src/pages/companies/company_details_and_issues.dart index 7276804067..103c2eb364 100644 --- a/lib/src/pages/companies/company_details_and_issues.dart +++ b/lib/src/pages/companies/company_details_and_issues.dart @@ -47,30 +47,33 @@ class CompanyDetailWithIssuesState setState(() { loading = true; }); - IssueData? response = - await IssueApiClient.getIssueByStatus("open", widget.company.url!); - openIssues = response!.issueList ?? []; - response = - await IssueApiClient.getIssueByStatus("closed", widget.company.url!); - closedIssues = response!.issueList ?? []; - // intialize the segments - segments = [ - Segment( - value: closedIssues.length, - color: Color.fromARGB(255, 101, 205, 105), - label: Text( - "Closed", + if (widget.company.url != null && widget.company.url != "") { + IssueData? response = + await IssueApiClient.getIssueByStatus("open", widget.company.url!); + openIssues = response!.issueList ?? []; + response = + await IssueApiClient.getIssueByStatus("closed", widget.company.url!); + closedIssues = response!.issueList ?? []; + + // intialize the segments + segments = [ + Segment( + value: closedIssues.length, + color: Color.fromARGB(255, 101, 205, 105), + label: Text( + "Closed", + ), ), - ), - Segment( - value: openIssues.length, - color: Colors.deepOrange, - label: Text( - "Open", + Segment( + value: openIssues.length, + color: Colors.deepOrange, + label: Text( + "Open", + ), ), - ), - ]; + ]; + } setState(() { loading = false; }); @@ -121,17 +124,18 @@ class CompanyDetailWithIssuesState padding: EdgeInsets.symmetric(horizontal: 20).copyWith(top: 12), child: Column(mainAxisAlignment: MainAxisAlignment.start, children: [ - ClipRRect( - borderRadius: BorderRadius.circular(12), - child: SizedBox( - // width: size.width * 0.89, - height: size.height * 0.17, - child: Image.network( - company.logoLink, - fit: BoxFit.contain, + if (company.logoLink != "") + ClipRRect( + borderRadius: BorderRadius.circular(12), + child: SizedBox( + // width: size.width * 0.89, + height: size.height * 0.17, + child: Image.network( + company.logoLink, + fit: BoxFit.contain, + ), ), ), - ), SizedBox(height: 8), Text( company.companyName, @@ -143,7 +147,7 @@ class CompanyDetailWithIssuesState ), ), SizedBox(height: 8), - if (company.email != "") ...[ + if (company.email != null && company.email != "") ...[ Text( company.email!, style: GoogleFonts.ubuntu( @@ -249,7 +253,7 @@ class CompanyDetailWithIssuesState // ), SizedBox(height: 20), // About Us Section: only if have a desc - if (company.description != null) ...[ + if (company.description != null && company.description != "") ...[ Align( alignment: Alignment.centerLeft, child: Text( diff --git a/lib/src/pages/companies/company_list_page.dart b/lib/src/pages/companies/company_list_page.dart index 9c6b1a3edd..421f0cafa5 100644 --- a/lib/src/pages/companies/company_list_page.dart +++ b/lib/src/pages/companies/company_list_page.dart @@ -259,11 +259,17 @@ class CompanyListElement extends StatelessWidget { child: SizedBox( height: 80, width: 120, - child: Image.network( - company.logoLink, - fit: BoxFit.cover, - alignment: Alignment.center, - ), + child: (company.logoLink != "") + ? Image.network( + company.logoLink, + fit: BoxFit.cover, + alignment: Alignment.center, + ) + : Image.asset( + "assets/image-not-found.png", + fit: BoxFit.cover, + alignment: Alignment.center, + ), ), ), SizedBox(height: 8), diff --git a/lib/src/pages/leaderboards/company_scoreboard.dart b/lib/src/pages/leaderboards/company_scoreboard.dart index 8ffb21d86b..323e5fbd3b 100644 --- a/lib/src/pages/leaderboards/company_scoreboard.dart +++ b/lib/src/pages/leaderboards/company_scoreboard.dart @@ -51,7 +51,7 @@ class CompanyScoreboardPageState extends ConsumerState else return CircleAvatar( foregroundImage: CachedNetworkImageProvider( - GeneralEndPoints.apiBaseUrl + "media/" + partUrl, + "https://storage.googleapis.com/bhfiles/" + partUrl, ), radius: 20, ); @@ -190,9 +190,10 @@ class CompanyScoreboardPageState extends ConsumerState company.closedIssues, company.issueCount, company.lastModified, - GeneralEndPoints.apiBaseUrl + - "media/" + - company.logoLink, + (company.logoLink != "") + ? "https://storage.googleapis.com/bhfiles/" + + company.logoLink + : "", company.topTester, company.twitter, company.facebook, diff --git a/lib/src/providers/companies/company_list_provider.dart b/lib/src/providers/companies/company_list_provider.dart index a3a55ad46f..f6400ab337 100644 --- a/lib/src/providers/companies/company_list_provider.dart +++ b/lib/src/providers/companies/company_list_provider.dart @@ -23,7 +23,7 @@ class CompanyListNotifier extends StateNotifier?>?> { final client = http.Client(); try { final List? companyData = - await CompanyApiClient.getListOfCompanies(client, "/company/"); + await CompanyApiClient.getListOfCompanies(client, "companies/"); state = AsyncValue.data(companyData); } catch (e) { AsyncValue.error(e); diff --git a/lib/src/util/api/issues_api.dart b/lib/src/util/api/issues_api.dart index 4884e0d620..ab0145dfd2 100644 --- a/lib/src/util/api/issues_api.dart +++ b/lib/src/util/api/issues_api.dart @@ -238,7 +238,7 @@ class IssueApiClient { List? issueList; try { String searchUrl = GeneralEndPoints.apiBaseUrl + - "/api/v1/issues/" + + "issues/" + "?status=$status&domain=$url"; response = await http.get(Uri.parse(searchUrl)); if (response.statusCode == 200) {