Skip to content

Commit

Permalink
Merge pull request #816 from cultuurnet/bugfix/III-5802
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahkiasen authored Oct 24, 2023
2 parents 7f6187f + 8fdcc75 commit 8ca51f2
Show file tree
Hide file tree
Showing 31 changed files with 193 additions and 297 deletions.
4 changes: 3 additions & 1 deletion src/hooks/api/authenticated-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { Cookies } from 'react-cookie';
import {
MutationFunction,
QueryClient,
useMutation,
useQueries,
useQuery,
useQueryClient,
UseQueryResult,
} from 'react-query';
import { useMutation, useQueries, useQuery } from 'react-query';

import { useCookiesWithOptions } from '@/hooks/useCookiesWithOptions';
import type { CalendarSummaryFormat } from '@/utils/createEmbededCalendarSummaries';
Expand Down
1 change: 0 additions & 1 deletion src/hooks/api/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import jwt_decode from 'jwt-decode';
import getConfig from 'next/config';

import { FetchError, fetchFromApi, isErrorObject } from '@/utils/fetchFromApi';

Expand Down
1 change: 0 additions & 1 deletion src/pages/PictureUploadBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DragEvent } from 'react';
import { useTranslation } from 'react-i18next';
import { css } from 'styled-components';

import { Scope, ScopeTypes } from '@/constants/OfferType';
import { Button, ButtonVariants } from '@/ui/Button';
Expand Down
1 change: 0 additions & 1 deletion src/pages/VideoUploadBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useTranslation } from 'react-i18next';
import { css } from 'styled-components';

import { Button, ButtonVariants } from '@/ui/Button';
import { Icons } from '@/ui/Icon';
Expand Down
1 change: 0 additions & 1 deletion src/pages/api/auth/[...auth0].api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { handleAuth, handleLogin, handleLogout } from '@auth0/nextjs-auth0';
import { serialize } from 'cookie';
import { NextApiRequest } from 'next';
import getConfig from 'next/config';

Expand Down
10 changes: 2 additions & 8 deletions src/pages/create/OfferForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@ import { Address, AddressInternal } from '@/types/Address';
import { ContactPoint } from '@/types/ContactPoint';
import { Country } from '@/types/Country';
import { AttendanceMode, AudienceType, isEvent } from '@/types/Event';
import {
BookingInfo,
Label,
MediaObject,
Offer,
PriceInfo,
} from '@/types/Offer';
import { BookingInfo, MediaObject, Offer, PriceInfo } from '@/types/Offer';
import { Organizer } from '@/types/Organizer';
import { isPlace, Place } from '@/types/Place';
import { Place } from '@/types/Place';
import { Values } from '@/types/Values';
import { WorkflowStatus } from '@/types/WorkflowStatus';
import { getLanguageObjectOrFallback } from '@/utils/getLanguageObjectOrFallback';
Expand Down
56 changes: 28 additions & 28 deletions src/pages/login/[language].page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const Path = (props) => <Box as="path" {...props} />;

