Skip to content

Commit

Permalink
Merge pull request #195 from seanmorley15/development
Browse files Browse the repository at this point in the history
Make public from creation modal
  • Loading branch information
seanmorley15 authored Aug 15, 2024
2 parents f846f46 + 132ad44 commit 36609c4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions frontend/src/lib/components/NewAdventure.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
let user_id = data[2];
let image_url = data[3];
let link = data[4];
if (newAdventure.is_public) {
navigator.clipboard.writeText(`${window.location.origin}/adventures/${id}`);
}
newAdventure.image = image_url;
newAdventure.id = id;
newAdventure.user_id = user_id;
Expand Down Expand Up @@ -370,6 +373,20 @@
class="input input-bordered w-full max-w-xs mt-1"
/>
</div>
<div class="mb-2">
<label for="is_public">Public <Earth class="inline-block -mt-1 mb-1 w-6 h-6" /></label><br
/>
<input
type="checkbox"
class="toggle toggle-primary"
id="is_public"
name="is_public"
bind:checked={newAdventure.is_public}
/>
</div>
{#if newAdventure.is_public}
<p>The link to this adventure will be copied to your clipboard once it is created!</p>
{/if}
<div class="mb-2">
<input
type="text"
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/routes/adventures/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ export const actions: Actions = {
let latitude = formData.get('latitude') as string | null;
let longitude = formData.get('longitude') as string | null;
let collection = formData.get('collection') as string | null;
let is_public = formData.get('is_public') as string | null | boolean;

if (is_public) {
is_public = true;
} else {
is_public = false;
}

// check if latitude and longitude are valid
if (latitude && longitude) {
Expand Down Expand Up @@ -127,6 +134,7 @@ export const actions: Actions = {
formDataToSend.append('description', description || '');
formDataToSend.append('latitude', latitude || '');
formDataToSend.append('longitude', longitude || '');
formDataToSend.append('is_public', is_public.toString());

if (!isNaN(Number(collection))) {
if (collection !== null) {
Expand Down

0 comments on commit 36609c4

Please sign in to comment.