save discount profile is now working perfectly well
This commit is contained in:
@@ -370,6 +370,40 @@ pub async fn audience_price_many(
|
||||
Ok(list.iter().map(|p| detail_for(p, &pc).priced()).collect())
|
||||
}
|
||||
|
||||
/// Like [`audience_price_many`], but prices against an *unsaved* set of profile
|
||||
/// ids for the active audience instead of the persisted assignment. Used by the
|
||||
/// products page to preview effective prices as the admin toggles profile
|
||||
/// checkboxes, before they hit Save. For the business tab the personal layer
|
||||
/// stays the persisted one (businesses get the lower of personal/business), and
|
||||
/// only the business layer is replaced by the previewed selection.
|
||||
pub async fn audience_price_many_preview(
|
||||
ctx: &AppContext,
|
||||
list: &[products::Model],
|
||||
audience: &str,
|
||||
selected_profile_ids: Vec<i32>,
|
||||
) -> Result<Vec<PricedProduct>> {
|
||||
let preview = load_profiles_by_ids(ctx, selected_profile_ids).await?;
|
||||
let (personal, business, b2b) = if audience == AUDIENCE_BUSINESS {
|
||||
(
|
||||
load_audience(ctx, AUDIENCE_PERSONAL).await?,
|
||||
preview,
|
||||
Some(B2bContext {
|
||||
manual: HashMap::new(),
|
||||
profiles: LoadedProfiles::empty(),
|
||||
resolutions: HashMap::new(),
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
(preview, LoadedProfiles::empty(), None)
|
||||
};
|
||||
let pc = PricingCtx {
|
||||
personal,
|
||||
business,
|
||||
b2b,
|
||||
};
|
||||
Ok(list.iter().map(|p| detail_for(p, &pc).priced()).collect())
|
||||
}
|
||||
|
||||
/// Price one product for `user` (`None` = anonymous/public).
|
||||
pub async fn price_for(
|
||||
ctx: &AppContext,
|
||||
|
||||
Reference in New Issue
Block a user