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

Refactor seasonal reservation #1443

Merged
merged 16 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
265 changes: 0 additions & 265 deletions apps/admin-ui/gql/gql-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5697,179 +5697,6 @@ export type ApplicationCommonFragment = {
} | null;
};

export type ApplicationQueryVariables = Exact<{
id: Scalars["ID"]["input"];
}>;

export type ApplicationQuery = {
application?: {
id: string;
pk?: number | null;
status?: ApplicationStatusChoice | null;
lastModifiedDate: string;
applicantType?: ApplicantTypeChoice | null;
additionalInformation?: string | null;
applicationRound: {
id: string;
notesWhenApplyingFi?: string | null;
notesWhenApplyingEn?: string | null;
notesWhenApplyingSv?: string | null;
pk?: number | null;
nameFi?: string | null;
nameSv?: string | null;
nameEn?: string | null;
applicationPeriodBegin: string;
applicationPeriodEnd: string;
reservationPeriodBegin: string;
reservationPeriodEnd: string;
status?: ApplicationRoundStatusChoice | null;
applicationsCount?: number | null;
reservationUnitCount?: number | null;
statusTimestamp?: string | null;
termsOfUse?: {
id: string;
pk?: string | null;
termsType: TermsType;
nameFi?: string | null;
nameEn?: string | null;
nameSv?: string | null;
textFi?: string | null;
textEn?: string | null;
textSv?: string | null;
} | null;
reservationUnits: Array<{
id: string;
pk?: number | null;
nameFi?: string | null;
nameSv?: string | null;
nameEn?: string | null;
minPersons?: number | null;
maxPersons?: number | null;
images: Array<{
id: string;
imageUrl?: string | null;
largeUrl?: string | null;
mediumUrl?: string | null;
smallUrl?: string | null;
imageType: ImageType;
}>;
unit?: {
id: string;
pk?: number | null;
nameFi?: string | null;
nameSv?: string | null;
nameEn?: string | null;
} | null;
}>;
};
applicationSections?: Array<{
id: string;
pk?: number | null;
name: string;
status?: ApplicationSectionStatusChoice | null;
reservationMaxDuration: number;
numPersons: number;
reservationsEndDate: string;
reservationsBeginDate: string;
appliedReservationsPerWeek: number;
reservationMinDuration: number;
suitableTimeRanges: Array<{
id: string;
pk?: number | null;
beginTime: string;
endTime: string;
dayOfTheWeek: Weekday;
priority: Priority;
}>;
purpose?: {
id: string;
pk?: number | null;
nameFi?: string | null;
nameSv?: string | null;
nameEn?: string | null;
} | null;
reservationUnitOptions: Array<{
id: string;
pk?: number | null;
preferredOrder: number;
reservationUnit: {
id: string;
pk?: number | null;
nameFi?: string | null;
nameEn?: string | null;
nameSv?: string | null;
unit?: {
id: string;
pk?: number | null;
nameFi?: string | null;
nameEn?: string | null;
nameSv?: string | null;
} | null;
applicationRoundTimeSlots: Array<{
id: string;
weekday: number;
closed: boolean;
reservableTimes?: Array<{
begin: string;
end: string;
} | null> | null;
}>;
};
}>;
ageGroup?: {
id: string;
pk?: number | null;
minimum: number;
maximum?: number | null;
} | null;
}> | null;
contactPerson?: {
id: string;
pk?: number | null;
firstName: string;
lastName: string;
email?: string | null;
phoneNumber?: string | null;
} | null;
organisation?: {
id: string;
pk?: number | null;
nameFi?: string | null;
identifier?: string | null;
organisationType: OrganizationTypeChoice;
coreBusinessFi?: string | null;
yearEstablished?: number | null;
address?: {
id: string;
pk?: number | null;
postCode: string;
streetAddressFi?: string | null;
cityFi?: string | null;
} | null;
} | null;
homeCity?: {
id: string;
pk?: number | null;
nameFi?: string | null;
nameEn?: string | null;
nameSv?: string | null;
} | null;
billingAddress?: {
id: string;
pk?: number | null;
postCode: string;
streetAddressFi?: string | null;
cityFi?: string | null;
} | null;
user?: {
id: string;
name?: string | null;
email: string;
pk?: number | null;
} | null;
} | null;
};

