Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
import { IframeBridge, callHandlerJson } from '@alga-psa/extension-iframe-sdk';
|
|
|
|
const output = document.getElementById('output');
|
|
const btnCreate = document.getElementById('btn-create') as HTMLButtonElement | null;
|
|
const btnStatus = document.getElementById('btn-status') as HTMLButtonElement | null;
|
|
|
|
function write(obj: unknown) {
|
|
if (!output) return;
|
|
output.textContent = JSON.stringify(obj, null, 2);
|
|
}
|
|
|
|
function getInputValue(id: string): string {
|
|
const el = document.getElementById(id) as HTMLInputElement | HTMLTextAreaElement | null;
|
|
return el?.value ?? '';
|
|
}
|
|
|
|
async function main() {
|
|
// The host currently does not provide a stable parentOrigin query param on all routes.
|
|
// For local/dev, allow wildcard so the SDK accepts messages from the embedding origin.
|
|
const bridge = new IframeBridge({ devAllowWildcard: true });
|
|
bridge.ready();
|
|
|
|
btnStatus?.addEventListener('click', async () => {
|
|
try {
|
|
const data = await callHandlerJson(bridge, '/api/status');
|
|
write({ ok: true, data });
|
|
} catch (err) {
|
|
write({ ok: false, error: err instanceof Error ? err.message : String(err) });
|
|
}
|
|
});
|
|
|
|
btnCreate?.addEventListener('click', async () => {
|
|
if (!btnCreate) return;
|
|
btnCreate.disabled = true;
|
|
btnCreate.textContent = 'Creating...';
|
|
|
|
try {
|
|
const clientId = getInputValue('clientId').trim();
|
|
const serviceId = getInputValue('serviceId').trim();
|
|
const invoiceDate = getInputValue('invoiceDate').trim();
|
|
const dueDate = getInputValue('dueDate').trim();
|
|
const poNumber = getInputValue('poNumber').trim();
|
|
const quantity = Number(getInputValue('quantity'));
|
|
const rateDollars = Number(getInputValue('rateDollars'));
|
|
const description = getInputValue('description');
|
|
|
|
const rate = Number.isFinite(rateDollars) ? Math.round(rateDollars * 100) : rateDollars;
|
|
|
|
const body = {
|
|
clientId,
|
|
invoiceDate: invoiceDate || undefined,
|
|
dueDate: dueDate || undefined,
|
|
poNumber: poNumber ? poNumber : null,
|
|
items: [{ serviceId, quantity, description, rate }],
|
|
};
|
|
|
|
const data = await callHandlerJson(bridge, '/api/create-manual-invoice', {
|
|
method: 'POST',
|
|
body,
|
|
});
|
|
write({ ok: true, data });
|
|
} catch (err) {
|
|
write({ ok: false, error: err instanceof Error ? err.message : String(err) });
|
|
} finally {
|
|
btnCreate.disabled = false;
|
|
btnCreate.textContent = 'Create Draft Invoice';
|
|
}
|
|
});
|
|
}
|
|
|
|
main().catch((err) => {
|
|
write({ ok: false, error: err instanceof Error ? err.message : String(err) });
|
|
});
|