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

III-4435 - New Organizer form #783

Merged
merged 108 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
3c0dbe8
III-4493 - Setup create organizer page
brampauwelyn Jul 12, 2023
34b176d
Add additional steps component
Anahkiasen Jul 12, 2023
8f48b36
Add shouldShownOn on relevant steps
Anahkiasen Jul 12, 2023
fb9e211
III-4493 - Handle form validation
brampauwelyn Jul 12, 2023
7d1335e
Add submit button
Anahkiasen Jul 12, 2023
90a5ecf
III-4493 - Submit create organizer
brampauwelyn Jul 12, 2023
ce4466a
III-4493 - Move save button to footer
brampauwelyn Jul 12, 2023
d2a233f
III-4493 - Redirect to edit page after creating organizer
brampauwelyn Jul 12, 2023
e784cad
III-4493 - Add missing point after sentence
brampauwelyn Jul 12, 2023
4c7ded7
III-4493 - Preload organizer info in edit mode
brampauwelyn Jul 12, 2023
1f818d5
III-4493 - Redirect organizer edit page to new edit form
brampauwelyn Jul 12, 2023
edaabe9
Merge branch 'feature/III-4493' into feature/III-4494
Anahkiasen Jul 13, 2023
5ad418e
III-4493 - Create seperate file in constants for regexes
brampauwelyn Jul 13, 2023
34bc633
Pass correct props to Steps component
Anahkiasen Jul 13, 2023
9f466d8
Use correct query
Anahkiasen Jul 13, 2023
c879343
III-4493 - Import Regexes from constants
brampauwelyn Jul 13, 2023
78da786
III-4493 - Show corresponding error message in NameStep
brampauwelyn Jul 13, 2023
312c1aa
III-4493 - Validate url + prefix with https
brampauwelyn Jul 13, 2023
dafb438
III-4493 - Use translatable labels
brampauwelyn Jul 13, 2023
2e2afc7
III-4493 - Make component for NameAndUrl
brampauwelyn Jul 13, 2023
688d2dd
Unwrap contact point in PUT request
Anahkiasen Jul 13, 2023
d89a6fa
Introduce Scope type
Anahkiasen Jul 13, 2023
731e0d5
Linting
Anahkiasen Jul 13, 2023
431b3a3
Merge branch 'feature/III-4493' into feature/III-4494
Anahkiasen Jul 13, 2023
18d1f0b
III-4493 - Added dutch labels
brampauwelyn Jul 13, 2023
4107bce
III-4493 - Add FR & DE labels
brampauwelyn Jul 13, 2023
5d2f548
Merge pull request #782 from cultuurnet/feature/III-4494
Anahkiasen Jul 14, 2023
127e0a8
Add actual constant for organizers scope
Anahkiasen Jul 14, 2023
ac3e1a3
Add tips
Anahkiasen Jul 14, 2023
c2002ed
Merge DescriptionInfo code
Anahkiasen Jul 14, 2023
6205deb
Add small hook to get right entity based on scope
Anahkiasen Jul 14, 2023
69d5dd0
Use correct query in DescriptionStep
Anahkiasen Jul 14, 2023
24bd419
Rename some things to make it clear those are not jsut for offers any…
Anahkiasen Jul 14, 2023
657f357
Linting
Anahkiasen Jul 14, 2023
cc8829e
Rename organization -> organizer
Anahkiasen Jul 14, 2023
3f83ec1
Remove extra directives
Anahkiasen Jul 14, 2023
f8711cc
Add missing default value
Anahkiasen Jul 18, 2023
ccdac2e
Unify location handling in isLocationSet
Anahkiasen Jul 18, 2023
5ad0eed
Add Location step
Anahkiasen Jul 18, 2023
ed92998
Just pass all props for now
Anahkiasen Jul 18, 2023
79808ec
Add update organizer mutation
Anahkiasen Jul 18, 2023
3860543
Don't show non unique organizer URL error for same one as current
Anahkiasen Jul 18, 2023
18243da
Cleanup component a bit
Anahkiasen Jul 18, 2023
1a511d8
Do upsert on save
Anahkiasen Jul 18, 2023
ecf23d2
Make standard placeholders default
Anahkiasen Jul 18, 2023
966e785
More adaptations to LocationStep
Anahkiasen Jul 18, 2023
e454a2b
Use correct getters for location
Anahkiasen Jul 18, 2023
fabe9f7
Add location to initial form value
Anahkiasen Jul 18, 2023
d6db722
Add save button for once the org is created
Anahkiasen Jul 18, 2023
cf933bd
Add translations
Anahkiasen Jul 18, 2023
3c45735
Only pass address on updates
Anahkiasen Jul 18, 2023
b600bfb
Set validation status
Anahkiasen Jul 18, 2023
ffa9f80
Hide additional steps until after creation
Anahkiasen Jul 18, 2023
b45cd86
Only prefill location form attributes if done once
Anahkiasen Jul 18, 2023
85e64ea
Add section title translation
Anahkiasen Jul 18, 2023
2441e26
Rename OfferScore to FormScore to match broader usage
Anahkiasen Jul 18, 2023
faf1fb7
Only add 10 points for completed location
Anahkiasen Jul 18, 2023
3d078d4
Linting
Anahkiasen Jul 18, 2023
a1f207d
Update types
Anahkiasen Jul 18, 2023
4b420a9
Fix incorrect weight for description for organizers
Anahkiasen Jul 19, 2023
a993230
Update query to also get organizers
Anahkiasen Jul 19, 2023
953c9f6
Linting
Anahkiasen Jul 19, 2023
a58c358
Add missing translations
Anahkiasen Jul 19, 2023
e4db8f6
Merge pull request #784 from cultuurnet/feature/III-4495
Anahkiasen Jul 19, 2023
beb3004
Merge pull request #786 from cultuurnet/feature/III-5678
Anahkiasen Jul 19, 2023
2ed998f
Merge branch 'feature/III-4493' into feature/III-5677
Anahkiasen Jul 19, 2023
0e265a8
Merge pull request #785 from cultuurnet/feature/III-5677
Anahkiasen Jul 19, 2023
d56347c
Merge branch 'main' into feature/III-4493
Anahkiasen Jul 19, 2023
c68bf18
Update query
Anahkiasen Jul 19, 2023
a9c6ad4
Hide videos for organizetrs
Anahkiasen Jul 19, 2023
7a3e7a9
Pass both id and mediaObjectId to
Anahkiasen Jul 24, 2023
6b2ae73
Update method to correct one for both offers/organizers
Anahkiasen Jul 24, 2023
ba0f8db
Correctly retrieve images
Anahkiasen Jul 24, 2023
c7ebaee
Update query in FormScore to fetch organizers too
Anahkiasen Jul 24, 2023
54054b5
Add correct organizer weights mapping
Anahkiasen Jul 24, 2023
7afc188
Linting
Anahkiasen Jul 24, 2023
ef673db
Add some missing useEffect dependencies
Anahkiasen Jul 24, 2023
3822cb4
Add umbrella type
Anahkiasen Jul 24, 2023
b207af2
Remove unused variable
Anahkiasen Jul 24, 2023
f5e077b
Fix merge errors from past PR
Anahkiasen Jul 25, 2023
f2d29b0
Add organizer-specific translations
Anahkiasen Jul 25, 2023
265d25c
Linting
Anahkiasen Jul 25, 2023
dc0c1eb
Add missing new prop
Anahkiasen Jul 25, 2023
028bf2e
Add missing part of condition
Anahkiasen Jul 25, 2023
485e34f
Add location tip and completed organizer message
Anahkiasen Jul 25, 2023
316d0a9
Add organizer form spec
Anahkiasen Jul 26, 2023
c1e0f3e
Hide additional steps until organizer is saved
Anahkiasen Jul 26, 2023
c153918
Add some blur() calls to trigger the right events
Anahkiasen Jul 26, 2023
1908837
Add file upload and score checks
Anahkiasen Jul 27, 2023
cb9ee1d
Move all dummy data to object
Anahkiasen Jul 27, 2023
46c21e0
Merge pull request #787 from cultuurnet/feature/III-5676
Anahkiasen Jul 27, 2023
ad53351
Fix wrong way to get entityId in shouldShowStep
Anahkiasen Jul 27, 2023
cd25e1d
Dummy change to retrigger PR update? 🤔
Anahkiasen Jul 27, 2023
309d213
Merge pull request #788 from cultuurnet/feature/III-5681
Anahkiasen Aug 1, 2023
7ea2225
Merge pull request #789 from cultuurnet/feature/III-5679
Anahkiasen Aug 1, 2023
02db456
Merge branch 'main' into feature/III-4493
Anahkiasen Sep 21, 2023
e97c7bf
Add new feature flag for organizer form
Anahkiasen Sep 22, 2023
0e4b88b
Update locator
Anahkiasen Sep 26, 2023
af9b294
Fix Location validation not being passed to Organizer form validation
Anahkiasen Oct 9, 2023
619eb1f
III-4493 - Don't validate location on on organizers create page
brampauwelyn Oct 9, 2023
6d5c6d2
III-4493 - Remove console.log
brampauwelyn Oct 10, 2023
a934fcb
III-4493 - spread stackProps after props
brampauwelyn Oct 10, 2023
bd0deef
III-4493 - Add new line
brampauwelyn Oct 10, 2023
8b9cfa5
Save organizer location on blur instead of on manual save
Anahkiasen Oct 10, 2023
0a2a456
Update footer for existing organizers
Anahkiasen Oct 10, 2023
60db825
Upsert organizer on name and URL change
Anahkiasen Oct 10, 2023
b385179
Linting
Anahkiasen Oct 10, 2023
8e788bc
Update spec
Anahkiasen Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/constants/OfferType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ const OfferTypes = {
PLACES: 'places',
} as const;

