-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3540 from LiteFarmOrg/LF-4474-nice-to-have-conver…
…t-create-task-button-to-cta-floating-button LF-4474 [Nice to have] convert create task button to CTA floating button
- Loading branch information
Showing
7 changed files
with
119 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
|
||
.floatingActionButton { | ||
position: relative; | ||
z-index: 100; | ||
|
||
@media (hover: hover) { | ||
&:hover { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,14 @@ | ||
import React, { useState } from 'react'; | ||
import styles from './styles.module.scss'; | ||
import { AddLink } from '../../Typography'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useSelector } from 'react-redux'; | ||
import { locationsSelector } from '../../../containers/locationSlice'; | ||
import LocationCreationModal from '../../LocationCreationModal'; | ||
|
||
export default function TaskCount({ count, handleAddTask, isAdmin }) { | ||
export default function TaskCount({ count }) { | ||
const { t } = useTranslation(); | ||
const locations = useSelector(locationsSelector); | ||
const [createLocation, setCreateLocation] = useState(false); | ||
|
||
const dismissLocationCreationModal = () => { | ||
setCreateLocation(false); | ||
}; | ||
|
||
const handleClick = () => { | ||
if (locations.length) { | ||
handleAddTask(); | ||
} else { | ||
setCreateLocation(true); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={styles.taskCountContainer}> | ||
<div data-cy="tasks-taskCount" className={styles.taskCount}> | ||
{t('TASK.TASKS_COUNT', { count })} | ||
</div> | ||
<AddLink onClick={handleClick}>{t('TASK.ADD_TASK')}</AddLink> | ||
{createLocation && ( | ||
<LocationCreationModal | ||
title={t('LOCATION_CREATION.TASK_TITLE')} | ||
body={ | ||
isAdmin ? t('LOCATION_CREATION.TASK_BODY') : t('LOCATION_CREATION.TASK_BODY_WORKER') | ||
} | ||
dismissModal={dismissLocationCreationModal} | ||
isAdmin={isAdmin} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2024 LiteFarm.org | ||
* This file is part of LiteFarm. | ||
* | ||
* LiteFarm is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiteFarm is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
.ctaButtonWrapper { | ||
position: fixed; | ||
bottom: 16px; | ||
right: 16px; | ||
} |