- Added support for workflow variables in automations, allowing users to define reusable values. - Implemented validation for Generate nodes to ensure intended image counts align with selected accounts. - Updated automation models and requests to handle new variables, including encryption for sensitive data. - Enhanced UI to display variables and their management within the automation editor. - Improved error handling for webhook and HTTP nodes to prevent requests to invalid URLs. - Refactored various components for better context resolution during automation runs.
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import type { InertiaLinkProps } from '@inertiajs/vue3';
|
|
import { clsx, type ClassValue } from 'clsx';
|
|
import { trans } from 'laravel-vue-i18n';
|
|
import { twMerge } from 'tailwind-merge';
|
|
import { toast } from 'vue-sonner';
|
|
|
|
export const cn = (...inputs: ClassValue[]) => {
|
|
return twMerge(clsx(inputs));
|
|
};
|
|
|
|
export const toUrl = (href: NonNullable<InertiaLinkProps['href']>) => {
|
|
return typeof href === 'string' ? href : href?.url;
|
|
};
|
|
|
|
export const formatNumber = (value: number): string => {
|
|
return value.toLocaleString('en-US');
|
|
};
|
|
|
|
export const formatNumberCompact = (value: number): string => {
|
|
return new Intl.NumberFormat('en-US', {
|
|
notation: 'compact',
|
|
compactDisplay: 'short',
|
|
maximumFractionDigits: 1,
|
|
}).format(value);
|
|
};
|
|
|
|
export const formatMoney = (cents: number): string => {
|
|
const dollars = cents / 100;
|
|
return dollars.toLocaleString('en-US', {
|
|
style: 'currency',
|
|
currency: 'USD',
|
|
minimumFractionDigits: 2,
|
|
maximumFractionDigits: 2,
|
|
});
|
|
};
|
|
|
|
export const formatMoneyCompact = (cents: number): string => {
|
|
const dollars = cents / 100;
|
|
return new Intl.NumberFormat('en-US', {
|
|
style: 'currency',
|
|
currency: 'USD',
|
|
notation: 'compact',
|
|
compactDisplay: 'short',
|
|
maximumFractionDigits: 1,
|
|
}).format(dollars);
|
|
};
|
|
|
|
export const copyToClipboard = async (text: string, message?: string) => {
|
|
try {
|
|
await navigator.clipboard.writeText(text);
|
|
toast.success(message ?? trans('common.actions.copied'));
|
|
} catch {
|
|
toast.error(trans('common.actions.copy_failed'));
|
|
}
|
|
};
|