const ScopeTypes = { ...OfferTypes, ORGANIZERS: 'organizers' };

type OfferType = Values<typeof OfferTypes>;
type Scope = Values<typeof ScopeTypes>;

export type { OfferType };
export { OfferTypes };
export type { OfferType, Scope };
export { OfferTypes, ScopeTypes };
6 changes: 6 additions & 0 deletions src/constants/Regex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const EMAIL_REGEX: RegExp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
const URL_REGEX: RegExp =
/^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?!&\/=]*)$/;
const PHONE_REGEX: RegExp = /^[0-9\/\-_.+ ]{0,15}$/;

export { EMAIL_REGEX, PHONE_REGEX, URL_REGEX };
27 changes: 11 additions & 16 deletions src/hooks/api/offers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const useAddOfferPriceInfoMutation = (configuration = {}) =>
...configuration,
});

const changeOfferDescription = async ({
const changeDescription = async ({
headers,
eventId,
language,
Expand All @@ -291,9 +291,9 @@ const changeOfferDescription = async ({
},
});

const useChangeOfferDescriptionMutation = (configuration = {}) =>
const useChangeDescriptionMutation = (configuration = {}) =>
useAuthenticatedMutation({
mutationFn: changeOfferDescription,
mutationFn: changeDescription,
mutationKey: 'offers-change-description',
...configuration,
});
Expand All @@ -304,7 +304,7 @@ const addOfferImage = async ({ headers, eventId, imageId, scope }) =>
options: {
method: 'POST',
headers,
body: JSON.stringify({ mediaObjectId: imageId }),
body: JSON.stringify({ mediaObjectId: imageId, id: imageId }),
},
});

Expand All @@ -319,7 +319,7 @@ const addOfferMainImage = async ({ headers, eventId, imageId, scope }) =>
fetchFromApi({
path: `/${scope}/${eventId.toString()}/images/main`,
options: {
method: 'POST',
method: 'PUT',
headers,
body: JSON.stringify({ mediaObjectId: imageId }),
},
Expand Down Expand Up @@ -408,24 +408,19 @@ const useDeleteOfferImageMutation = (configuration = {}) =>
...configuration,
});

const addOfferContactPoint = async ({
headers,
eventId,
contactPoint,
scope,
}) =>
const addContactPoint = async ({ headers, eventId, contactPoint, scope }) =>
fetchFromApi({
path: `/${scope}/${eventId}/contactPoint`,
options: {
method: 'PUT',
headers,
body: JSON.stringify({ contactPoint }),
body: JSON.stringify({ ...contactPoint }),
},
});

const useAddOfferContactPointMutation = (configuration = {}) =>
const useAddContactPointMutation = (configuration = {}) =>
useAuthenticatedMutation({
mutationFn: addOfferContactPoint,
mutationFn: addContactPoint,
mutationKey: 'offers-add-contact-point',
...configuration,
});
Expand Down Expand Up @@ -486,16 +481,16 @@ const useDeleteOfferOrganizerMutation = (configuration = {}) =>
});

