Merge branch 'master' into beta

This commit is contained in:
Abdullah Atta
2025-10-10 15:53:32 +05:00
5 changed files with 36 additions and 19 deletions

View File

@@ -50,7 +50,6 @@ const TRIAL_PERIODS: Record<Period, number> = {
}; };
export function toPricingInfo(plan: Plan, user: User | undefined): PricingInfo { export function toPricingInfo(plan: Plan, user: User | undefined): PricingInfo {
console.log("TO PRICING INFO", plan);
return { return {
country: plan.country, country: plan.country,
period: plan.period, period: plan.period,
@@ -58,9 +57,9 @@ export function toPricingInfo(plan: Plan, user: User | undefined): PricingInfo {
currency: plan.currency, currency: plan.currency,
id: plan.id, id: plan.id,
period: plan.period, period: plan.period,
subtotal: formatPrice(plan.price.gross, plan.currency), subtotal: formatPrice(plan.price.net, plan.currency),
tax: formatPrice(plan.price.tax, plan.currency), tax: formatPrice(plan.price.tax, plan.currency),
total: formatPrice(plan.price.net, plan.currency), total: formatPrice(plan.price.gross, plan.currency),
trial_period: isTrialAvailableForPlan(plan.plan, user) trial_period: isTrialAvailableForPlan(plan.plan, user)
? { ? {
frequency: TRIAL_PERIODS[plan.period] frequency: TRIAL_PERIODS[plan.period]
@@ -74,9 +73,9 @@ export function toPricingInfo(plan: Plan, user: User | undefined): PricingInfo {
currency: plan.currency, currency: plan.currency,
id: plan.id, id: plan.id,
period: plan.period, period: plan.period,
subtotal: formatPrice(plan.price.gross, plan.currency), subtotal: formatPrice(plan.price.net, plan.currency),
tax: formatPrice(plan.price.tax, plan.currency), tax: formatPrice(plan.price.tax, plan.currency),
total: formatPrice(plan.price.net, plan.currency) total: formatPrice(plan.price.gross, plan.currency)
} }
: undefined : undefined
}; };

View File

@@ -245,7 +245,7 @@ function getPricingInfo(
id: price.price_id, id: price.price_id,
period: options.period, period: options.period,
subtotal: formatPrice( subtotal: formatPrice(
data.recurring_totals.subtotal, data.recurring_totals.subtotal - data.recurring_totals.discount,
data.currency_code data.currency_code
), ),
total: formatPrice(data.recurring_totals.total, data.currency_code), total: formatPrice(data.recurring_totals.total, data.currency_code),
@@ -256,7 +256,10 @@ function getPricingInfo(
currency: data.currency_code, currency: data.currency_code,
id: price.price_id, id: price.price_id,
period: options.period, period: options.period,
subtotal: formatPrice(totals.subtotal, data.currency_code), subtotal: formatPrice(
totals.subtotal - totals.discount,
data.currency_code
),
total: formatPrice(totals.total, data.currency_code), total: formatPrice(totals.total, data.currency_code),
tax: formatPrice(totals.tax, data.currency_code), tax: formatPrice(totals.tax, data.currency_code),
trial_period: price.trial_period trial_period: price.trial_period

View File

@@ -119,7 +119,7 @@ function Checkout() {
useEffect(() => { useEffect(() => {
if (currentStep === 2) { if (currentStep === 2) {
var event = EV.subscribe(EVENTS.userSubscriptionUpdated, () => { const event = EV.subscribe(EVENTS.userSubscriptionUpdated, () => {
hardNavigate("/notes#/welcome"); hardNavigate("/notes#/welcome");
}); });
return () => { return () => {

View File

@@ -42,7 +42,7 @@ export class ClipboardDOMParser extends ProsemirrorDOMParser {
convertGoogleDocsChecklist(dom); convertGoogleDocsChecklist(dom);
formatCodeblocks(dom); formatCodeblocks(dom);
convertBrToSingleSpacedParagraphs(dom); convertBrToSingleSpacedParagraphs(dom);
removeImages(dom); removePremiumFeatures(dom);
removeBlockId(dom); removeBlockId(dom);
} }
return super.parseSlice(dom, options); return super.parseSlice(dom, options);
@@ -53,7 +53,7 @@ export class ClipboardDOMParser extends ProsemirrorDOMParser {
convertGoogleDocsChecklist(dom); convertGoogleDocsChecklist(dom);
formatCodeblocks(dom); formatCodeblocks(dom);
convertBrToSingleSpacedParagraphs(dom); convertBrToSingleSpacedParagraphs(dom);
removeImages(dom); removePremiumFeatures(dom);
removeBlockId(dom); removeBlockId(dom);
} }
return super.parse(dom, options); return super.parse(dom, options);
@@ -154,11 +154,29 @@ export function convertGoogleDocsChecklist(dom: HTMLElement | Document) {
} }
} }
export function removeImages(dom: HTMLElement | Document) { const premiumFeatures = [
let canInsertImages: boolean | null = null; {
for (const img of dom.querySelectorAll(`img`)) { selector: "div.callout",
canInsertImages = canInsertImages ?? hasPermission("insertImage"); permission: "setCallout"
if (!canInsertImages) img.remove(); },
{
selector: 'ul[data-type="outlineList"]',
permission: "toggleOutlineList"
},
{
selector: "ul.checklist",
permission: "toggleTaskList"
}
] as const;
function removePremiumFeatures(dom: HTMLElement | Document) {
for (const feature of premiumFeatures) {
const elements = dom.querySelectorAll(feature.selector);
if (elements.length === 0) continue;
if (!hasPermission(feature.permission)) {
elements.forEach((element) => element.remove());
}
} }
} }

View File

@@ -69,10 +69,7 @@ export function TableComponent(props: ReactNodeViewProps) {
/> />
</DesktopOnly> </DesktopOnly>
<SimpleBar autoHide> <SimpleBar autoHide>
<Box <Box dir={textDirection}>
dir={textDirection}
sx={{ "& table": { width: "100% !important" } }}
>
<table <table
ref={(ref) => { ref={(ref) => {
forwardRef?.(ref); forwardRef?.(ref);