Skip to content

Commit

Permalink
rename list prop to taskList, pass it down to Task #101
Browse files Browse the repository at this point in the history
no change in functionality
  • Loading branch information
blahosyl committed Aug 12, 2024
1 parent c7ba4e4 commit 6d3a3a9
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function App() {
exact
path="/tabs"
render={() => (
<TaskTabs list message="No results found. Adjust the search keyword." />
<TaskTabs taskList message="No results found. Adjust the search keyword." />
)}
/>
<Route
Expand Down
1 change: 1 addition & 0 deletions src/pages/tasks/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const Task = (props) => {
watched_id,
watchers_count,
taskDetail,
taskList,
setTasks,
} = props;

Expand Down
20 changes: 16 additions & 4 deletions src/pages/tasks/TaskKanban.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import NoResults from "../../assets/no-results.png";
import { useCurrentUser } from "../../contexts/CurrentUserContext";
import { Link } from "react-router-dom/cjs/react-router-dom.min";

function TaskKanban({ message, filter = "" }) {
function TaskKanban({ message, filter = "", taskList }) {
const [tasks, setTasks] = useState({ results: [] });
const [hasLoaded, setHasLoaded] = useState(false);
const { pathname } = useLocation();
Expand Down Expand Up @@ -93,7 +93,11 @@ function TaskKanban({ message, filter = "" }) {
children={tasks.results.map(
(task) =>
task.status === "TO-DO" && (
<Task key={task.id} {...task} setTasks={setTasks} />
<Task
key={task.id} {...task}
setTasks={setTasks}
taskList={taskList}
/>
)
)}
dataLength={tasks.results.length}
Expand All @@ -119,7 +123,11 @@ function TaskKanban({ message, filter = "" }) {
children={tasks.results.map(
(task) =>
task.status === "IN-PROGRESS" && (
<Task key={task.id} {...task} setTasks={setTasks} />
<Task
key={task.id} {...task}
setTasks={setTasks}
taskList={taskList}
/>
)
)}
dataLength={tasks.results.length}
Expand All @@ -145,7 +153,11 @@ function TaskKanban({ message, filter = "" }) {
children={tasks.results.map(
(task) =>
task.status === "DONE" && (
<Task key={task.id} {...task} setTasks={setTasks} />
<Task
key={task.id} {...task}
setTasks={setTasks}
taskList={taskList}
/>
)
)}
dataLength={tasks.results.length}
Expand Down
8 changes: 6 additions & 2 deletions src/pages/tasks/TaskList.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import NoResults from "../../assets/no-results.png";
// import ProfileList from "../profiles/ProfileList";
import { useCurrentUser } from "../../contexts/CurrentUserContext";

function TaskList({ message, filter = "" }) {
function TaskList({ message, filter = "" , taskList}) {
const [tasks, setTasks] = useState({ results: [] });
const [hasLoaded, setHasLoaded] = useState(false);
const { pathname } = useLocation();
Expand Down Expand Up @@ -69,7 +69,11 @@ function TaskList({ message, filter = "" }) {
{tasks.results.length ? (
<InfiniteScroll
children={tasks.results.map((task) => (
<Task key={task.id} {...task} setTasks={setTasks} />
<Task
key={task.id} {...task}
setTasks={setTasks}
taskList={taskList}
/>
))}
dataLength={tasks.results.length}
loader={<Asset spinner />}
Expand Down
14 changes: 10 additions & 4 deletions src/pages/tasks/TaskTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import { axiosReq } from "../../api/axiosDefaults";

function TaskTabs(props) {
const {
list
taskList
} = props;
const TaskComponent = list ? TaskList : TaskKanban
const TaskComponent = taskList ? TaskList : TaskKanban

const currentUser = useCurrentUser();
const profile_id = currentUser?.profile_id || "";
Expand Down Expand Up @@ -57,6 +57,7 @@ function TaskTabs(props) {
`}
>
<TaskComponent
taskList={taskList}
message="No results found. Adjust the search keyword assign a task to yourself."
filter={`assignee__profile=${profile_id}&ordering=-updated_at&`}
/>
Expand All @@ -69,6 +70,7 @@ function TaskTabs(props) {
`}
>
<TaskComponent
taskList={taskList}
message="No results found. Adjust the search keyword or watch a task."
filter={`watched__owner__profile=${profile_id}&ordering=-watchers__created_at&`}
/>
Expand All @@ -81,6 +83,7 @@ function TaskTabs(props) {
`}
>
<TaskComponent
taskList={taskList}
message="No results found. Adjust the search keyword or create a task."
filter={`owner__profile=${profile_id}&ordering=-created_at&`}
/>
Expand All @@ -91,11 +94,14 @@ function TaskTabs(props) {
All tasks
`}
>
<TaskComponent message="No results found. Adjust the search keyword." />
<TaskComponent
taskList={taskList}
message="No results found. Adjust the search keyword."
/>
</Tab>
</Tabs>
</Col>
{list && (<Col md={4} className="d-none d-lg-block p-0 p-lg-2">
{taskList && (<Col md={4} className="d-none d-lg-block p-0 p-lg-2">
<ProfileList />
</Col>)}
</Row>
Expand Down

0 comments on commit 6d3a3a9

Please sign in to comment.