export {
useAddContactPointMutation,
useAddOfferBookingInfoMutation,
useAddOfferContactPointMutation,
useAddOfferImageMutation,
useAddOfferLabelMutation,
useAddOfferMainImageMutation,
useAddOfferOrganizerMutation,
useAddOfferPriceInfoMutation,
useAddOfferVideoMutation,
useChangeDescriptionMutation,
useChangeOfferCalendarMutation,
useChangeOfferDescriptionMutation,
useChangeOfferNameMutation,
useChangeOfferThemeMutation,
useChangeOfferTypeMutation,
Expand Down
71 changes: 67 additions & 4 deletions src/hooks/api/organizers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,11 @@ const getOrganizerById = async ({ headers, id }: GetOrganizerByIdArguments) => {
};

const useGetOrganizerByIdQuery = (
{ req, queryClient, id },
{ id, ...options },
configuration: UseQueryOptions = {},
) =>
useAuthenticatedQuery({
req,
queryClient,
...options,
queryKey: ['organizers'],
queryFn: getOrganizerById,
queryArguments: { id },
Expand Down Expand Up @@ -213,14 +212,23 @@ const useGetOrganizersByCreatorQuery = (
...configuration,
});

type CreateOrganizerArguments = {
headers: Headers;
url: string;
name: string;
address: any;
mainLanguage: string;
contact: any;
};

const createOrganizer = ({
headers,
url,
name,
address,
mainLanguage,
contact,
}) =>
}: CreateOrganizerArguments) =>
fetchFromApi({
path: '/organizers',
options: {
Expand All @@ -243,11 +251,66 @@ const useCreateOrganizerMutation = (configuration: UseMutationOptions = {}) =>
...configuration,
});

type UpdateOrganizerArguments = CreateOrganizerArguments & {
organizerId: string;
};

const updateOrganizer = ({
headers,
url,
organizerId,
name,
address,
mainLanguage,
contact,
}: UpdateOrganizerArguments) =>
fetchFromApi({
path: `/organizers/${organizerId}`,
options: {
headers,
method: 'PUT',
body: JSON.stringify({
mainLanguage,
name,
url,
address,
contact,
}),
},
});

const useUpdateOrganizerMutation = (configuration: UseMutationOptions = {}) =>
useAuthenticatedMutation({
mutationFn: updateOrganizer,
mutationKey: 'organizers-update',
...configuration,
});

const changeLocation = async ({ headers, organizerId, language, location }) => {
return fetchFromApi({
path: `/organizers/${organizerId.toString()}/address/${language}`,
options: {
method: 'PUT',
headers,
body: JSON.stringify(location),
},
});
};

const useChangeLocationMutation = (configuration = {}) =>
useAuthenticatedMutation({
mutationFn: changeLocation,
mutationKey: 'organizer-change-location',
...configuration,
});

export {
useChangeLocationMutation,
useCreateOrganizerMutation,
useDeleteOrganizerByIdMutation,
useGetOrganizerByIdQuery,
useGetOrganizersByCreatorQuery,
useGetOrganizersByQueryQuery,
useGetOrganizersByWebsiteQuery,
useUpdateOrganizerMutation,
};
23 changes: 23 additions & 0 deletions src/hooks/api/scope.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Scope, ScopeTypes } from '@/constants/OfferType';
import { useGetOfferByIdQuery } from '@/hooks/api/offers';
import { useGetOrganizerByIdQuery } from '@/hooks/api/organizers';

