Skip to content

Commit

Permalink
feat: 5205 - added a "My prices" item linking to the web app (#5317)
Browse files Browse the repository at this point in the history
Impacted files:
* `app_en.arb`: added a "My prices" label
* `app_fr.arb`: added a "My prices" label
* `user_preferences_account.dart`: added a "My prices" item
  • Loading branch information
monsieurtanuki authored May 31, 2024
1 parent c962614 commit 722c2f4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,10 @@
"@user_search_to_be_completed_title": {
"description": "User search (to be completed): list tile title"
},
"user_search_prices_title": "My prices",
"@user_search_prices_title": {
"description": "User prices: list tile title"
},
"all_search_to_be_completed_title": "All to-be-completed products",
"@all_search_to_be_completed_title": {
"description": "All products to be completed: list tile title"
Expand Down
4 changes: 4 additions & 0 deletions packages/smooth_app/lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,10 @@
"@user_search_to_be_completed_title": {
"description": "User search (to be completed): list tile title"
},
"user_search_prices_title": "Mes prix",
"@user_search_prices_title": {
"description": "User prices: list tile title"
},
"all_search_to_be_completed_title": "Tous les produits à compléter",
"@all_search_to_be_completed_title": {
"description": "All products to be completed: list tile title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,21 @@ class UserPreferencesAccount extends AbstractUserPreferences {
localDatabase: localDatabase,
myCount: _getMyCount(UserSearchType.TO_BE_COMPLETED),
),
_getListTile(
appLocalizations.user_search_prices_title,
() async {
final UriProductHelper uriProductHelper =
ProductQuery.uriProductHelper;
final Uri uri = Uri(
scheme: uriProductHelper.scheme,
host: uriProductHelper.getHost('prices'),
path: 'app/dashboard/prices',
);
return LaunchUrlHelper.launchURL(uri.toString());
},
Icons.open_in_new,
myCount: _getMyPricesCount(),
),
_buildProductQueryTile(
productQuery: PagedToBeCompletedProductQuery(),
title: appLocalizations.all_search_to_be_completed_title,
Expand Down Expand Up @@ -311,6 +326,20 @@ class UserPreferencesAccount extends AbstractUserPreferences {
}
}

Future<int?> _getMyPricesCount() async {
final MaybeError<GetPricesResult> result =
await OpenPricesAPIClient.getPrices(
GetPricesParameters()
..owner = ProductQuery.getWriteUser().userId
..pageSize = 1,
uriHelper: ProductQuery.uriProductHelper,
);
if (result.isError) {
return null;
}
return result.value.total;
}

UserPreferencesItem _buildProductQueryTile({
required final PagedProductQuery productQuery,
required final String title,
Expand Down

0 comments on commit 722c2f4

Please sign in to comment.