1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-25 07:49:37 +02:00

Toggle public profile from settings page.

This commit is contained in:
Sean Morley 2024-09-08 13:53:50 -04:00
parent c867494a17
commit 4d17484f86
4 changed files with 32 additions and 4 deletions

View file

@ -1,5 +1,4 @@
export let appVersion = 'Web v0.6.0';
export let versionChangelog = 'https://github.com/seanmorley15/AdventureLog/releases/tag/v0.5.2';
export let versionChangelog = 'https://github.com/seanmorley15/AdventureLog/releases/tag/v0.6.0';
export let appTitle = 'AdventureLog';
export let copyrightYear = '2024';
// config for the frontend

View file

@ -45,6 +45,7 @@ export const actions: Actions = {
let first_name = formData.get('first_name') as string | null | undefined;
let last_name = formData.get('last_name') as string | null | undefined;
let profile_pic = formData.get('profile_pic') as File | null | undefined;
let public_profile = formData.get('public_profile') as string | null | undefined | boolean;
const resCurrent = await fetch(`${endpoint}/auth/user/`, {
headers: {
@ -56,6 +57,13 @@ export const actions: Actions = {
return fail(resCurrent.status, await resCurrent.json());
}
if (public_profile === 'on') {
public_profile = true;
} else {
public_profile = false;
}
console.log(public_profile);
let currentUser = (await resCurrent.json()) as User;
if (username === currentUser.username || !username) {
@ -84,6 +92,7 @@ export const actions: Actions = {
if (profile_pic) {
formDataToSend.append('profile_pic', profile_pic);
}
formDataToSend.append('public_profile', public_profile.toString());
let res = await fetch(`${endpoint}/auth/user/`, {
method: 'PATCH',

View file

@ -111,6 +111,24 @@
id="profile_pic"
class="file-input file-input-bordered w-full max-w-xs mb-2"
/><br />
<div class="form-control">
<div
class="tooltip tooltip-info"
data-tip="With a public profile, users can share collections with you and view your profile on the users page."
>
<label class="label cursor-pointer">
<span class="label-text">Public Profile</span>
<input
id="public_profile"
name="public_profile"
type="checkbox"
class="toggle"
checked={user.public_profile}
/>
</label>
</div>
</div>
<button class="py-2 mt-2 px-4 btn btn-primary">Update</button>
</form>
</div>