-
Notifications
You must be signed in to change notification settings - Fork 3
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 #12 from Maker-Management-Platform/dev
Dev
- Loading branch information
Showing
20 changed files
with
231 additions
and
171 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
81 changes: 81 additions & 0 deletions
81
src/projects/components/parts/project-form/ProjectForm.tsx
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,81 @@ | ||
import { Button, Group, TagsInput, Textarea, TextInput } from "@mantine/core"; | ||
import { useForm } from "@mantine/form"; | ||
import { Project } from "../../../entities/Project.ts"; | ||
import useAxios from "axios-hooks"; | ||
import { useContext, useState } from "react"; | ||
import { SettingsContext } from "@/core/utils/settingsContext.ts"; | ||
import { notifications } from '@mantine/notifications'; | ||
type ProjectFormProps = { | ||
project: Project; | ||
onProjectChange: (p: Project) => void; | ||
}; | ||
|
||
export function ProjectForm({ project, onProjectChange }: ProjectFormProps) { | ||
const { local_backend } = useContext(SettingsContext); | ||
const [{ data, loading, error }, executeSave] = useAxios( | ||
{ | ||
method: 'POST' | ||
}, | ||
{ manual: true } | ||
) | ||
const form = useForm({ | ||
initialValues: { | ||
...project, | ||
}, | ||
validate: { | ||
name: (value) => (value.length < 2 ? 'Too short name' : null), | ||
path: (value) => (value.length < 1 ? 'Too short path' : null), | ||
}, | ||
}); | ||
const onSave = (project: Project) => { | ||
executeSave({ | ||
url: `${local_backend}/projects/${project.uuid}`, | ||
data: { | ||
...project, | ||
} | ||
}) | ||
.then(({ data }) => { | ||
onProjectChange(data) | ||
notifications.show({ | ||
title: 'Great Success!', | ||
message: 'Project updated', | ||
color: 'indigo', | ||
}) | ||
}) | ||
.catch(({ message }) => { | ||
console.log(message) | ||
notifications.show({ | ||
title: 'Ops... Error updating project!', | ||
message, | ||
color: 'red', | ||
autoClose: false | ||
}) | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<form onSubmit={form.onSubmit(onSave)}> | ||
<TextInput | ||
mb="sm" | ||
label="Name" | ||
{...form.getInputProps('name')} | ||
/> | ||
<Textarea | ||
mb="sm" | ||
label="Desciption" | ||
{...form.getInputProps('description')} | ||
/> | ||
<TagsInput | ||
mb="sm" | ||
label="Tags" | ||
maxDropdownHeight={200} | ||
{...form.getInputProps('tags')} | ||
/> | ||
<Group justify="flex-end" mt="md"> | ||
<Button type="submit" loading={loading}>Submit</Button> | ||
</Group> | ||
</form> | ||
</> | ||
); | ||
} |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...mponents/project-header/ProjectHeader.tsx → ...ts/parts/project-header/ProjectHeader.tsx
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 was deleted.
Oops, something went wrong.
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
34 changes: 0 additions & 34 deletions
34
src/projects/components/project-page3/parts/edit-project/EditProject.tsx
This file was deleted.
Oops, something went wrong.
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
33 changes: 33 additions & 0 deletions
33
...jects/components/project-page3/parts/project-page-body/parts/edit-project/EditProject.tsx
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,33 @@ | ||
import { Container, Tabs } from "@mantine/core"; | ||
import { ProjectForm } from "@/projects/components/parts/project-form/ProjectForm.tsx"; | ||
import { Project } from "@/projects/entities/Project.ts"; | ||
import { ProjectOprations } from "./parts/project-operations/ProjectOperations"; | ||
|
||
|
||
type EditProjectProps = { | ||
project: Project; | ||
onProjectChange: (p: Project) => void; | ||
} | ||
|
||
export function EditProject({ project, onProjectChange }: EditProjectProps) { | ||
return ( | ||
<> | ||
<Tabs defaultValue="edit" orientation="vertical" placement="right"> | ||
<Tabs.List> | ||
<Tabs.Tab value="edit">Edit</Tabs.Tab> | ||
<Tabs.Tab value="operations">Operations</Tabs.Tab> | ||
</Tabs.List> | ||
<Tabs.Panel value="edit"> | ||
<Container> | ||
<ProjectForm project={project} onProjectChange={onProjectChange} /> | ||
</Container> | ||
</Tabs.Panel> | ||
<Tabs.Panel value="operations"> | ||
<Container> | ||
<ProjectOprations project={project} onProjectChange={onProjectChange} /> | ||
</Container> | ||
</Tabs.Panel> | ||
</Tabs> | ||
</> | ||
); | ||
} |
Oops, something went wrong.