const getEntityQueryForScope = (scope: Scope) =>
scope === ScopeTypes.ORGANIZERS
? useGetOrganizerByIdQuery
: useGetOfferByIdQuery;

const useGetEntityByIdAndScope = ({
scope,
id,
...rest
}: {
scope: Scope;
id: string;
}) => {
const query = getEntityQueryForScope(scope);

return query({ scope, id, ...rest });
};

export { getEntityQueryForScope, useGetEntityByIdAndScope };
5 changes: 3 additions & 2 deletions src/hooks/api/terms.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import getConfig from 'next/config';
import { useQuery } from 'react-query';

type TermScope = 'events' | 'places';
import { Scope } from '@/constants/OfferType';

type TermDomain = 'eventtype' | 'theme' | 'facility';

type Term = {
Expand All @@ -13,7 +14,7 @@ type Term = {
de: string;
en: string;
};
scope: TermScope[];
scope: Scope[];
};

type EventType = Term & {
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useFeatureFlag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useCookiesWithOptions } from './useCookiesWithOptions';

const FeatureFlags = {
REACT_CREATE: 'react_create',
ORGANIZER_CREATE: 'organizer_create',
} as const;

const createCookieName = (identifier: string) => `ff_${identifier}`;
Expand Down
42 changes: 39 additions & 3 deletions src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,14 @@
"text": "Tipp: Fügen Sie einen <1>{{link}}</1> hinzu",
"link": "Organisator"
},
"completed": "Alle Punkte! Mit dieser Veranstaltung werden Sie punkten!"
"location": {
"text": "Tipp: Fügen Sie <1>{{link}}</1> hinzu",
"link": "Adresseinformationen"
},
"completed": {
"offers": "Alle Punkte! Mit dieser Veranstaltung werden Sie punkten!",
"organizers": "Mit dieser Organisation wirst du punkten!"
}
}
},
"organizer": {
Expand All @@ -444,6 +451,9 @@
"not_found": "Diese Veranstaltung ist dem UiTPAS noch nicht bekannt."
}
},
"location": {
"title": "Standort"
},
"place": {
"add_new_label": "Ort nicht gefunden? Neuen Standort hinzufügen"
},
Expand Down Expand Up @@ -479,7 +489,8 @@
},
"title": {
"events": "Stellen Sie sicher, dass Ihr Publikum keine Informationen verpasst",
"places": "Stellen Sie sicher, dass Ihr Publikum keine Informationen verpasst"
"places": "Stellen Sie sicher, dass Ihr Publikum keine Informationen verpasst",
"organizers": "Stellen Sie sicher, dass Ihr Publikum keine Informationen verpasst"
},
"title_events": "Machen Sie dieses Ereignis zu etwas Besonderem",
"title_places": "Heben Sie diesen Standort hervor"
Expand All @@ -495,7 +506,6 @@
},
"description": "Ab wann soll dies online angezeigt werden?",
"title": "Wählen Sie ein Veröffentlichungsdatum",

