Compare commits
3
Commits
c78920ba6e
...
89e7e6a349
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89e7e6a349
|
||
|
|
280989a8cc
|
||
|
|
fa16a60d24
|
No files matched your search
-19
@@ -1,28 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
const { locale, locales, setLocale } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="min-h-screen bg-orange-50/40 text-stone-900 dark:bg-stone-950 dark:text-stone-100"
|
||||
>
|
||||
<NuxtRouteAnnouncer />
|
||||
<main class="mx-auto max-w-md px-4 py-8">
|
||||
<div class="mb-4 flex justify-end">
|
||||
<select
|
||||
:value="locale"
|
||||
class="rounded-lg border border-stone-300 bg-white px-2 py-1 text-xs font-medium text-stone-600 shadow-sm dark:border-stone-700 dark:bg-stone-900 dark:text-stone-300"
|
||||
@change="
|
||||
setLocale(
|
||||
($event.target as HTMLSelectElement).value as typeof locale,
|
||||
)
|
||||
"
|
||||
>
|
||||
<option v-for="loc in locales" :key="loc.code" :value="loc.code">
|
||||
{{ loc.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<NuxtPage />
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,7 @@ const props = defineProps<{
|
||||
expenses: ExpenseView[];
|
||||
participants: ParticipantView[];
|
||||
currency: string;
|
||||
currentParticipantId?: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -37,10 +38,52 @@ function toggle(id: number) {
|
||||
const sorted = computed(() =>
|
||||
[...props.expenses].sort((a, b) => b.createdAt - a.createdAt),
|
||||
);
|
||||
|
||||
const totalExpensesCents = computed(() =>
|
||||
props.expenses
|
||||
.filter((expense) => expense.type === 'expense')
|
||||
.reduce((sum, expense) => sum + expense.amountCents, 0),
|
||||
);
|
||||
|
||||
const myExpensesCents = computed(() => {
|
||||
const myId = props.currentParticipantId;
|
||||
if (myId === undefined) return 0;
|
||||
return props.expenses
|
||||
.filter(
|
||||
(expense) =>
|
||||
expense.type === 'expense' && expense.participantIds.includes(myId),
|
||||
)
|
||||
.reduce((sum, expense) => {
|
||||
const shares = computeSplit(expense.amountCents, expense.participantIds);
|
||||
return sum + (shares[myId] ?? 0);
|
||||
}, 0);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
v-if="expenses.length > 0"
|
||||
class="flex gap-3 rounded-2xl border border-stone-200 bg-white p-4 shadow-sm dark:border-stone-800 dark:bg-stone-900"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<p class="text-xs text-stone-500 dark:text-stone-400">
|
||||
{{ t('expenses.total') }}
|
||||
</p>
|
||||
<p class="font-medium text-stone-900 dark:text-stone-100">
|
||||
{{ formatCurrency(totalExpensesCents, currency) }}
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="currentParticipantId !== undefined" class="flex-1">
|
||||
<p class="text-xs text-stone-500 dark:text-stone-400">
|
||||
{{ t('expenses.mine') }}
|
||||
</p>
|
||||
<p class="font-medium text-orange-600 dark:text-orange-400">
|
||||
{{ formatCurrency(myExpensesCents, currency) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="expenses.length === 0"
|
||||
class="rounded-2xl border border-dashed border-stone-300 p-4 text-center text-sm text-stone-500 dark:border-stone-700 dark:text-stone-400"
|
||||
|
||||
+21
-1
@@ -1,8 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
const { t } = useI18n();
|
||||
const { t, locale, locales, setLocale } = useI18n();
|
||||
const { name, setName } = useIdentity();
|
||||
const { pots: visitedPots } = useVisitedPots();
|
||||
|
||||
const localeFlags: Record<string, string> = {
|
||||
en: '🇬🇧',
|
||||
de: '🇩🇪',
|
||||
};
|
||||
|
||||
const potName = ref('');
|
||||
const currency = ref('EUR');
|
||||
const creating = ref(false);
|
||||
@@ -34,6 +39,21 @@ async function createPot() {
|
||||
|
||||
<template>
|
||||
<div class="space-y-8">
|
||||
<div class="flex justify-end gap-1">
|
||||
<button
|
||||
v-for="loc in locales"
|
||||
:key="loc.code"
|
||||
type="button"
|
||||
class="rounded-lg px-1.5 py-1 text-lg leading-none transition-opacity"
|
||||
:class="loc.code === locale ? 'opacity-100' : 'opacity-40 hover:opacity-70'"
|
||||
:aria-label="loc.name"
|
||||
:aria-current="loc.code === locale"
|
||||
@click="setLocale(loc.code as typeof locale)"
|
||||
>
|
||||
{{ localeFlags[loc.code] ?? loc.code }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1 text-center">
|
||||
<div class="text-4xl">🍯</div>
|
||||
<h1 class="text-2xl font-bold text-stone-900 dark:text-stone-100">
|
||||
|
||||
@@ -69,6 +69,7 @@ async function removeExpense(id: number) {
|
||||
:expenses="data.expenses"
|
||||
:participants="data.participants"
|
||||
:currency="data.pot.currency"
|
||||
:current-participant-id="me?.id"
|
||||
@edit="editExpense"
|
||||
@remove="removeExpense"
|
||||
/>
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
},
|
||||
"expenses": {
|
||||
"empty": "Noch keine Ausgaben. Füge die erste unten hinzu.",
|
||||
"total": "Gesamtausgaben",
|
||||
"mine": "Deine Ausgaben",
|
||||
"addExpense": "+ Ausgabe hinzufügen",
|
||||
"paidBy": "bezahlt von {name}",
|
||||
"paymentDescription": "{payer} hat {recipient} bezahlt",
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
},
|
||||
"expenses": {
|
||||
"empty": "No expenses yet. Add the first one below.",
|
||||
"total": "Total expenses",
|
||||
"mine": "Your expenses",
|
||||
"addExpense": "+ Add expense",
|
||||
"paidBy": "paid by {name}",
|
||||
"paymentDescription": "{payer} paid {recipient}",
|
||||
|
||||
@@ -6,6 +6,20 @@ export default defineNuxtConfig({
|
||||
devtools: { enabled: true },
|
||||
modules: ['@nuxtjs/i18n'],
|
||||
css: ['~/assets/css/tailwind.css'],
|
||||
app: {
|
||||
head: {
|
||||
link: [
|
||||
{ rel: 'manifest', href: '/manifest.webmanifest' },
|
||||
{ rel: 'apple-touch-icon', href: '/apple-touch-icon.png' },
|
||||
],
|
||||
meta: [
|
||||
{ name: 'theme-color', content: '#ea580c' },
|
||||
{ name: 'apple-mobile-web-app-capable', content: 'yes' },
|
||||
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
|
||||
{ name: 'apple-mobile-web-app-title', content: 'Splitt' },
|
||||
],
|
||||
},
|
||||
},
|
||||
vite: {
|
||||
plugins: [tailwindcss()],
|
||||
},
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "Splitt the Bill",
|
||||
"short_name": "Splitt",
|
||||
"description": "Track shared costs with friends, the easy way.",
|
||||
"start_url": "/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#fff7ed",
|
||||
"theme_color": "#ea580c",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icon-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "/icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "/icon-maskable-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user