fix: screenshots keys, show warning on updating project's hashtag

This commit is contained in:
MTG2000
2022-09-25 17:02:20 +03:00
parent 3677b2efb9
commit ec4eaca217
4 changed files with 230 additions and 222 deletions

View File

@@ -13,6 +13,7 @@ import { store } from "src/redux/store";
import UpdateProjectContextProvider from './updateProjectContext'
import { useNavigate } from 'react-router-dom'
import { createRoute } from 'src/utils/routing'
import { nanoid } from "@reduxjs/toolkit";
interface Props {
@@ -160,10 +161,10 @@ export default function FormContainer(props: PropsWithChildren<Props>) {
slack: data.slack,
telegram: data.telegram,
github: data.github,
lightning_address:data.lightning_address,
lightning_address: data.lightning_address,
category_id: data.category.id,
capabilities: data.capabilities.map(c => c.id),
screenshots: data.screenshots.map(url => ({ url })),
screenshots: data.screenshots.map(url => ({ url, local_id: nanoid(5), })),
members: prepareMembers(data.members),
recruit_roles: data.recruit_roles.map(r => r.id),

View File

@@ -14,7 +14,9 @@ interface Props { }
export default function ProjectDetailsTab(props: Props) {
const { register, formState: { errors, }, control, getValues } = useFormContext<IListProjectForm>();
const { register, formState: { errors, dirtyFields }, control, getValues } = useFormContext<IListProjectForm>();
const isUpdating = !!getValues('id');
return (
<div className="md:col-span-2 flex flex-col gap-24">
@@ -124,6 +126,9 @@ export default function ProjectDetailsTab(props: Props) {
{...register("hashtag")}
/>
</div>
{(isUpdating && dirtyFields.hashtag) && <p className="text-body5 text-orange-500 mt-8">
<span className="font-bolder text-orange-400">Warning:</span> changing the hashtag of the project will break all the old links for the project.
</p>}
{errors.hashtag && <p className="input-error">
{errors.hashtag.message}
</p>}