product availability
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
This commit is contained in:
parent
829542714a
commit
efe1a8f898
1 changed files with 5 additions and 3 deletions
|
|
@ -5,11 +5,13 @@ import 'package:mnemo_cards_common_backend/mnemo_cards_common_backend.dart'
|
||||||
hide VoiceModel;
|
hide VoiceModel;
|
||||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||||
|
|
||||||
|
import '../api/di/injector.dart';
|
||||||
|
import 'product_availability_manager.dart';
|
||||||
|
|
||||||
/// Extension для конвертации CardPack (Drift) в DTO
|
/// Extension для конвертации CardPack (Drift) в DTO
|
||||||
extension CardPackToDto on CardPack {
|
extension CardPackToDto on CardPack {
|
||||||
Future<CardPackPreviewDto> toPreviewDto(UserModel? user) async {
|
Future<CardPackPreviewDto> toPreviewDto(UserModel? user) async {
|
||||||
final hasAccess =
|
final isAvailable = await getIt.get<ProductAvailabilityManager>().isPackAvailable(packId: id.toString(), user: user);
|
||||||
user != null && (user.packs.contains(id.toString()) || user.admin);
|
|
||||||
|
|
||||||
// Generate cover image URL
|
// Generate cover image URL
|
||||||
String? coverUrl;
|
String? coverUrl;
|
||||||
|
|
@ -36,7 +38,7 @@ extension CardPackToDto on CardPack {
|
||||||
price: price,
|
price: price,
|
||||||
imageUrl: coverUrl,
|
imageUrl: coverUrl,
|
||||||
color: color,
|
color: color,
|
||||||
isAvailable: hasAccess,
|
isAvailable: isAvailable,
|
||||||
tip: null,
|
tip: null,
|
||||||
version: version,
|
version: version,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue