76 lines
9.1 KiB
JavaScript
76 lines
9.1 KiB
JavaScript
import { s as subscribe } from "../../../chunks/utils.js";
|
|
import { c as create_ssr_component, a as add_attribute, e as escape, b as each, v as validate_component } from "../../../chunks/ssr.js";
|
|
import { p as page } from "../../../chunks/stores.js";
|
|
import { w as walletStore } from "../../../chunks/walletStore.js";
|
|
import { e as expenseStore, i as isExpenseValid } from "../../../chunks/expenseStore.js";
|
|
import "@stellar/stellar-sdk";
|
|
import "../../../chunks/horizonQueries.js";
|
|
import "../../../chunks/transactions.js";
|
|
const css = {
|
|
code: 'input[type="number"].svelte-9ghwy4::-webkit-outer-spin-button,input[type="number"].svelte-9ghwy4::-webkit-inner-spin-button{-webkit-appearance:none;appearance:none;margin:0}input[type="number"].svelte-9ghwy4{-moz-appearance:textfield;appearance:textfield}',
|
|
map: null
|
|
};
|
|
const ExpenseForm = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let currentExpense;
|
|
let walletConnected;
|
|
let $walletStore, $$unsubscribe_walletStore;
|
|
let $expenseStore, $$unsubscribe_expenseStore;
|
|
$$unsubscribe_walletStore = subscribe(walletStore, (value) => $walletStore = value);
|
|
$$unsubscribe_expenseStore = subscribe(expenseStore, (value) => $expenseStore = value);
|
|
let descriptionInput;
|
|
let amountInput;
|
|
$$result.css.add(css);
|
|
currentExpense = $expenseStore.currentExpense;
|
|
walletConnected = $walletStore.publicKey;
|
|
{
|
|
if (walletConnected && !currentExpense.id) {
|
|
expenseStore.update((store) => ({
|
|
...store,
|
|
currentExpense: {
|
|
id: Date.now().toString(36) + Math.random().toString(36).substr(2),
|
|
description: "",
|
|
totalAmount: "",
|
|
participants: [],
|
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
createdBy: $walletStore.publicKey
|
|
}
|
|
}));
|
|
}
|
|
}
|
|
$$unsubscribe_walletStore();
|
|
$$unsubscribe_expenseStore();
|
|
return `<div class="space-y-6"><form class="space-y-4"> <div><label for="description" class="block text-sm font-medium text-gray-700 mb-1" data-svelte-h="svelte-103bymj">What's this expense for?</label> <input type="text" id="description"${add_attribute("value", currentExpense.description, 0)} placeholder="Dinner, Movie tickets, Utilities, etc." class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"${add_attribute("this", descriptionInput, 0)}> ${``}</div> <div><label for="amount" class="block text-sm font-medium text-gray-700 mb-1" data-svelte-h="svelte-yc5yir">Total Amount (XLM)</label> <input type="number" id="amount"${add_attribute("value", currentExpense.totalAmount, 0)} step="0.0000001" min="0" placeholder="0.0000000" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 svelte-9ghwy4"${add_attribute("this", amountInput, 0)}> ${`<p class="mt-1 text-xs text-gray-500" data-svelte-h="svelte-h1xsju">Enter the total amount to be split between everyone</p>`}</div> <div><p class="block text-xs font-medium text-gray-600 mb-2" data-svelte-h="svelte-y1cu3u">Quick Amounts</p> <div class="flex flex-wrap gap-2"><button type="button" class="px-3 py-1 text-sm bg-gray-100 hover:bg-gray-200 text-gray-800 rounded transition-colors" data-svelte-h="svelte-g3qgrk">10 XLM</button> <button type="button" class="px-3 py-1 text-sm bg-gray-100 hover:bg-gray-200 text-gray-800 rounded transition-colors" data-svelte-h="svelte-1o80fec">25 XLM</button> <button type="button" class="px-3 py-1 text-sm bg-gray-100 hover:bg-gray-200 text-gray-800 rounded transition-colors" data-svelte-h="svelte-dpk8s0">50 XLM</button> <button type="button" class="px-3 py-1 text-sm bg-gray-100 hover:bg-gray-200 text-gray-800 rounded transition-colors" data-svelte-h="svelte-12m1gbi">100 XLM</button> <button type="button" class="px-3 py-1 text-sm bg-gray-100 hover:bg-gray-200 text-gray-800 rounded transition-colors" data-svelte-h="svelte-6spsmu">200 XLM</button> <button type="button" class="px-3 py-1 text-sm bg-red-50 hover:bg-red-100 text-red-700 rounded transition-colors" data-svelte-h="svelte-qpzjjh">Clear</button></div></div></form> ${currentExpense.description && currentExpense.totalAmount ? `<div class="bg-blue-50 border border-blue-100 rounded-lg p-4"><h3 class="text-md font-medium text-blue-800 mb-2" data-svelte-h="svelte-axa95w">Expense Summary</h3> <div class="grid grid-cols-2 gap-2 text-sm"><div class="text-blue-700" data-svelte-h="svelte-bsi4kb">Description:</div> <div class="font-medium text-blue-900">${escape(currentExpense.description)}</div> <div class="text-blue-700" data-svelte-h="svelte-ilk9zr">Amount:</div> <div class="font-medium text-blue-900">${escape(currentExpense.totalAmount)} XLM</div></div></div>` : ``} <div class="bg-gray-50 rounded-lg p-4 border border-gray-200" data-svelte-h="svelte-jz1394"><h3 class="font-medium text-gray-800 mb-2">💡 Tips</h3> <ul class="text-sm text-gray-600 space-y-1"><li>• Be specific in the description (e.g., "Dinner at Luigi's - 5/15")</li> <li>• Enter the total amount you paid, not individual shares</li> <li>• You'll add participants and choose split method in the next step</li></ul></div> ${!walletConnected ? `<div class="bg-yellow-50 border border-yellow-200 rounded-lg p-4" data-svelte-h="svelte-12fkglq"><p class="text-sm text-yellow-800">Please connect your wallet to create an expense.</p></div>` : `<div class="text-xs text-gray-500">You're creating this expense as: ${escape($walletStore.publicKey.substring(0, 8))}...${escape($walletStore.publicKey.substring($walletStore.publicKey.length - 8))}</div>`} </div>`;
|
|
});
|
|
const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
let walletConnected;
|
|
let $$unsubscribe_page;
|
|
let $walletStore, $$unsubscribe_walletStore;
|
|
let $expenseStore, $$unsubscribe_expenseStore;
|
|
let $$unsubscribe_isExpenseValid;
|
|
$$unsubscribe_page = subscribe(page, (value) => value);
|
|
$$unsubscribe_walletStore = subscribe(walletStore, (value) => $walletStore = value);
|
|
$$unsubscribe_expenseStore = subscribe(expenseStore, (value) => $expenseStore = value);
|
|
$$unsubscribe_isExpenseValid = subscribe(isExpenseValid, (value) => value);
|
|
let currentStep = 1;
|
|
let validationErrors = [];
|
|
walletConnected = $walletStore.publicKey;
|
|
$$unsubscribe_page();
|
|
$$unsubscribe_walletStore();
|
|
$$unsubscribe_expenseStore();
|
|
$$unsubscribe_isExpenseValid();
|
|
return `${$$result.head += `<!-- HEAD_svelte-e66dgi_START -->${$$result.title = `<title>Split Expense - InstantSplit</title>`, ""}<meta name="description" content="Split expenses with friends using Stellar blockchain for ultra-low fees and instant settlement."><!-- HEAD_svelte-e66dgi_END -->`, ""} <div class="min-h-screen bg-gray-50 py-8"><div class="max-w-4xl mx-auto px-4"> <div class="text-center mb-8" data-svelte-h="svelte-1rhvllx"><h1 class="text-4xl font-bold text-gray-900 mb-4">💸 Split Expense</h1> <p class="text-lg text-gray-600">Split bills with friends globally in seconds, not days</p></div> ${!walletConnected ? `<div class="max-w-md mx-auto" data-svelte-h="svelte-20aay3"><div class="bg-yellow-50 border border-yellow-200 rounded-lg p-6 text-center"><p class="mb-4 text-yellow-800">Connect your Stellar wallet to start splitting expenses.</p> <a href="/auto-login" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg font-medium transition-colors">Connect Wallet</a></div></div>` : ` <div class="mb-8"><div class="flex items-center justify-center space-x-4">${each(["Create", "Participants", "Review", "Complete"], (step, index) => {
|
|
return `<div class="flex items-center"><div class="${"flex items-center justify-center w-8 h-8 rounded-full text-sm font-semibold " + escape(
|
|
index + 1 <= currentStep ? "bg-blue-600 text-white" : "bg-gray-200 text-gray-600",
|
|
true
|
|
)}">${escape(index + 1)}</div> <span class="${"ml-2 text-sm font-medium " + escape(
|
|
index + 1 <= currentStep ? "text-blue-600" : "text-gray-600",
|
|
true
|
|
)}">${escape(step)}</span> ${index < 3 ? `<div class="${"w-8 h-0.5 mx-4 " + escape(index + 1 < currentStep ? "bg-blue-600" : "bg-gray-200", true)}"></div>` : ``} </div>`;
|
|
})}</div></div> ${validationErrors.length > 0 ? `<div class="mb-6"><div class="bg-red-50 border border-red-200 rounded-lg p-4"><h3 class="text-red-800 font-medium mb-2" data-svelte-h="svelte-3kt48s">Please fix the following errors:</h3> <ul class="list-disc list-inside space-y-1">${each(validationErrors, (error) => {
|
|
return `<li class="text-red-700 text-sm">${escape(error)}</li>`;
|
|
})}</ul></div></div>` : ``} <div class="space-y-6"> ${`<div class="bg-white rounded-lg shadow-sm border p-6"><h2 class="text-xl font-semibold mb-4" data-svelte-h="svelte-1vnruxo">📝 Expense Details</h2> ${validate_component(ExpenseForm, "ExpenseForm").$$render($$result, {}, {}, {})} ${$expenseStore.currentExpense.description && $expenseStore.currentExpense.totalAmount ? `<div class="mt-4 flex justify-end"><button class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg font-medium transition-colors" data-next-step data-svelte-h="svelte-7284a1">Next: Add Participants →</button></div>` : ``}</div>`} ${``} ${``} ${``}</div>`}</div></div>`;
|
|
});
|
|
export {
|
|
Page as default
|
|
};
|