fix: projects editor to selected project editor, moved attributes editor
This commit is contained in:
@@ -3,28 +3,21 @@ import { useForm } from "@mantine/form";
|
||||
import { useEffect, useState } from "react";
|
||||
import { BaseMarketplaceSchema, BoardSchema, ClientSchema, ProjectSchema, StatusSchema } from "../../../client";
|
||||
|
||||
|
||||
type Props = {
|
||||
projects: ProjectSchema[];
|
||||
}
|
||||
|
||||
export type CardsPageState = {
|
||||
id: number | null;
|
||||
marketplace: BaseMarketplaceSchema | null;
|
||||
client: ClientSchema | null;
|
||||
project: ProjectSchema | null;
|
||||
|
||||
projectForTable: ProjectSchema | null;
|
||||
board: BoardSchema | null;
|
||||
status: StatusSchema | null;
|
||||
};
|
||||
|
||||
const useCardsPageState = ({ projects }: Props) => {
|
||||
const useCardsPageState = () => {
|
||||
const { objects } = useCardSummariesFull();
|
||||
|
||||
const form = useForm<CardsPageState>({
|
||||
initialValues: {
|
||||
project: null,
|
||||
id: null,
|
||||
marketplace: null,
|
||||
client: null,
|
||||
@@ -51,7 +44,7 @@ const useCardsPageState = ({ projects }: Props) => {
|
||||
}
|
||||
if (form.values.projectForTable) {
|
||||
result = result.filter(
|
||||
obj => obj.board.projectId === form.values.project?.id,
|
||||
obj => obj.board.projectId === form.values.projectForTable?.id,
|
||||
);
|
||||
|
||||
if (form.values.board) {
|
||||
@@ -78,12 +71,6 @@ const useCardsPageState = ({ projects }: Props) => {
|
||||
applyFilters();
|
||||
}, [form.values, objects]);
|
||||
|
||||
useEffect(() => {
|
||||
if (projects.length > 0 && form.values.project === null) {
|
||||
form.setFieldValue("project", projects[0]);
|
||||
}
|
||||
}, [projects]);
|
||||
|
||||
return { data, form };
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user