Add react-ios-time-picker package and fix merge

conflict in PieChart component
This commit is contained in:
Pattadon 2023-11-27 14:24:59 +07:00
parent 8f2e64b5e0
commit 00c68538fc
5 changed files with 102 additions and 43 deletions

View File

@ -46,6 +46,7 @@
"react-datetime-picker": "^5.5.3",
"react-dom": "^18.2.0",
"react-icons": "^4.11.0",
"react-ios-time-picker": "^0.2.2",
"react-router-dom": "^6.18.0",
"react-tsparticles": "^2.12.2",
"tsparticles": "^2.12.0"

View File

@ -1,9 +1,5 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
dependencies:
'@dnd-kit/core':
specifier: ^6.1.0
@ -113,6 +109,9 @@ dependencies:
react-icons:
specifier: ^4.11.0
version: 4.12.0(react@18.2.0)
react-ios-time-picker:
specifier: ^0.2.2
version: 0.2.2(react-dom@18.2.0)(react@18.2.0)
react-router-dom:
specifier: ^6.18.0
version: 6.19.0(react-dom@18.2.0)(react@18.2.0)
@ -3573,6 +3572,17 @@ packages:
react: 18.2.0
dev: false
/react-ios-time-picker@0.2.2(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-bi+K23lK6Pf2xDXmhAlz+RJuy9/onWYi7Ye+ODVhIkis9AVFECOza2ckkZl/4vUypj2+TdTsHn+VZrTNdGIwDQ==}
peerDependencies:
react: ^18.2.0
react-dom: ^18.2.0
dependencies:
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
react-portal: 4.2.2(react-dom@18.2.0)(react@18.2.0)
dev: false
/react-is@16.13.1:
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
@ -3612,6 +3622,17 @@ packages:
warning: 4.0.3
dev: false
/react-portal@4.2.2(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-vS18idTmevQxyQpnde0Td6ZcUlv+pD8GTyR42n3CHUQq9OHi1C4jDE4ZWEbEsrbrLRhSECYiao58cvocwMtP7Q==}
peerDependencies:
react: ^16.0.0-0 || ^17.0.0-0 || ^18.0.0-0
react-dom: ^16.0.0-0 || ^17.0.0-0 || ^18.0.0-0
dependencies:
prop-types: 15.8.1
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
dev: false
/react-redux@7.2.9(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-Gx4L3uM182jEEayZfRbI/G11ZpYdNAnBs70lFVMNdHJI76XYtR+7m0MN+eAs7UHBPhWXcnFPaS+9owSCJQHNpQ==}
peerDependencies:
@ -4663,3 +4684,7 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
dev: true
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false

View File