const Animation = (props) => {
const draw = keyframes`
to {
stroke-dashoffset: 0;
}
`;
to {
stroke-dashoffset: 0;
}
`;

const drawAnimationLineLeft = css`
${draw} 2s 0.2s forwards linear;
Expand All @@ -47,32 +47,32 @@ const Animation = (props) => {
`;

const logoAnimate = keyframes`
0% {
transform: scale(1);
animation-timing-function: cubic-bezier(0.3, 0.1, 0.9, 0.5);
}
10% {
transform: scale(0.8);
animation-timing-function: cubic-bezier(0.1, 0.4, 0.2, 1);
}
100% {
transform: scale(1);
}
`;
0% {
transform: scale(1);
animation-timing-function: cubic-bezier(0.3, 0.1, 0.9, 0.5);
}
10% {
transform: scale(0.8);
animation-timing-function: cubic-bezier(0.1, 0.4, 0.2, 1);
}
100% {
transform: scale(1);
}
`;

const publicAnimate = keyframes`
0% {
transform: scale(1);
animation-timing-function: cubic-bezier(0.3, 0.1, 0.9, 0.5);
}
10% {
transform: scale(0.8);
animation-timing-function: cubic-bezier(0.1, 0.4, 0.2, 1);
}
100% {
transform: scale(1);
}
`;
0% {
transform: scale(1);
animation-timing-function: cubic-bezier(0.3, 0.1, 0.9, 0.5);
}
10% {
transform: scale(0.8);
animation-timing-function: cubic-bezier(0.1, 0.4, 0.2, 1);
}
100% {
transform: scale(1);
}
`;

return (
<Svg {...props} width="100%">
Expand Down
6 changes: 3 additions & 3 deletions src/pages/organizers/create/steps/NameStep.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormEvent } from 'react';
import { FocusEvent } from 'react';
import { Controller } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

Expand All @@ -18,7 +18,7 @@ const NameStep = ({
name,
...props
}: NameStepProps) => {
const { t, i18n } = useTranslation();
const { t } = useTranslation();

return (
<Stack {...getStackProps(props)}>
Expand All @@ -41,7 +41,7 @@ const NameStep = ({
name: (event.target as HTMLInputElement).value,
});
}}
onBlur={(event: FormEvent<HTMLInputElement>) => {
onBlur={(event: FocusEvent<HTMLInputElement>) => {
field.onChange({
...field.value,
name: (event.target as HTMLInputElement).value,
Expand Down
8 changes: 1 addition & 7 deletions src/pages/organizers/create/steps/UrlStep.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRouter } from 'next/router';
import { FormEvent, useEffect, useState } from 'react';
import { Controller, useWatch } from 'react-hook-form';
import { Controller } from 'react-hook-form';
import { Trans, useTranslation } from 'react-i18next';

import { useGetOrganizersByWebsiteQuery } from '@/hooks/api/organizers';
Expand Down Expand Up @@ -34,12 +34,6 @@ const UrlStep = ({
const { t, i18n } = useTranslation();

const [searchInput, setSearchInput] = useState('');

const [watchedUrl] = useWatch({
control,
name: ['nameAndUrl.url'],
});

const debouncedSearchInput = useDebounce(searchInput, 275);

const getOrganizersByWebsiteQuery = useGetOrganizersByWebsiteQuery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,7 @@ const BookingInfoStep = ({
as="form"
width="45%"
spacing={4}
onBlur={handleSubmit((data) => {
handleAddBookingInfoMutation(data);
})}
onBlur={() => handleAddBookingInfoMutation(getValues())}
ref={formComponent}
>
{Object.keys(ContactInfoType).map((key, index) => {
Expand Down
1 change: 0 additions & 1 deletion src/pages/steps/AdditionalInformationStep/LabelsStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ function LabelsStep({
setLabels(uniq([...labels, label]));
ref.current.clear();
}}
customFilter={() => true}
/>
}
maxWidth={'100%'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import { ButtonCard } from '@/ui/ButtonCard';
import { FormElement } from '@/ui/FormElement';
import { Icon, Icons } from '@/ui/Icon';
import { Inline } from '@/ui/Inline';
import { Paragraph } from '@/ui/Paragraph';
import { getStackProps, Stack, StackProps } from '@/ui/Stack';
import { Text } from '@/ui/Text';
import { getGlobalBorderRadius, getValueFromTheme } from '@/ui/theme';
import { getValueFromTheme } from '@/ui/theme';
import { isNewEntry, NewEntry, Typeahead } from '@/ui/Typeahead';
import { parseOfferId } from '@/utils/parseOfferId';
import { valueToArray } from '@/utils/valueToArray';
Expand Down
3 changes: 1 addition & 2 deletions src/pages/steps/CalendarStep/CalendarOpeninghoursModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { yupResolver } from '@hookform/resolvers/yup';
import { ChangeEvent } from 'react';
import { useEffect } from 'react';
import { ChangeEvent, useEffect } from 'react';
import { useFieldArray, useForm, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import * as yup from 'yup';
Expand Down
1 change: 0 additions & 1 deletion src/pages/steps/CalendarStep/useCalendarType.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useMemo } from 'react';

import { CalendarType } from '@/constants/CalendarType';
import { Values } from '@/types/Values';

import {
useIsIdle,
Expand Down
7 changes: 1 addition & 6 deletions src/pages/steps/LocationStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ import { useTranslation } from 'react-i18next';
import * as yup from 'yup';

import { EventTypes } from '@/constants/EventTypes';
import {
OfferType,
OfferTypes,
Scope,
ScopeTypes,
} from '@/constants/OfferType';
import { OfferTypes, Scope, ScopeTypes } from '@/constants/OfferType';
import {
useChangeAttendanceModeMutation,
useChangeAudienceMutation,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/steps/PlaceStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const PlaceStep = ({
isLoading={useGetPlacesQuery.isLoading}
options={places}
onInputChange={debounce(setSearchInput, 275)}
customFilter={filterByCallback}
filterBy={filterByCallback}
labelKey={(place) =>
getPlaceName(place.name, place.mainLanguage)
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/steps/ProductionStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
useChangeNameMutation,
useGetEventByIdQuery,
} from '@/hooks/api/events';
import { useGetProductionsQuery } from '@/hooks/api/productions';
import {
useAddEventByIdMutation as useAddEventToProductionByIdMutation,
useCreateWithEventsMutation as useCreateProductionWithEventsMutation,
useDeleteEventByIdMutation as useDeleteEventFromProductionByIdMutation,
useGetProductionsQuery,
} from '@/hooks/api/productions';
import type {
FormDataUnion,
Expand Down
1 change: 0 additions & 1 deletion src/pages/steps/ScopeStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Controller, ControllerRenderProps, Path } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

import { OfferType, OfferTypes } from '@/constants/OfferType';
import { Values } from '@/types/Values';
import { parseSpacing } from '@/ui/Box';
import { getInlineProps, Inline, InlineProps } from '@/ui/Inline';
import { ToggleBox } from '@/ui/ToggleBox';
Expand Down
3 changes: 1 addition & 2 deletions src/pages/steps/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import type {
} from 'react-hook-form';
import { useTranslation } from 'react-i18next';

import { OfferType, OfferTypes, Scope } from '@/constants/OfferType';
import { Scope } from '@/constants/OfferType';
import { SupportedLanguage } from '@/i18n/index';
import { Values } from '@/types/Values';
import type { BoxProps } from '@/ui/Box';
import { Box } from '@/ui/Box';
import type { StackProps } from '@/ui/Stack';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/steps/TimeTableStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { Alert, AlertVariants } from '@/ui/Alert';
import { Box } from '@/ui/Box';
import type { StackProps } from '@/ui/Stack';
import { getStackProps, Stack } from '@/ui/Stack';
import { TimeTableValue } from '@/ui/TimeTable';
import {
areAllTimeSlotsValid,
isTimeTableEmpty,
TimeTable,
TimeTableValue,
} from '@/ui/TimeTable';
import { formatDateToISO } from '@/utils/formatDateToISO';

Expand Down
1 change: 0 additions & 1 deletion src/pages/steps/hooks/usePublishOffer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMemo } from 'react';
import { useQueryClient } from 'react-query';

import { OfferTypes } from '@/constants/OfferType';
Expand Down
1 change: 0 additions & 1 deletion src/test/e2e/events/create-uitpas-event.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { faker } from '@faker-js/faker';
import { expect, test } from '@playwright/test';

const dummyEvent = {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/Alert.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs/blocks';
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
import { Alert, AlertVariants } from './Alert';

<Meta title="Components/Alert" component={Alert} />
Expand Down
39 changes: 6 additions & 33 deletions src/ui/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import type {
DragEvent,
FocusEvent,
FormEvent,
HTMLProps,
KeyboardEvent,
MouseEvent,
ReactNode,
} from 'react';
import { forwardRef } from 'react';
import { AsyncTypeaheadProps, TypeaheadModel } from 'react-bootstrap-typeahead';
import { ReactDatePickerProps } from 'react-datepicker';
import type {
FlattenInterpolation,
Expand Down Expand Up @@ -94,33 +94,7 @@ type ProgressBarProps = {
now: number;
};

type TypeaheadProps = {
options: unknown[];
labelKey: ((option: unknown) => string) | string;
isLoading: boolean;
disabled: boolean;
placeholder: string;
emptyLabel: string;
minLength: number;
delay: number;
highlightOnlyResult: boolean;
isInvalid: boolean;
promptText: string;
searchText: string;
positionFixed: boolean;
allowNew:
| boolean
| ((
results: Array<Record<string, unknown> | string>,
props: Record<string, unknown>,
) => boolean);
newSelectionPrefix: string;
renderMenuItemChildren?: (option: unknown, { text }) => JSX.Element;
inputProps: HTMLProps<HTMLInputElement>;
defaultInputValue: string;
};

type SpecificComponentProps = InlineProps &
type SpecificComponentProps<T extends TypeaheadModel> = InlineProps &
Omit<ReactDatePickerProps, 'onChange' | 'onSelect' | 'value' | 'selected'> &
TitleProps &
ListProps &
Expand All @@ -129,7 +103,7 @@ type SpecificComponentProps = InlineProps &
ImageProps &
SvgProps &
ProgressBarProps &
TypeaheadProps;
Omit<AsyncTypeaheadProps<T>, 'id' | 'size' | 'onChange' | 'selected'>;

type EventHandlerProps = {
onBlur: (event: ChangeEvent<HTMLInputElement>) => void;
Expand All @@ -142,7 +116,6 @@ type EventHandlerProps = {
onInputChange: (value: string) => void;
onMouseOver: (event: MouseEvent<HTMLFormElement>) => void;
onPaste: (event: ClipboardEvent<HTMLFormElement>) => void;
onSearch: (search: string) => void;
onSubmit: (event: FormEvent<HTMLFormElement>) => void;
onDragOver: (event: DragEvent<HTMLElement>) => void;
onDrop: (event: DragEvent<HTMLElement>) => void;
Expand Down Expand Up @@ -245,8 +218,8 @@ type UIProps = {
zIndex: UIProp<number>;
};

type BoxProps = Partial<
UIProps & GeneralProps & SpecificComponentProps & EventHandlerProps
type BoxProps<T extends TypeaheadModel = any> = Partial<
UIProps & GeneralProps & SpecificComponentProps<T> & EventHandlerProps
>;

const remInPixels = 15;
Expand Down Expand Up @@ -341,7 +314,7 @@ const parseProperty =
])
.sort(([valueA], [valueB]) => valueA - valueB);

return parsedBreakpoints.reduce((acc, [breakpoint, val], index) => {
return parsedBreakpoints.reduce((acc, [breakpoint, val]) => {
if (!breakpoint || val === undefined) return acc;
return css`
${wrapStatementWithBreakpoint(
Expand Down
Loading

0 comments on commit 8ca51f2

Please sign in to comment.