Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 5205 - added a "My prices" item linking to the web app #5317

Merged
merged 2 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading