mirror of
https://github.com/jcreek/LivingDexTracker.git
synced 2026-07-13 02:53:45 +00:00
feat(*): Enable automatic saving
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
function save() {
|
function updateCatchRecord() {
|
||||||
dispatch('updateCatch', { pokedexEntry, catchRecord });
|
dispatch('updateCatch', { pokedexEntry, catchRecord });
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -83,6 +83,7 @@
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
bind:checked={catchRecord.caught}
|
bind:checked={catchRecord.caught}
|
||||||
class="checkbox checkbox-primary border-black"
|
class="checkbox checkbox-primary border-black"
|
||||||
|
on:change={updateCatchRecord}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -95,6 +96,7 @@
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
bind:checked={catchRecord.haveToEvolve}
|
bind:checked={catchRecord.haveToEvolve}
|
||||||
class="checkbox checkbox-primary border-black"
|
class="checkbox checkbox-primary border-black"
|
||||||
|
on:change={updateCatchRecord}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -107,6 +109,7 @@
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
bind:checked={catchRecord.inHome}
|
bind:checked={catchRecord.inHome}
|
||||||
class="checkbox checkbox-primary border-black"
|
class="checkbox checkbox-primary border-black"
|
||||||
|
on:change={updateCatchRecord}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -120,6 +123,7 @@
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
bind:checked={catchRecord.hasGigantamaxed}
|
bind:checked={catchRecord.hasGigantamaxed}
|
||||||
class="checkbox checkbox-primary border-black"
|
class="checkbox checkbox-primary border-black"
|
||||||
|
on:change={updateCatchRecord}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -133,6 +137,7 @@
|
|||||||
bind:value={catchRecord.personalNotes}
|
bind:value={catchRecord.personalNotes}
|
||||||
id={`personalNotesInput-${catchRecord._id}`}
|
id={`personalNotesInput-${catchRecord._id}`}
|
||||||
class="form-textarea w-full p-2 border rounded"
|
class="form-textarea w-full p-2 border rounded"
|
||||||
|
on:change={updateCatchRecord}
|
||||||
></textarea>
|
></textarea>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -152,9 +157,6 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="bg-white text-black rounded-lg p-4">
|
|
||||||
<button on:click={save}>Save</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateACatch(catchRecord: CatchRecord) {
|
async function updateACatch(event: any) {
|
||||||
|
const { catchRecord } = event.detail;
|
||||||
if (!localUser?.id) {
|
if (!localUser?.id) {
|
||||||
alert('User not signed in');
|
alert('User not signed in');
|
||||||
return;
|
return;
|
||||||
@@ -73,11 +74,9 @@
|
|||||||
try {
|
try {
|
||||||
const response = await fetch('/api/catch-records', requestOptions);
|
const response = await fetch('/api/catch-records', requestOptions);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
alert('Failed to update catch record');
|
||||||
throw new Error('Failed to update catch record');
|
throw new Error('Failed to update catch record');
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatedRecord = await response.json();
|
|
||||||
console.log('Updated catch record:', updatedRecord);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating catch record:', error);
|
console.error('Error updating catch record:', error);
|
||||||
}
|
}
|
||||||
@@ -177,7 +176,7 @@
|
|||||||
{showOrigins}
|
{showOrigins}
|
||||||
{showForms}
|
{showForms}
|
||||||
bind:catchRecord
|
bind:catchRecord
|
||||||
on:updateCatch={() => updateACatch(catchRecord)}
|
on:updateCatch={updateACatch}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
{:else if failedToLoad}
|
{:else if failedToLoad}
|
||||||
|
|||||||
Reference in New Issue
Block a user