updated adding jurney

This commit is contained in:
2026-06-16 01:39:59 +09:00
parent 06e5fe5593
commit 65248fd082
5 changed files with 308 additions and 86 deletions

View File

@@ -1,7 +1,8 @@
<script>
import { get } from 'svelte/store';
import { journals, addJournal, updateJournal } from '../stores/journalStore.js';
import { getEntries } from '../stores/entriesStore.svelte.js';
import { addEntry, updateEntry } from '../stores/entriesStore.svelte.js';
import { countryNames } from '../shared/countries.js';
import { getCitiesForCountry, ALL_CITIES } from '../shared/cities.js';
import SearchInput from '../shared/SearchInput.svelte';
import PhotoEditor from './PhotoEditor.svelte';
@@ -58,10 +59,11 @@
}
// Suggest cities — when a country is selected show only cities from that country.
let allEntries = $derived(getEntries());
let cityOptions = $derived(
country.trim()
? [...new Set(get(journals).filter(j => (j.location.country || '').toLowerCase() === country.trim().toLowerCase()).flatMap(e => e.location.cities))].sort()
: [...new Set(get(journals).flatMap(e => e.location.cities))].sort()
? [...new Set([...getCitiesForCountry(country), ...allEntries.filter(j => (j.location.country || '').toLowerCase() === country.trim().toLowerCase()).flatMap(e => e.location.cities)])].sort()
: [...new Set([...Object.values(ALL_CITIES).flat(), ...allEntries.flatMap(e => e.location.cities)])].sort()
);
function addCity(val) {
@@ -89,7 +91,7 @@
try {
if (isNew) {
await addJournal({
await addEntry({
title: `${cities.join(', ')}, ${country}`,
date,
days: Number(days),
@@ -100,8 +102,7 @@
location: { cities, country },
});
} else {
await updateJournal({
...entry,
await updateEntry(entry.id, {
date,
days: Number(days),
tripType,
@@ -113,7 +114,7 @@
}
onBack();
} catch (err) {
showToast('Failed to save. Please try again.');
console.error('Save failed:', err);
}
}
</script>
@@ -240,7 +241,7 @@
align-items: center;
justify-content: space-between;
padding: 0 20px;
height: 52px;
height: 60px;
flex-shrink: 0;
border-bottom: 1px solid var(--border);
background: var(--bg);
@@ -255,8 +256,8 @@
.topbar-right { justify-content: flex-end; }
.topbar-title {
font-size: 14px;
font-weight: 400;
font-size: 16px;
font-weight: 500;
color: var(--text-h);
}
@@ -265,13 +266,13 @@
align-items: center;
gap: 6px;
font-family: var(--sans);
font-size: 13px;
font-weight: 300;
font-size: 15px;
font-weight: 400;
color: var(--text);
background: none;
border: 1px solid transparent;
border-radius: 8px;
padding: 6px 12px;
border-radius: 10px;
padding: 8px 14px;
cursor: pointer;
transition: background 0.15s, color 0.15s, border-color 0.15s;
white-space: nowrap;