Bug fixes

This commit is contained in:
sairaj mote 2024-02-08 04:03:27 +05:30
parent 75684cd4ef
commit f08bafc079
4 changed files with 59 additions and 47 deletions

View File

@ -48,7 +48,7 @@
<div class="flex-column flex-1 gap-0-3"> <div class="flex-column flex-1 gap-0-3">
<label class="label" for="task_popup__category">Category*</label> <label class="label" for="task_popup__category">Category*</label>
<sm-chips name="category" id="task_popup__category" class="flex-1" multiline> <sm-chips name="category" id="task_popup__category" class="flex-1" multiline>
<sm-chip value="c00" selected="">Creative Writing</sm-chip> <sm-chip value="c00" selected>Creative Writing</sm-chip>
<sm-chip value="c01">Marketing</sm-chip> <sm-chip value="c01">Marketing</sm-chip>
<sm-chip value="c02">Design</sm-chip> <sm-chip value="c02">Design</sm-chip>
<sm-chip value="c03">Development</sm-chip> <sm-chip value="c03">Development</sm-chip>

View File

@ -695,6 +695,7 @@ async function saveTask() {
task.date = Date.now(); task.date = Date.now();
floGlobals.appObjects.rmInterns.tasks.unshift(task) floGlobals.appObjects.rmInterns.tasks.unshift(task)
} }
buttonLoader('task_popup__submit', true)
floCloudAPI.updateObjectData('rmInterns') floCloudAPI.updateObjectData('rmInterns')
.then(response => { .then(response => {
notify('Task saved successfully', 'success') notify('Task saved successfully', 'success')
@ -704,6 +705,7 @@ async function saveTask() {
notify('An error occurred while saving the task', 'error') notify('An error occurred while saving the task', 'error')
console.error(e) console.error(e)
}).finally(() => { }).finally(() => {
buttonLoader('task_popup__submit', false)
closePopup() closePopup()
}) })
} }
@ -741,7 +743,7 @@ const render = {
actions = html` actions = html`
<button class="button button--outlined" onclick=${() => editTask(id)}>Edit</button> <button class="button button--outlined" onclick=${() => editTask(id)}>Edit</button>
<button class="button button--outlined" onclick=${() => deleteTask(id)}>Delete</button> <button class="button button--outlined" onclick=${() => deleteTask(id)}>Delete</button>
<a href=${`#/task?id=${id}`} class="button button--outlined margin-left-auto">${floGlobals.applications[id].size} applied</a> <a href=${`#/task?id=${id}`} class="button button--outlined margin-left-auto">${floGlobals.applications[id]?.size || 0} applied</a>
` `
} else if (!floGlobals.isAdmin) { } else if (!floGlobals.isAdmin) {
const applied = floGlobals.applications.has(id) const applied = floGlobals.applications.has(id)
@ -749,6 +751,9 @@ const render = {
<button class=${`button ${applied ? '' : 'button--outlined'}`} data-task-id=${id} onclick=${() => applyToTask(id)} ?disabled=${applied}>${applied ? 'Applied' : 'Apply'}</button> <button class=${`button ${applied ? '' : 'button--outlined'}`} data-task-id=${id} onclick=${() => applyToTask(id)} ?disabled=${applied}>${applied ? 'Applied' : 'Apply'}</button>
` `
} }
} else {
actions = html`<a href=${`#/sign_in`} class="button button--outlined margin-left-auto">Apply</a>`
floGlobals.applyingForTask = id;
} }
return html` return html`
<li class="task-card" .dataset=${{ id }}> <li class="task-card" .dataset=${{ id }}>
@ -788,8 +793,9 @@ const router = new Router({
} }
} }
}) })
const header = (page) => { const header = () => {
const isUserLoggedIn = page === 'loading' || floGlobals.isUserLoggedIn const { page } = router.state
const isUserLoggedIn = page === 'loading' || floGlobals.isUserLoggedIn;
return html` return html`
<header id="main_header" class="flex align-center gap-1"> <header id="main_header" class="flex align-center gap-1">
<a href="#/"> <a href="#/">
@ -798,8 +804,8 @@ const header = (page) => {
<theme-toggle class="margin-left-auto"></theme-toggle> <theme-toggle class="margin-left-auto"></theme-toggle>
${isUserLoggedIn ? html`` : html` ${isUserLoggedIn ? html`` : html`
<div class="flex gap-0-5"> <div class="flex gap-0-5">
<a class="button button--outlined" href="#/sign_up">Get Started</a> ${page !== 'sign_up' ? html`<a class="button button--outlined" href="#/sign_up">Get Started</a>` : ''}
<a class="button button--primary" href="#/sign_in">Sign in</a> ${page !== 'sign_in' ? html`<a class="button button--primary" href="#/sign_in">Sign in</a>` : ''}
</div> </div>
`} `}
</header> </header>
@ -808,7 +814,7 @@ const header = (page) => {
router.addRoute('loading', (state) => { router.addRoute('loading', (state) => {
renderElem(getRef('app_body'), html` renderElem(getRef('app_body'), html`
<article id="loading"> <article id="loading">
${header('loading')} ${header()}
<section class="grid justify-content-center"> <section class="grid justify-content-center">
<sm-spinner></sm-spinner> <sm-spinner></sm-spinner>
<div class="grid gap-1 justify-items-center"> <div class="grid gap-1 justify-items-center">
@ -823,7 +829,7 @@ router.addRoute('landing', (state) => {
const { page } = state; const { page } = state;
renderElem(getRef('app_body'), html` renderElem(getRef('app_body'), html`
<article id="landing"> <article id="landing">
${header(page)} ${header()}
<section class="flex flex-wrap"> <section class="flex flex-wrap">
<div> <div>
<h1 class="grid"> <h1 class="grid">
@ -951,21 +957,26 @@ function renderHome(state) {
getRef('task_popup__title').textContent = 'Add Task'; getRef('task_popup__title').textContent = 'Add Task';
render.availableTasks() render.availableTasks()
} else { } else {
renderElem(getRef('app_body'), html` if (floGlobals.applyingForTask) {
<article id="home"> applyToTask(floGlobals.applyingForTask)
${header()} floGlobals.applyingForTask = null;
<section class="grid gap-1"> } else {
<h2>Home</h2> renderElem(getRef('app_body'), html`
<div class="flex flex-direction-column gap-1-5"> <article id="home">
<h4>Available</h4> ${header()}
<ul id="available_tasks_list" class="grid"> <section class="grid gap-1">
<sm-spinner></sm-spinner> <h2>Home</h2>
</ul> <div class="flex flex-direction-column gap-1-5">
</div> <h4>Available</h4>
</section> <ul id="available_tasks_list" class="grid">
</article> <sm-spinner></sm-spinner>
`) </ul>
render.availableTasks() </div>
</section>
</article>
`)
render.availableTasks()
}
} }
} }
@ -1215,3 +1226,4 @@ window.addEventListener("load", () => {
// handle task deadlines // handle task deadlines
// should we allow users to apply for multiple tasks? // should we allow users to apply for multiple tasks?
// Add icons to the task categories // Add icons to the task categories
// handle applicants data securely (encrypted) and allow sub-admins to view them

44
scripts/app.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long