@ -13,11 +13,7 @@ export function DonutChartGraph() {
const completedTask = response.data.total_completed_tasks || 0;
const donutData = [
<<<<<<< HEAD
{ name: "Completed task", count: completedTask },
=======
{ name: "Completed task", count: completedTask},
>>>>>>> 4a3f253e3049f97ef4479dd423642897a56e13fc
{ name: "Total task", count: totalTask },
];

View File

@ -60,7 +60,7 @@ export function TaskCard({ task, deleteTask, updateTask }) {
// Due Date
const dueDateTag =
task.end_event && new Date(task.end_event) > new Date()
? (() => {
? (() => {
const daysUntilDue = Math.ceil((new Date(task.end_event) - new Date()) / (1000 * 60 * 60 * 24));
let colorClass =
@ -139,23 +139,6 @@ export function TaskCard({ task, deleteTask, updateTask }) {
onMouseLeave={() => {
setMouseIsOver(false);
}}>
<<<<<<< HEAD
<p
className={`p-2.5 my-auto w-full overflow-y-auto overflow-x-hidden whitespace-pre-wrap rounded-xl shadow bg-white`}
onClick={() => document.getElementById(`task_detail_modal_${task.id}`).showModal()}>
{task.content}
</p>
{mouseIsOver && (
<button
onClick={() => {
deleteTask(task.id);
}}
className="stroke-white absolute right-0 top-1/2 rounded-full bg-white -translate-y-1/2 bg-columnBackgroundColor p-2 hover:opacity-100 ">
<BsFillTrashFill />
</button>
)}
=======
{/* -------- Task Content -------- */}
{/* Tags */}
{tags}
@ -183,7 +166,6 @@ export function TaskCard({ task, deleteTask, updateTask }) {
{dueDateTag}
{subtaskCountTag}
</div>
>>>>>>> 4a3f253e3049f97ef4479dd423642897a56e13fc
</div>
</div>
);

View File

@ -3,9 +3,21 @@ import { FaTasks, FaRegListAlt } from "react-icons/fa";
import { FaPlus } from "react-icons/fa6";
import { TbChecklist } from "react-icons/tb";
import DatePicker from "react-datepicker";
import { TimePicker } from "react-ios-time-picker";
import "react-datepicker/dist/react-datepicker.css";
import { borderColor } from "@mui/system";
export function TaskDetailModal({ title, description, tags, difficulty, challenge, importance, taskId, updateTask }) {
export function TaskDetailModal({
title,
description,
tags,
difficulty,
challenge,
importance,
taskId,
updateTask,
}) {
let date = new Date();
const [isChallengeChecked, setChallengeChecked] = useState(challenge);
const [isImportantChecked, setImportantChecked] = useState(importance);
const [currentDifficulty, setCurrentDifficulty] = useState(difficulty);
@ -15,7 +27,11 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
const [startDateEnabled, setStartDateEnabled] = useState(false);
const [endDateEnabled, setEndDateEnabled] = useState(false);
const [isTaskComplete, setTaskComplete] = useState(false);
const [value, setValue] = useState('10:00');
const onChange = (timeValue) => {
setValue(timeValue);
};
const handleChallengeChange = () => {
setChallengeChecked(!isChallengeChecked);
};
@ -30,7 +46,11 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
const handleTagChange = (tag) => {
const isSelected = selectedTags.includes(tag);
setSelectedTags(isSelected ? selectedTags.filter((selectedTag) => selectedTag !== tag) : [...selectedTags, tag]);
setSelectedTags(
isSelected
? selectedTags.filter((selectedTag) => selectedTag !== tag)
: [...selectedTags, tag]
);
};
const handleStartDateChange = () => {
@ -59,7 +79,8 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
const existingTags = tags.map((tag, index) => (
<div
key={index}
className={`text-xs inline-flex items-center font-bold leading-sm uppercase px-2 py-1 bg-${tag.color}-200 text-${tag.color}-700 rounded-full`}>
className={`text-xs inline-flex items-center font-bold leading-sm uppercase px-2 py-1 bg-${tag.color}-200 text-${tag.color}-700 rounded-full`}
>
{tag.label}
</div>
));
@ -68,7 +89,8 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
const selectedTagElements = selectedTags.map((tag, index) => (
<div
key={index}
className={`text-xs inline-flex items-center font-bold leading-sm uppercase px-2 py-1 bg-${tag.color}-200 text-${tag.color}-700 rounded-full`}>
className={`text-xs inline-flex items-center font-bold leading-sm uppercase px-2 py-1 bg-${tag.color}-200 text-${tag.color}-700 rounded-full`}
>
{tag.label}
</div>
));
@ -92,10 +114,16 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
<div className="flex flex-col py-2 pb-4">
<div className="flex flex-row space-x-5">
<div className="dropdown">
<label tabIndex={0} className="btn-md border-2 rounded-xl m-1 py-1">
<label
tabIndex={0}
className="btn-md border-2 rounded-xl m-1 py-1"
>
+ Add Tags
</label>
<ul tabIndex={0} className="dropdown-content z-[10] menu p-2 shadow bg-base-100 rounded-box w-52">
<ul
tabIndex={0}
className="dropdown-content z-[10] menu p-2 shadow bg-base-100 rounded-box w-52"
>
{tags.map((tag, index) => (
<li key={index}>
<label className="cursor-pointer space-x-2">
@ -127,10 +155,14 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
<input
type="checkbox"
checked={startDateEnabled}
className="checkbox checkbox-xs"
className="checkbox checkbox-xs bg-black"
onChange={handleStartDateChange}
/>
<div className={`rounded p-2 shadow border-2 ${!startDateEnabled && "opacity-50"}`}>
<div
className={`rounded p-2 shadow border-2 ${
!startDateEnabled && "opacity-50"
}`}
>
<DatePicker
selected={dateStart}
onChange={(date) => setDateStart(date)}
@ -138,6 +170,15 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
/>
</div>
</div>
</div>
<div className="rounded p-2 shadow border-2">
<TimePicker
value={value}
onChange={onChange}
className="rounded p-2 shadow border-2 z-[10000] relative"
/>
</div>
{/* Complete? */}
<div className="mx-4">
@ -147,7 +188,7 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
<input
type="checkbox"
checked={isTaskComplete}
className="checkbox checkbox-xl"
className="checkbox checkbox-xl bg-black"
onChange={handleTaskCompleteChange}
/>
</div>
@ -161,11 +202,19 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
<input
type="checkbox"
checked={endDateEnabled}
className="checkbox checkbox-xs"
className="checkbox checkbox-xs bg-black"
onChange={handleEndDateChange}
/>
<div className={`rounded p-2 shadow border-2 ${!endDateEnabled && "opacity-50"}`}>
<DatePicker selected={dateEnd} onChange={(date) => setDateEnd(date)} disabled={!endDateEnabled} />
<div
className={`rounded p-2 shadow border-2 ${
!endDateEnabled && "opacity-50"
}`}
>
<DatePicker
selected={dateEnd}
onChange={(date) => setDateEnd(date)}
disabled={!endDateEnabled}
/>
</div>
</div>
</div>
@ -211,7 +260,7 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
<input
type="checkbox"
checked={isChallengeChecked}
className="checkbox"
className="checkbox bg-black"
onChange={handleChallengeChange}
/>
</label>
@ -226,7 +275,7 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
<input
type="checkbox"
checked={isImportantChecked}
className="checkbox"
className="checkbox bg-black"
onChange={handleImportantChange}
/>
</label>
@ -242,7 +291,11 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
</span>
</h2>
<div className="flex space-x-3 pt-2">
<input type="text" placeholder="subtask topic" className="input input-bordered flex-1 w-full" />
<input
type="text"
placeholder="subtask topic"
className="input input-bordered flex-1 w-full"
/>
<button className="btn">
<FaPlus />
Add Subtask
@ -250,7 +303,9 @@ export function TaskDetailModal({ title, description, tags, difficulty, challeng
</div>
</div>
<form method="dialog">
<button className="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">X</button>
<button className="btn btn-sm btn-circle btn-ghost absolute right-2 top-2">
X
</button>
</form>
</div>
</dialog>