Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPF-469-Add website #1128

Merged
merged 12 commits into from
May 23, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function rules(): array
'subscriptionId' => ['required', 'string'],
'integrationName' => ['required', 'string', 'max:255'],
'description' => ['required', 'string', 'max:255'],
'website' => ['required_if:integrationType,uitpas', 'nullable', 'url:http,https', 'max:255'],
vhande marked this conversation as resolved.
Show resolved Hide resolved
'firstNameFunctionalContact' => ['required', 'string', 'max:255'],
'lastNameFunctionalContact' => ['required', 'string', 'max:255'],
'emailFunctionalContact' => ['required', 'string', 'email', 'max:255'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Domain\Integrations\FormRequests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

final class UpdateIntegrationRequest extends FormRequest
{
Expand All @@ -16,6 +17,12 @@ public function rules(): array
return [
'integrationName' => ['required_without:description', 'string', 'max:255'],
'description' => ['required_without:integrationName', 'string', 'max:255'],
'website' => [
Rule::requiredIf($this->input('integrationType') === 'uitpas'),
'nullable',
'url:http,https',
'max:255',
],
];
}
}
12 changes: 10 additions & 2 deletions app/Domain/Integrations/Mappers/StoreIntegrationMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Domain\Integrations\IntegrationPartnerStatus;
use App\Domain\Integrations\IntegrationStatus;
use App\Domain\Integrations\IntegrationType;
use App\Domain\Integrations\Website;
use Ramsey\Uuid\Uuid;

final class StoreIntegrationMapper
Expand Down Expand Up @@ -47,14 +48,21 @@ public static function map(StoreIntegrationRequest $request, CurrentUser $curren
$currentUser->lastName()
);

return (new Integration(
$integration = new Integration(
$integrationId,
IntegrationType::from($request->input('integrationType')),
$request->input('integrationName'),
$request->input('description'),
Uuid::fromString($request->input('subscriptionId')),
IntegrationStatus::Draft,
IntegrationPartnerStatus::THIRD_PARTY,
))->withContacts($functionalContact, $technicalContact, $contributorContact);
);
$integration = $integration->withContacts($functionalContact, $technicalContact, $contributorContact);

if (!is_null($request->input('website'))) {
$integration = $integration->withWebsite(new Website($request->input('website')));
}

return $integration;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

use App\Domain\Integrations\FormRequests\UpdateIntegrationRequest;
use App\Domain\Integrations\Integration;
use App\Domain\Integrations\Website;