export type ReserveeNameFieldsFragment = {
reserveeFirstName?: string | null;
reserveeLastName?: string | null;
Expand Down Expand Up @@ -9878,98 +9705,6 @@ export type BannerNotificationsListQueryResult = Apollo.QueryResult<
BannerNotificationsListQuery,
BannerNotificationsListQueryVariables
>;
export const ApplicationDocument = gql`
query Application($id: ID!) {
application(id: $id) {
...ApplicationCommon
applicationRound {
id
notesWhenApplyingFi
notesWhenApplyingEn
notesWhenApplyingSv
termsOfUse {
id
...TermsOfUseFields
}
}
}
}
${ApplicationCommonFragmentDoc}
${TermsOfUseFieldsFragmentDoc}
`;

/**
* __useApplicationQuery__
*
* To run a query within a React component, call `useApplicationQuery` and pass it any options that fit your needs.
* When your component renders, `useApplicationQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI.
*
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
*
* @example
* const { data, loading, error } = useApplicationQuery({
* variables: {
* id: // value for 'id'
* },
* });
*/
export function useApplicationQuery(
baseOptions: Apollo.QueryHookOptions<
ApplicationQuery,
ApplicationQueryVariables
> &
(
| { variables: ApplicationQueryVariables; skip?: boolean }
| { skip: boolean }
)
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useQuery<ApplicationQuery, ApplicationQueryVariables>(
ApplicationDocument,
options
);
}
export function useApplicationLazyQuery(
baseOptions?: Apollo.LazyQueryHookOptions<
ApplicationQuery,
ApplicationQueryVariables
>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<ApplicationQuery, ApplicationQueryVariables>(
ApplicationDocument,
options
);
}
export function useApplicationSuspenseQuery(
baseOptions?:
| Apollo.SkipToken
| Apollo.SuspenseQueryHookOptions<
ApplicationQuery,
ApplicationQueryVariables
>
) {
const options =
baseOptions === Apollo.skipToken
? baseOptions
: { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<ApplicationQuery, ApplicationQueryVariables>(
ApplicationDocument,
options
);
}
export type ApplicationQueryHookResult = ReturnType<typeof useApplicationQuery>;
export type ApplicationLazyQueryHookResult = ReturnType<
typeof useApplicationLazyQuery
>;
export type ApplicationSuspenseQueryHookResult = ReturnType<
typeof useApplicationSuspenseQuery
>;
export type ApplicationQueryResult = Apollo.QueryResult<
ApplicationQuery,
ApplicationQueryVariables
>;
export const TermsOfUseDocument = gql`
query TermsOfUse($termsType: TermsType) {
termsOfUse(termsType: $termsType) {
Expand Down
23 changes: 11 additions & 12 deletions apps/ui/components/application/ApplicationEventList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { StyledLabelValue, TimePreviewContainer } from "./styled";
import { TwoColumnContainer, FormSubHeading } from "../common/common";
import { AccordionWithState as Accordion } from "../common/Accordion";
import { UnitList } from "./UnitList";
import { filterNonNullable } from "common/src/helpers";

const filterPrimary = (n: { priority: Priority }) =>
n.priority === Priority.Primary;
Expand Down Expand Up @@ -63,18 +64,16 @@ type Node = NonNullable<ApplicationQuery["application"]>;
export function ApplicationEventList({ application }: { application: Node }) {
const { t } = useTranslation();

const aes = application.applicationSections ?? [];
const reservationUnits =
aes.map(
(evt) =>
evt?.reservationUnitOptions?.map((eru, index) => ({
pk: eru.reservationUnit?.pk ?? 0,
priority: index,
nameFi: eru.reservationUnit?.nameFi ?? undefined,
nameSv: eru.reservationUnit?.nameSv ?? undefined,
nameEn: eru.reservationUnit?.nameEn ?? undefined,
})) ?? []
) ?? [];
const aes = filterNonNullable(application.applicationSections);
const reservationUnits = aes.map((evt) =>
evt?.reservationUnitOptions?.map((eru, index) => ({
pk: eru.reservationUnit?.pk ?? 0,
priority: index,
nameFi: eru.reservationUnit?.nameFi ?? undefined,
nameSv: eru.reservationUnit?.nameSv ?? undefined,
nameEn: eru.reservationUnit?.nameEn ?? undefined,
}))
);

return (
<>
Expand Down
Loading