@@ -1,7 +1,7 @@
|
||||
import { Link, useForm } from "@inertiajs/react";
|
||||
import { Management } from "../management/shared";
|
||||
import { Field, input, button, card, groupLabels } from "./shared";
|
||||
import type { Opportunity, Context, References } from "./shared";
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Management } from '../management/shared';
|
||||
import { Field, input, button, card, groupLabels } from './shared';
|
||||
import type { Opportunity, Context, References } from './shared';
|
||||
export default function EditContext({
|
||||
record,
|
||||
context,
|
||||
@@ -14,11 +14,11 @@ export default function EditContext({
|
||||
const form = useForm({
|
||||
version: context.profile?.version ?? 0,
|
||||
is_education: context.profile?.is_education ?? false,
|
||||
business_model: context.profile?.business_model ?? "",
|
||||
requirements: context.profile?.requirements ?? "",
|
||||
risks: context.profile?.risks ?? "",
|
||||
target_date: context.profile?.target_date ?? "",
|
||||
source_reference: context.profile?.source_reference ?? "",
|
||||
business_model: context.profile?.business_model ?? '',
|
||||
requirements: context.profile?.requirements ?? '',
|
||||
risks: context.profile?.risks ?? '',
|
||||
target_date: context.profile?.target_date ?? '',
|
||||
source_reference: context.profile?.source_reference ?? '',
|
||||
clusters: context.clusters.map((r) => r.id),
|
||||
corridors: context.corridors.map((r) => r.id),
|
||||
projects: context.projects.map((r) => r.id),
|
||||
@@ -26,12 +26,15 @@ export default function EditContext({
|
||||
facets: context.facets.map((r) => r.id),
|
||||
});
|
||||
return (
|
||||
<Management title={"Contexto: " + record.title}>
|
||||
<Management title={'Contexto: ' + record.title}>
|
||||
<p>
|
||||
As relações e características são parte da ficha publicada. Guardar devolve-a a
|
||||
rascunho para revisão.
|
||||
As relações e características são parte da ficha publicada.
|
||||
Guardar devolve-a a rascunho para revisão.
|
||||
</p>
|
||||
<Link href={`/management/opportunities/${record.id}/edit`} className="underline">
|
||||
<Link
|
||||
href={`/management/opportunities/${record.id}/edit`}
|
||||
className="underline"
|
||||
>
|
||||
Editar e publicar a ficha principal
|
||||
</Link>
|
||||
<form
|
||||
@@ -39,7 +42,8 @@ export default function EditContext({
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
form.put(`/management/opportunities/${record.id}/context`, {
|
||||
onSuccess: () => form.setData("version", form.data.version + 1),
|
||||
onSuccess: () =>
|
||||
form.setData('version', form.data.version + 1),
|
||||
});
|
||||
}}
|
||||
>
|
||||
@@ -47,15 +51,36 @@ export default function EditContext({
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.is_education}
|
||||
onChange={(e) => form.setData("is_education", e.target.checked)}
|
||||
onChange={(e) =>
|
||||
form.setData('is_education', e.target.checked)
|
||||
}
|
||||
/>
|
||||
Oportunidade na educação
|
||||
</label>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
{(["clusters", "corridors", "projects", "locations"] as const).map((key, i) => (
|
||||
<fieldset className={card + " max-h-72 space-y-2 overflow-auto"} key={key}>
|
||||
{(
|
||||
[
|
||||
'clusters',
|
||||
'corridors',
|
||||
'projects',
|
||||
'locations',
|
||||
] as const
|
||||
).map((key, i) => (
|
||||
<fieldset
|
||||
className={
|
||||
card + ' max-h-72 space-y-2 overflow-auto'
|
||||
}
|
||||
key={key}
|
||||
>
|
||||
<legend className="font-bold">
|
||||
{["Clusters", "Corredores", "Projectos âncora", "Localizações"][i]}
|
||||
{
|
||||
[
|
||||
'Clusters',
|
||||
'Corredores',
|
||||
'Projectos âncora',
|
||||
'Localizações',
|
||||
][i]
|
||||
}
|
||||
</legend>
|
||||
{references[key].map((r) => (
|
||||
<label key={r.id} className="flex gap-2">
|
||||
@@ -67,7 +92,9 @@ export default function EditContext({
|
||||
key,
|
||||
e.target.checked
|
||||
? [...form.data[key], r.id]
|
||||
: form.data[key].filter((id) => id !== r.id),
|
||||
: form.data[key].filter(
|
||||
(id) => id !== r.id,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
@@ -79,18 +106,20 @@ export default function EditContext({
|
||||
</div>
|
||||
<div className="grid gap-4 md:grid-cols-3">
|
||||
{[
|
||||
"subsector",
|
||||
"education",
|
||||
"infrastructure",
|
||||
"labour",
|
||||
"qualification",
|
||||
"support",
|
||||
"impact",
|
||||
"partnership",
|
||||
'subsector',
|
||||
'education',
|
||||
'infrastructure',
|
||||
'labour',
|
||||
'qualification',
|
||||
'support',
|
||||
'impact',
|
||||
'partnership',
|
||||
].map((group) => (
|
||||
<fieldset
|
||||
key={group}
|
||||
className={card + " max-h-64 space-y-2 overflow-auto"}
|
||||
className={
|
||||
card + ' max-h-64 space-y-2 overflow-auto'
|
||||
}
|
||||
>
|
||||
<legend>{groupLabels[group]}</legend>
|
||||
{references.options
|
||||
@@ -99,14 +128,21 @@ export default function EditContext({
|
||||
<label key={o.id} className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={form.data.facets.includes(o.id)}
|
||||
checked={form.data.facets.includes(
|
||||
o.id,
|
||||
)}
|
||||
onChange={(e) =>
|
||||
form.setData(
|
||||
"facets",
|
||||
'facets',
|
||||
e.target.checked
|
||||
? [...form.data.facets, o.id]
|
||||
? [
|
||||
...form.data
|
||||
.facets,
|
||||
o.id,
|
||||
]
|
||||
: form.data.facets.filter(
|
||||
(id) => id !== o.id,
|
||||
(id) =>
|
||||
id !== o.id,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -117,35 +153,43 @@ export default function EditContext({
|
||||
</fieldset>
|
||||
))}
|
||||
</div>
|
||||
{(["business_model", "requirements", "risks", "source_reference"] as const).map(
|
||||
(key) => (
|
||||
<Field
|
||||
key={key}
|
||||
label={
|
||||
{
|
||||
business_model: "Modelo de negócio",
|
||||
requirements: "Requisitos e necessidades",
|
||||
risks: "Riscos",
|
||||
source_reference: "Fonte e referência de autorização",
|
||||
}[key]
|
||||
}
|
||||
>
|
||||
<textarea
|
||||
className={input}
|
||||
required={key === "source_reference"}
|
||||
rows={3}
|
||||
value={form.data[key]}
|
||||
onChange={(e) => form.setData(key, e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
),
|
||||
)}
|
||||
{(
|
||||
[
|
||||
'business_model',
|
||||
'requirements',
|
||||
'risks',
|
||||
'source_reference',
|
||||
] as const
|
||||
).map((key) => (
|
||||
<Field
|
||||
key={key}
|
||||
label={
|
||||
{
|
||||
business_model: 'Modelo de negócio',
|
||||
requirements: 'Requisitos e necessidades',
|
||||
risks: 'Riscos',
|
||||
source_reference:
|
||||
'Fonte e referência de autorização',
|
||||
}[key]
|
||||
}
|
||||
>
|
||||
<textarea
|
||||
className={input}
|
||||
required={key === 'source_reference'}
|
||||
rows={3}
|
||||
value={form.data[key]}
|
||||
onChange={(e) => form.setData(key, e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
))}
|
||||
<Field label="Data-alvo">
|
||||
<input
|
||||
type="date"
|
||||
className={input}
|
||||
value={form.data.target_date}
|
||||
onChange={(e) => form.setData("target_date", e.target.value)}
|
||||
onChange={(e) =>
|
||||
form.setData('target_date', e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
{Object.entries(form.errors).map(([key, value]) => (
|
||||
|
||||
Reference in New Issue
Block a user