final class UpdateIntegrationMapper
{
public static function map(UpdateIntegrationRequest $request, Integration $currentIntegration): Integration
{
return new Integration(
$integration = new Integration(
$currentIntegration->id,
$currentIntegration->type,
$request->input('integrationName') ?? $currentIntegration->name,
Expand All @@ -20,5 +21,11 @@ public static function map(UpdateIntegrationRequest $request, Integration $curre
$currentIntegration->status,
$currentIntegration->partnerStatus
);

if (!is_null($request->input('website'))) {
$integration = $integration->withWebsite(new Website($request->input('website')));
}

return $integration;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function update(Integration $integration): void
'type' => $integration->type,
'name' => $integration->name,
'description' => $integration->description,
'website' => $integration->website() ? $integration->website()->value : null,
'subscription_id' => $integration->subscriptionId,
'status' => $integration->status,
'partner_status' => $integration->partnerStatus,
Expand Down
3 changes: 3 additions & 0 deletions lang/en/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
'attribute-name' => [
'rule-name' => 'custom-message',
],
'website' => [
'required_if' => 'Website is required.'
]
],

/*
Expand Down
3 changes: 3 additions & 0 deletions lang/nl/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@
'attribute-name' => [
'rule-name' => 'custom-message',
],
'website' => [
'required_if' => 'Website is verplicht.'
]
],

/*
Expand Down
31 changes: 22 additions & 9 deletions resources/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,28 @@
"integration_form": {
"title": "Add integration",
"type": "Integration type",
"pricing_plan": "Pricing plan",
"price_info": "You only pay when you want to use real data. You can explore all possibilities with test events first.",
"pricing_plan": {
"label": "Pricing plan",
"info": "You only pay when you want to use real data. You can explore all possibilities with test events first."
},
"integration_name": "Integration name",
"description_name": "Give a clear title to your integration and mention the name of the organization or municipality for which the integration is built",
"aim": "Integration purpose",
"description_aim": "Provide a clear, motivated description of the integration you want to set up with the publiq platform (max. 200 characters)",
"contact_label_functional": "Functional contact",
"contact_label_functional_info": "The functional contact is the functional point of contact for the integration (e.g., an employee of the organization or municipality for which the integration is intended).",
"contact_label_technical": "Technical contact",
"contact_label_technical_info": "The technical contact is the technical point of contact for the integration (e.g., the developer of the integration).",
"aim": {
"label": "Integration purpose",
"info": "Provide a clear, motivated description of the integration you want to set up with the publiq platform (max. 200 characters)"
},
"website": {
"label": "Website",
"info": "De URL van de website of app waarvoor de integratie gebouwd wordt."
},
"contact_functional": {
"label": "Functional contact",
"info": "The functional contact is the functional point of contact for the integration (e.g., an employee of the organization or municipality for which the integration is intended)."
},
"contact_technical": {
"label": "Technical contact",
"info": "The technical contact is the technical point of contact for the integration (e.g., the developer of the integration)."
},
"contact_label_contributor": "Employee",
"add": "Add employee",
"contact": {
Expand Down Expand Up @@ -184,7 +196,8 @@
"basic_info": {
"title": "Basic information",
"name": "Integration name",
"description": "Description"
"description": "Description",
"website": "Website"
},
"contact_info": {
"title": "Contacts",
Expand Down
31 changes: 22 additions & 9 deletions resources/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,28 @@
"integration_form": {
"title": "Integratie toevoegen",
"type": "Type integratie",
"pricing_plan": "Prijsplan",
"price_info": "Je betaalt pas wanneer je gebruik wilt maken van echte data. Je probeert eerst alle mogelijkheden met testevenementen.",
"pricing_plan": {
"label": "Prijsplan",
"info": "Je betaalt pas wanneer je gebruik wilt maken van echte data. Je probeert eerst alle mogelijkheden met testevenementen."
},
"integration_name": "Naam integratie",
"description_name": "Geef een duidelijk titel aan je integratie en vermeld de naam van de organisatie of gemeente waarvoor de integratie gebouwd wordt",
"aim": "Doel van de integratie",
"description_aim": "Geef een duidelijke, gemotiveerde beschrijving van de integratie die je met het publiq platform wil opzetten (max. 200 karakters)",
"contact_label_functional": "Inhoudelijk contact",
"contact_label_functional_info": "Het inhoudelijk contact is het inhoudelijk aanspreekpunt voor de integratie (bvb. een medewerker van de organisatie of gemeente waarvoor de integratie is).",
"contact_label_technical": "Technisch contact",
"contact_label_technical_info": "Het technisch contact is het technische aanspreekpunt voor de integratie (bvb. de ontwikkelaar van de integratie).",
"aim": {
"label": "Doel van de integratie",
"info": "Geef een duidelijke, gemotiveerde beschrijving van de integratie die je met het publiq platform wil opzetten (max. 200 karakters)"
},
"website": {
"label": "Website",
"info": "De URL van de website of app waarvoor de integratie gebouwd wordt."
},
"contact_functional": {
"label": "Inhoudelijk contact",
"info": "Het inhoudelijk contact is het inhoudelijk aanspreekpunt voor de integratie (bvb. een medewerker van de organisatie of gemeente waarvoor de integratie is)."
},
"contact_technical": {
"label": "Technisch contact",
"info": "Het technisch contact is het technische aanspreekpunt voor de integratie (bvb. de ontwikkelaar van de integratie)."
},
"contact_label_contributor": "Medewerker",
"add": "Medewerker toevoegen",
"contact": {
Expand Down Expand Up @@ -184,7 +196,8 @@
"basic_info": {
"title": "Basisgegevens",
"name": "Integratienaam",
"description": "Beschrijving"
"description": "Beschrijving",
"website": "Website"
},
"contact_info": {
"title": "Contacten",
Expand Down
2 changes: 1 addition & 1 deletion resources/ts/Components/ContactsTableContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const ContactsTableContent = ({
mobile && "text-xs"
)}
>
{t(`integration_form.contact_label_${type.label}`)}
{t(`integration_form.contact_${type.label}.label`)}
</div>
</td>
{desktop && (
Expand Down
17 changes: 17 additions & 0 deletions resources/ts/Components/Integrations/Detail/BasicInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ import { Heading } from "../../Heading";
type Props = {
name: string;
description: string;
website: string;
errors: Record<string, string | undefined>;
onChangeName: (val: string) => void;
onChangeDescription: (val: string) => void;
onChangeWebsite: (val: string) => void;
};
export const BasicInfo = ({
name,
description,
website,
errors,
onChangeName,
onChangeDescription,
onChangeWebsite,
}: Props) => {
const { t } = useTranslation();

Expand Down Expand Up @@ -55,6 +59,19 @@ export const BasicInfo = ({
/>
}
/>
<FormElement
label={`${t("details.basic_info.website")}`}
error={errors["website"]}
component={
<Input
type="text"
name="website"
value={website}
onChange={(e) => onChangeWebsite(e.target.value)}
className="md:min-w-[40rem]"
/>
}
/>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const IntegrationSettings = ({
name,
type,
description,
website,
urls,
keyVisibility,
onChangeIsFormDirty,
Expand All @@ -113,6 +114,8 @@ export const IntegrationSettings = ({
const basicInfoForm = useBasicInfoForm({
integrationName: name,
description,
website,
integrationType: type,
});

const urlsForm = useUrlsForm({
Expand Down Expand Up @@ -192,7 +195,7 @@ export const IntegrationSettings = ({
resolve(undefined);
basicInfoForm.setDefaults();
},
only: ["name", "description", "errors"],
only: ["name", "description", "website", "errors"],
});
});
};
Expand Down Expand Up @@ -242,10 +245,12 @@ export const IntegrationSettings = ({
<BasicInfo
name={basicInfoForm.data.integrationName}
description={basicInfoForm.data.description}
website={basicInfoForm.data.website}
onChangeName={(name) => basicInfoForm.setData("integrationName", name)}
onChangeDescription={(description) =>
basicInfoForm.setData("description", description)
}
onChangeWebsite={(website) => basicInfoForm.setData("website", website)}
errors={basicInfoForm.errors}
/>

Expand Down
33 changes: 25 additions & 8 deletions resources/ts/Pages/Integrations/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const New = ({ subscriptions }: Props) => {
: "",
integrationName: "",
description: "",
website: "",
organizationFunctionalContact: "",
firstNameFunctionalContact: "",
lastNameFunctionalContact: "",
Expand Down Expand Up @@ -138,7 +139,7 @@ const New = ({ subscriptions }: Props) => {
</Card>

{pricingPlans.length > 0 && (
<Card title={t("integration_form.pricing_plan")}>
<Card title={t("integration_form.pricing_plan.label")}>
<RadioButtonGroup
orientation="vertical"
name="subscriptionId"
Expand All @@ -162,7 +163,7 @@ const New = ({ subscriptions }: Props) => {
)}
{data.integrationType !== IntegrationType.EntryApi && (
<span className="text-gray-500 text-sm mt-3 inline-block">
{t("integration_form.price_info")}
{t("integration_form.pricing_plan.info")}
</span>
)}
</div>
Expand All @@ -186,9 +187,9 @@ const New = ({ subscriptions }: Props) => {
</Card>
<Card>
<FormElement
label={t("integration_form.aim")}
label={t("integration_form.aim.label")}
labelSize="2xl"
info={t("integration_form.description_aim")}
info={t("integration_form.aim.info")}
component={
<textarea
rows={3}
Expand All @@ -201,8 +202,24 @@ const New = ({ subscriptions }: Props) => {
error={errors.description}
/>
</Card>
<Card>
<FormElement
label={t("integration_form.website.label")}
labelSize="2xl"
info={t("integration_form.website.info")}
component={
<Input
type="text"
name="website"
value={data.website}
onChange={(e) => setData("website", e.target.value)}
/>
}
error={errors.website}
/>
</Card>
<Card
title={t("integration_form.contact_label_functional")}
title={t("integration_form.contact_functional.label")}
contentStyles="flex flex-col gap-5"
>
<div className="flex flex-col gap-5">
Expand Down Expand Up @@ -254,13 +271,13 @@ const New = ({ subscriptions }: Props) => {
/>
</div>
<span className="text-gray-500 text-sm">
{t("integration_form.contact_label_functional_info")}
{t("integration_form.contact_functional.info")}
</span>
</div>
</Card>

<Card
title={t("integration_form.contact_label_technical")}
title={t("integration_form.contact_technical.label")}
contentStyles="flex flex-col gap-5"
>
<div className="grid grid-cols-3 max-md:flex max-md:flex-col gap-5">
Expand Down Expand Up @@ -312,7 +329,7 @@ const New = ({ subscriptions }: Props) => {
/>
</div>
<span className="text-gray-500 text-sm">
{t("integration_form.contact_label_technical_info")}
{t("integration_form.contact_technical.info")}
</span>
</Card>

Expand Down
1 change: 1 addition & 0 deletions resources/ts/types/Integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type Integration = {
type: Values<typeof IntegrationType>;
name: string;
description: string;
website: string;
subscriptionId: string;
coupon: Coupon | null;
status: IntegrationStatus;
Expand Down
Loading