From ba149d0e963c1927248e532ba18055018a52d218 Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Sat, 1 Feb 2025 01:51:20 -0500 Subject: [PATCH] Make label Clickable Fix changing URL for selfhosted Update styling for calendar and thingview --- src/utils/TokenManager.jsx | 1 + src/views/Authorization/LoginSettings.jsx | 214 ++++++++++------------ src/views/Authorization/LoginView.jsx | 38 ++-- src/views/ChoreEdit/ChoreView.jsx | 1 + src/views/Chores/ChoreCard.jsx | 60 +++--- src/views/Chores/MyChores.jsx | 2 +- src/views/Chores/Sidepanel.jsx | 2 +- src/views/Things/ThingsView.jsx | 10 +- src/views/components/AddTaskModal.jsx | 7 + src/views/components/CalendarView.jsx | 2 +- 10 files changed, 171 insertions(+), 166 deletions(-) diff --git a/src/utils/TokenManager.jsx b/src/utils/TokenManager.jsx index d33467c..41751d1 100644 --- a/src/utils/TokenManager.jsx +++ b/src/utils/TokenManager.jsx @@ -25,6 +25,7 @@ class ApiManager { } updateApiURL(url) { this.customServerURL = url + this.init() } } diff --git a/src/views/Authorization/LoginSettings.jsx b/src/views/Authorization/LoginSettings.jsx index 6d97186..22cde4c 100644 --- a/src/views/Authorization/LoginSettings.jsx +++ b/src/views/Authorization/LoginSettings.jsx @@ -1,36 +1,26 @@ -import GoogleIcon from '@mui/icons-material/Google' +import { Preferences } from '@capacitor/preferences' import { - Avatar, Box, Button, Container, - Divider, - IconButton, Input, Sheet, Snackbar, Typography, } from '@mui/joy' import React from 'react' -import { LoginSocialGoogle } from 'reactjs-social-login' -import { API_URL, GOOGLE_CLIENT_ID, REDIRECT_URL } from '../../Config' -import Logo from '../../Logo' -import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth'; -import { Capacitor } from '@capacitor/core' -import { Settings } from '@mui/icons-material' import { useNavigate } from 'react-router-dom' -import { Preferences } from '@capacitor/preferences' - - - +import { API_URL } from '../../Config' +import Logo from '../../Logo' +import { apiManager } from '../../utils/TokenManager' const LoginSettings = () => { const [error, setError] = React.useState(null) const Navigate = useNavigate() - + const [serverURL, setServerURL] = React.useState('') React.useEffect(() => { - Preferences.get({ key: 'customServerUrl' }).then((result) => { + Preferences.get({ key: 'customServerUrl' }).then(result => { setServerURL(result.value || API_URL) }) }, []) @@ -38,13 +28,9 @@ const LoginSettings = () => { const isValidServerURL = () => { return serverURL.match(/^(http|https):\/\/[^ "]+$/) } - - return ( - + return ( + { sx={{ mt: 1, width: '100%', - + display: 'flex', flexDirection: 'column', alignItems: 'center', @@ -67,103 +53,101 @@ const LoginSettings = () => { boxShadow: 'md', }} > - + - - Done - - tick - - + + Done + + tick + + + + Server URL + + { + setServerURL(e.target.value) + }} + /> - - - - - Server URL - - { - setServerURL(e.target.value) - }} - /> - - - Change the server URL to connect to a different server, such as your own self-hosted Donetick server. - - - Please ensure to include the protocol (http:// or https://) and the port number if necessary (default Donetick port is 2021). - - - + Preferences.set({ + key: 'customServerUrl', + value: serverURL, + }).then(() => { + apiManager.updateApiURL(serverURL + '/api/v1') + Navigate('/login') + }) + }} + > + Save + + { boxShadow: 'md', }} > - { - Navigate('/login/settings') - }} - > - {' '} - - - {/* logo */} + {Capacitor.isNativePlatform() && ( + { + Navigate('/login/settings') + }} + > + {' '} + + + )} diff --git a/src/views/ChoreEdit/ChoreView.jsx b/src/views/ChoreEdit/ChoreView.jsx index 2ce44fd..d28d08a 100644 --- a/src/views/ChoreEdit/ChoreView.jsx +++ b/src/views/ChoreEdit/ChoreView.jsx @@ -435,6 +435,7 @@ const ChoreView = () => { sx={{ p: 2, borderRadius: 'lg', + mb: 1, }} > { return ( - { + e.stopPropagation() + onChipClick({ label: l }) }} - // onClick={e => { - // e.stopPropagation() - // onChipClick({ label: l }) - // }} - - // startDecorator={getIconForLabel(label)} + onKeyDown={e => { + if (e.key === 'Enter' || e.key === ' ') { + e.stopPropagation() + onChipClick({ label: l }) + } + }} + style={{ display: 'inline-block', cursor: 'pointer' }} // Make the wrapper clickable + key={`chorecard-${chore.id}-label-${l.id}`} > - {l?.name} - + { + // e.stopPropagation() + // onChipClick({ label: l }) + // }} + + // startDecorator={getIconForLabel(label)} + > + {l?.name} + + ) })} diff --git a/src/views/Chores/MyChores.jsx b/src/views/Chores/MyChores.jsx index 6cc5d87..b6e2aa2 100644 --- a/src/views/Chores/MyChores.jsx +++ b/src/views/Chores/MyChores.jsx @@ -426,7 +426,6 @@ const MyChores = () => { )} - { key={section.name + index} sx={{ my: 0, + px: 0, }} expanded={Boolean(openChoreSections[index])} > diff --git a/src/views/Chores/Sidepanel.jsx b/src/views/Chores/Sidepanel.jsx index e5947c0..3e15904 100644 --- a/src/views/Chores/Sidepanel.jsx +++ b/src/views/Chores/Sidepanel.jsx @@ -31,7 +31,7 @@ const Sidepanel = ({ chores }) => { } return ( diff --git a/src/views/components/AddTaskModal.jsx b/src/views/components/AddTaskModal.jsx index 7ed108c..7f856fe 100644 --- a/src/views/components/AddTaskModal.jsx +++ b/src/views/components/AddTaskModal.jsx @@ -21,6 +21,7 @@ import { CSSTransition } from 'react-transition-group' import { UserContext } from '../../contexts/UserContext' import useDebounce from '../../utils/Debounce' import { CreateChore } from '../../utils/Fetcher' +import { isPlusAccount } from '../../utils/Helpers' import { useLabels } from '../Labels/LabelQueries' import LearnMoreButton from './LearnMore' const VALID_DAYS = { @@ -429,16 +430,22 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => { assignedTo: userProfile.id, assignStrategy: 'random', isRolling: false, + notification: false, description: description || null, labelsV2: [], priority: priority || 0, status: 0, + frequencyType: 'once', } if (frequency) { chore.frequencyType = frequency.frequencyType chore.frequencyMetadata = frequency.frequencyMetadata chore.frequency = frequency.frequency + if (isPlusAccount()) { + chore.notification = true + chore.notificationMetadata = { dueDate: true } + } } CreateChore(chore).then(resp => { diff --git a/src/views/components/CalendarView.jsx b/src/views/components/CalendarView.jsx index 33ed5d4..154b723 100644 --- a/src/views/components/CalendarView.jsx +++ b/src/views/components/CalendarView.jsx @@ -124,7 +124,7 @@ const CalendarView = ({ chores }) => { .map((chore, idx) => ( { Navigate('/chores/' + chore.id) }}