feat: priority select in calendar
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<html lang="ru">
|
<html lang="ru">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Антихвост</title>
|
<title>Антихвост</title>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ import {
|
|||||||
import { FunctionComponent } from "preact";
|
import { FunctionComponent } from "preact";
|
||||||
import { useEffect, useMemo, useState } from "preact/hooks";
|
import { useEffect, useMemo, useState } from "preact/hooks";
|
||||||
import { Calendar, CalendarDateTemplateEvent } from "primereact/calendar";
|
import { Calendar, CalendarDateTemplateEvent } from "primereact/calendar";
|
||||||
|
import { Dropdown } from "primereact/dropdown";
|
||||||
import { Nullable } from "primereact/ts-helpers";
|
import { Nullable } from "primereact/ts-helpers";
|
||||||
import { SubmitHandler, useForm } from "react-hook-form";
|
import { SubmitHandler, useForm } from "react-hook-form";
|
||||||
|
import { priorities } from "./profile_tasks";
|
||||||
import {
|
import {
|
||||||
IApiResponse,
|
IApiResponse,
|
||||||
IAPITag,
|
IAPITag,
|
||||||
@@ -31,6 +33,7 @@ import {
|
|||||||
ITaskForm,
|
ITaskForm,
|
||||||
IViewTagsResponse,
|
IViewTagsResponse,
|
||||||
} from "./profile_tasks.dto";
|
} from "./profile_tasks.dto";
|
||||||
|
import { DropdownStyles, selectedPriorityTemplate } from "./profile_tasks.prime.styles";
|
||||||
|
|
||||||
const calendarStyles = {
|
const calendarStyles = {
|
||||||
root: "inline-flex w-full relative",
|
root: "inline-flex w-full relative",
|
||||||
@@ -68,6 +71,7 @@ const ProfileCalendar: FunctionComponent = () => {
|
|||||||
const [subjectChoices, setSubjectChoices] = useState<IAPITag[]>([]);
|
const [subjectChoices, setSubjectChoices] = useState<IAPITag[]>([]);
|
||||||
const [taskTypeChoices, setTaskTypeChoices] = useState<IAPITag[]>([]);
|
const [taskTypeChoices, setTaskTypeChoices] = useState<IAPITag[]>([]);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
const [selectedPriority, setSelectedPriority] = useState(4);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@@ -171,6 +175,7 @@ const ProfileCalendar: FunctionComponent = () => {
|
|||||||
taskType: selectedTaskType,
|
taskType: selectedTaskType,
|
||||||
dateTime_due: formattedDate,
|
dateTime_due: formattedDate,
|
||||||
telegram_notifications: false,
|
telegram_notifications: false,
|
||||||
|
priority: selectedPriority,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!editContent) {
|
if (!editContent) {
|
||||||
@@ -254,6 +259,7 @@ const ProfileCalendar: FunctionComponent = () => {
|
|||||||
setIsEdit(true);
|
setIsEdit(true);
|
||||||
setEditContent(task);
|
setEditContent(task);
|
||||||
setCalendarDate(task.date);
|
setCalendarDate(task.date);
|
||||||
|
setSelectedPriority(task.priority);
|
||||||
setIsEditModal(false);
|
setIsEditModal(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch task details:", error);
|
console.error("Failed to fetch task details:", error);
|
||||||
@@ -403,6 +409,7 @@ const ProfileCalendar: FunctionComponent = () => {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
setIsEdit(false);
|
setIsEdit(false);
|
||||||
setEditContent(null);
|
setEditContent(null);
|
||||||
|
setSelectedPriority(4);
|
||||||
setIsEditModal(false);
|
setIsEditModal(false);
|
||||||
setTags({ first: 0, second: 0, overdue: false });
|
setTags({ first: 0, second: 0, overdue: false });
|
||||||
setCalendarDate(null);
|
setCalendarDate(null);
|
||||||
@@ -530,6 +537,15 @@ const ProfileCalendar: FunctionComponent = () => {
|
|||||||
{editContent.taskType.name}
|
{editContent.taskType.name}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<Dropdown
|
||||||
|
disabled={!isEditModal}
|
||||||
|
pt={DropdownStyles}
|
||||||
|
options={priorities}
|
||||||
|
value={selectedPriority}
|
||||||
|
onChange={(e) => setSelectedPriority(e.value)}
|
||||||
|
itemTemplate={selectedPriorityTemplate}
|
||||||
|
valueTemplate={selectedPriorityTemplate}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import {
|
|||||||
import classes from "./profile_tasks.module.scss";
|
import classes from "./profile_tasks.module.scss";
|
||||||
import { DropdownStyles, selectedPriorityTemplate } from "./profile_tasks.prime.styles";
|
import { DropdownStyles, selectedPriorityTemplate } from "./profile_tasks.prime.styles";
|
||||||
|
|
||||||
const priorities: SelectItem[] = [
|
export const priorities: SelectItem[] = [
|
||||||
{ label: "Приоритет 1", value: 1 },
|
{ label: "Приоритет 1", value: 1 },
|
||||||
{ label: "Приоритет 2", value: 2 },
|
{ label: "Приоритет 2", value: 2 },
|
||||||
{ label: "Приоритет 3", value: 3 },
|
{ label: "Приоритет 3", value: 3 },
|
||||||
|
|||||||
Reference in New Issue
Block a user