"warning": "Achtung, dieses Datum kann nur einmalig eingestellt werden."
},
"duplicate": {
Expand Down Expand Up @@ -963,6 +973,32 @@
"title": "Produktionen"
}
},
"organizers": {
"create": {
"title": "Organisation hinzufügen",
"step1": {
"title": "Welche Organisation möchten Sie hinzufügen?",
"save": "Speichern",
"name": "Name",
"url": "Website",
"url_requirements": "Um Organisationen in der UiT-Datenbank einzigartig zu halten, bitten wir jede Organisation um einen eindeutigen und gültigen Hyperlink",
"errors": {
"name_required": "Name fehlt",
"url_required": "URL fehlt",
"url_matches": "Ungültige URL",
"url_not_unique": "Diese Adresse wird bereits von der Organisation „{{organizerName}}“ verwendet."
}
},
"step2": {
"description_tips": "Beschreiben Sie Ihre Organisation mit Begeisterung\nAn welche Zielgruppe richtet sich die Organisation?\nWelche Aktivitäten organisiert diese Organisation?",
"save": "Speichern",
"pictures": {
"title": "Bilder",
"intro": "Fügen Sie ein Bild hinzu, damit Besucher Ihre Organisation besser erkennen"
}
}
}
},
"selectionTable": {
"rowsSelectedCount": "{{count}} Reihe ausgewählt",
"rowsSelectedCount_plural": "{{count}} Reihen ausgewählt"
Expand Down
Loading
Loading