Skip to content

Commit

Permalink
Fixed calendar bug, updated some data entry ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Wing committed Jan 21, 2025
1 parent 71f74a3 commit 3b2691e
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 41 deletions.
16 changes: 11 additions & 5 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@
import { instance as axios } from './axios'; // Import your configured Axios axios
import store from './store'; // Import the Vuex store to access sessionId and other state

function verify(){

}

// API call to create a new list
export async function createList(listData) {
const { sessionId } = store.state;

console.log(axios);

console.log("sessionId: "+sessionId);
//console.log(axios);

if (!sessionId) {
throw new Error('No session ID found. User may not be authenticated.');
}



try {
const response = await axios.post(
'/lists/',
listData,
{ headers: { 'Authorization': `Bearer ${sessionId}` } }
{ headers: { 'Authorization': `Bearer ${sessionId}` },
body: JSON.stringify(listData),
},
);
return response.data;
} catch (error) {
Expand Down
17 changes: 6 additions & 11 deletions src/components/CalendarComponents/DailyCalendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</template>

<script>
import {getTodayDate} from '../../date.js';
export default {
name: "DailyCalendar",
props: {
Expand All @@ -38,14 +39,12 @@ export default {
computed: {
combinedEvents() {
const today = this.getTodayDate();
const today = getTodayDate();
const events = [
...this.list1.map((event) => ({ ...event, listType: "list1" })),
...this.list2.map((event) => ({ ...event, listType: "list2" })),
];
console.log('Computed Combined Events:', events.filter((event) => event.scheduledDate === today));
return events.filter((event) => event.scheduledDate === today);
},
},
Expand All @@ -70,6 +69,8 @@ export default {
},
getEventStyle(event) {
console.log(event);
console.log(event.scheduledTime);
const startHour = this.parseTime(event.scheduledTime);
let endHour = startHour + event.taskTimeEstimate / 60;
Expand Down Expand Up @@ -98,16 +99,10 @@ export default {
this.$emit("event-clicked", { event, listType: event.listType, index });
},
getTodayDate() {
const today = new Date();
const year = today.getFullYear();
const month = (today.getMonth() + 1).toString().padStart(2, "0");
const day = today.getDate().toString().padStart(2, "0");
return `${year}-${month}-${day}`; // Format: YYYY-MM-DD
},
// Updated parseTime method to handle various formats like '2:00pm', '09:59am', '9:59am'
parseTime(time) {
if(time==null)
time=Date.now().toString();
const regex = /(\d{1,2}):(\d{2})(am|pm)/i;
const match = time.trim().match(regex);
if (!match) return 0; // Default if time format is invalid
Expand Down
7 changes: 3 additions & 4 deletions src/components/DashboardComponents/MultiplayerToggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<label class="slider-label">{{ label }}</label>
<div class="slider" @click="toggleSlider" :aria-checked="isChecked" role="switch">
<!--Needs to switch between an icon of one person and multiple -->
<div class="slider-tab" :class="{ 'slider-checked': isChecked }">{{ isChecked ? 'Yes' : 'No' }}</div>
<div class="slider-tab" :class="{ 'slider-checked': isChecked }">{{ isChecked ? Yes : No }}</div>
</div>
</div>
</template>
Expand All @@ -18,7 +18,7 @@ export default {
props: {
label: {
type: String,
default: 'Yes/No',
default: '',
},
modelValue: {
type: Boolean,
Expand All @@ -38,8 +38,7 @@ export default {
methods: {
emitSliderChange() {
this.$emit('update:modelValue', this.isChecked); // Emit for v-model binding
console.log("toggling");
},
},
toggleSlider() {
this.isChecked = !this.isChecked;
this.emitSliderChange(); // Emit the change
Expand Down
6 changes: 3 additions & 3 deletions src/components/ListItems/DateInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ export default {
}
.date-input {
background-color: #1e1e1e;
color: #cfcfcf;
border: 1px solid #4a4a4a;
background-color: #343541;
color: white;
border: 1px solid white;
border-radius: 4px;
padding: 8px;
width: 90%;
Expand Down
19 changes: 16 additions & 3 deletions src/components/ListItems/ListElement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">

<div class="template-container">
<div class="input-grid">
<div v-if="!multiplayer" class="input-grid">
<div class='title' :contenteditable="parentPage !== 'dashboard'" ref="titleInput" @keydown.enter.prevent=""
spellcheck="false">
{{ listName }}
Expand Down Expand Up @@ -79,6 +79,10 @@ export default {
listName: {
type: String,
required: false
},
multiplayer: {
type: Boolean,
required: false
}
},
data() {
Expand Down Expand Up @@ -128,6 +132,10 @@ export default {
},
mounted() {
},
unmounted(){
this.itemsArray.length = 0;
this.emitList();
},
components: {
DateInput,
Expand Down Expand Up @@ -176,6 +184,11 @@ export default {
saveList() {
//LATER Need to add some debounce time maybe 750 ms to only call the api once every 3/4s second and not spam the backend.
//LATER Should also do the async call to save to the backend
this.emitList();
},
emitList(){
this.$emit("update:modelValue", this.itemsArray);
},
newList() {
Expand All @@ -184,7 +197,7 @@ export default {
list_description: this.listDescription,
list_items: JSON.stringify([
{
item_description: "Example item",
item_description: "Exampleee item",
item_duration: 30,
recurring_item: false,
},
Expand Down Expand Up @@ -212,7 +225,7 @@ export default {
this.itemsArray.push(this.createTestItem("Bruh2"));
this.saveList();
//this.newList();
this.newList();
//Call api get and load initial list
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/ListItems/MinuteInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ export default {
}
.minute-input-field {
background-color: #1e1e1e;
background-color: #343541;
color: #cfcfcf;
border: 1px solid #4a4a4a;
border: 1px solid white;
border-radius: 4px;
padding: 8px;
width: 90%;
Expand Down
6 changes: 3 additions & 3 deletions src/components/ListItems/TimeInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ export default {
}
.time-input {
background-color: #1e1e1e;
color: #cfcfcf;
border: 1px solid #4a4a4a;
background-color: #343541;
color: white;
border: 1px solid white;
border-radius: 4px;
padding: 8px;
width: 80%;
Expand Down
2 changes: 1 addition & 1 deletion src/components/SidebarComponents/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
// { path: '/Lists', label: 'Lists' },
// { path: '/Learn', label: 'Learn' },
// { path: '/Type', label: 'Type' },
// { path: '/About-me', label: 'About Me' },
{ path: '/About-me', label: 'About Me' },
// { path: '/Settings', label: 'Settings' },
{ path: '/Login', label: 'Login' },
];
Expand Down
12 changes: 12 additions & 0 deletions src/date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


export function getTodayDate() {
const today = new Date();
const year = today.getFullYear();
const month = (today.getMonth() + 1).toString().padStart(2, "0");
const day = today.getDate().toString().padStart(2, "0");
return `${year}-${month}-${day}`; // Format: YYYY-MM-DD
}



6 changes: 6 additions & 0 deletions src/router/dashboardRoutes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import DashboardWorld from '../views/Dashboard.vue';
import AboutMe from '@/views/AboutMe.vue';

export default [
{
path: '/',
name: 'dashboard',
component: DashboardWorld,
},
{
path: '/about-me',
name: 'AboutMe',
component: AboutMe
},
];
3 changes: 1 addition & 2 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ const store = createStore({
},
mutations: {
SET_USER(state, user) {
console.log('User authenticated:', user);
state.user = user;
state.isAuthenticated = !!user;
},
LOGOUT(state) {
console.log('User logged out');
//console.log('User logged out');
state.user = null;
state.isAuthenticated = false;
state.sessionId = null;
Expand Down
13 changes: 6 additions & 7 deletions src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
<!-- Top row: Hero text and navigation buttons -->
<div class="top-row" :style="{ 'background-color': colors.sideBar }">
<div class="button-container">
<MultiplayerToggle />
<!-- <MultiplayerToggle v-model="isChecked" label="Multiplayer"/>-->
<!--Need to put these in a v-if is bound to the emits of multiplayer toggle-->
<div>
<div class="bigButton" id="previousDay" @click="decrementDay"
:style="{ 'background-color': colors.background }">Previous Day</div>
<!--<DateInput @date-selected="handleDueDateChange" :initialDate="currentDate"/>-->
<div class="bigButton" id="nextDay" :style="{ 'background-color': colors.background }">Next Day</div>
</div>
:style="{ 'background-color': colors.background }">&lt;&lt;</div>
<DateInput :style="{margin:'0px' }" @date-selected="handleDueDateChange" :initialDate="currentDate"/>
<div class="bigButton" id="nextDay" :style="{ 'background-color': colors.background }">>></div>
</div>
</div>

<div class="page-container" :style="{ 'background-color': colors.background }">
<div class="lists-container">
<ListElement listName="Backburner" v-model="backburner" />
<ListElement listName="Daily List" v-model="dailyList" />
<ListElement listName="Daily List" v-model="dailyList" :multiplayer="isChecked"/>
<DailyCalendar v-model:list1="backburner" v-model:list2="dailyList" />
</div>
</div>
Expand Down Expand Up @@ -48,6 +46,7 @@ export default {
dailyList: [],
backburner: [],
currentDate: 0,
isChecked: false,
};
},
watch: {
Expand Down
2 changes: 2 additions & 0 deletions src/views/cssViews/Dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ html, body {

.button-container {
display: flex;
flex-direction:row;
gap: 20px;
}

Expand All @@ -34,6 +35,7 @@ html, body {
cursor: pointer;
transition: background-color 0.3s;
user-select: none;
display:flex;
}

.bigButton:hover {
Expand Down

0 comments on commit 3b2691e

Please sign in to comment.