Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
fix: add reservation to series mutation
Browse files Browse the repository at this point in the history
- change to use new mutation to add to series
- fix: buffer toggles and rename the form keys
  • Loading branch information
joonatank committed Feb 5, 2025
1 parent 7136ef0 commit 30d60db
Show file tree
Hide file tree
Showing 10 changed files with 429 additions and 160 deletions.
150 changes: 135 additions & 15 deletions apps/admin-ui/gql/gql-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,7 @@ export enum LoginMethod {
}

export type Mutation = {
addReservationToSeries?: Maybe<ReservationSeriesAddMutationPayload>;
adjustReservationTime?: Maybe<ReservationAdjustTimeMutationPayload>;
approveReservation?: Maybe<ReservationApproveMutationPayload>;
cancelAllApplicationSectionReservations?: Maybe<ApplicationSectionReservationCancellationMutationPayload>;
Expand Down Expand Up @@ -1224,6 +1225,8 @@ export type Mutation = {
setApplicationRoundHandled?: Maybe<SetApplicationRoundHandledMutationPayload>;
setApplicationRoundResultsSent?: Maybe<SetApplicationRoundResultsSentMutationPayload>;
staffAdjustReservationTime?: Maybe<ReservationStaffAdjustTimeMutationPayload>;
staffChangeReservationAccessCode?: Maybe<ReservationStaffChangeAccessCodeMutationPayload>;
staffRepairReservationAccessCode?: Maybe<ReservationStaffRepairAccessCodeMutationPayload>;
staffReservationModify?: Maybe<ReservationStaffModifyMutationPayload>;
updateApplication?: Maybe<ApplicationUpdateMutationPayload>;
updateApplicationSection?: Maybe<ApplicationSectionUpdateMutationPayload>;
Expand All @@ -1244,6 +1247,10 @@ export type Mutation = {
updateUnit?: Maybe<UnitUpdateMutationPayload>;
};

export type MutationAddReservationToSeriesArgs = {
input: ReservationSeriesAddMutationInput;
};

export type MutationAdjustReservationTimeArgs = {
input: ReservationAdjustTimeMutationInput;
};
Expand Down Expand Up @@ -1420,6 +1427,14 @@ export type MutationStaffAdjustReservationTimeArgs = {
input: ReservationStaffAdjustTimeMutationInput;
};

export type MutationStaffChangeReservationAccessCodeArgs = {
input: ReservationStaffChangeAccessCodeMutationInput;
};

export type MutationStaffRepairReservationAccessCodeArgs = {
input: ReservationStaffRepairAccessCodeMutationInput;
};

export type MutationStaffReservationModifyArgs = {
input: ReservationStaffModifyMutationInput;
};
Expand Down Expand Up @@ -1642,6 +1657,18 @@ export type PersonSerializerInput = {
pk?: InputMaybe<Scalars["Int"]["input"]>;
};

export type PindoraInfoType = {
accessCode: Scalars["String"]["output"];
accessCodeBeginsAt: Scalars["DateTime"]["output"];
accessCodeEndsAt: Scalars["DateTime"]["output"];
accessCodeGeneratedAt: Scalars["DateTime"]["output"];
accessCodeIsActive: Scalars["Boolean"]["output"];
accessCodeKeypadUrl: Scalars["String"]["output"];
accessCodePhoneNumber: Scalars["String"]["output"];
accessCodeSmsMessage: Scalars["String"]["output"];
accessCodeSmsNumber: Scalars["String"]["output"];
};

/** An enumeration. */
export enum PreferredLanguage {
/** Englanti */
Expand Down Expand Up @@ -2853,6 +2880,10 @@ export type ReservationMetadataSetNodeEdge = {
};

export type ReservationNode = Node & {
accessCodeGeneratedAt?: Maybe<Scalars["DateTime"]["output"]>;
accessCodeIsActive: Scalars["Boolean"]["output"];
accessCodeShouldBeActive?: Maybe<Scalars["Boolean"]["output"]>;
accessType: AccessType;
/** Which reservation units' reserveability is affected by this reservation? */
affectedReservationUnits?: Maybe<Array<Maybe<Scalars["Int"]["output"]>>>;
ageGroup?: Maybe<AgeGroupNode>;
Expand Down Expand Up @@ -2888,6 +2919,8 @@ export type ReservationNode = Node & {
/** @deprecated Please use to 'paymentOrder' instead. */
order?: Maybe<PaymentOrderNode>;
paymentOrder: Array<PaymentOrderNode>;
/** Info fetched from Pindora API. Cached per reservation for 30s. Please don't use this when filtering multiple reservations, queries to Pindora are not optimized. */
pindoraInfo?: Maybe<PindoraInfoType>;
pk?: Maybe<Scalars["Int"]["output"]>;
price?: Maybe<Scalars["Decimal"]["output"]>;
priceNet?: Maybe<Scalars["Decimal"]["output"]>;
Expand Down Expand Up @@ -3092,6 +3125,18 @@ export type ReservationRequiresHandlingMutationPayload = {
state?: Maybe<ReservationStateChoice>;
};

export type ReservationSeriesAddMutationInput = {
begin: Scalars["DateTime"]["input"];
bufferTimeAfter?: InputMaybe<Scalars["String"]["input"]>;
bufferTimeBefore?: InputMaybe<Scalars["String"]["input"]>;
end: Scalars["DateTime"]["input"];
pk: Scalars["Int"]["input"];
};

export type ReservationSeriesAddMutationPayload = {
pk?: Maybe<Scalars["Int"]["output"]>;
};

export type ReservationSeriesCreateMutationInput = {
abilityGroup?: InputMaybe<Scalars["Int"]["input"]>;
ageGroup?: InputMaybe<Scalars["Int"]["input"]>;
Expand Down Expand Up @@ -3184,7 +3229,6 @@ export type ReservationSeriesReservationCreateSerializerInput = {
reserveeFirstName?: InputMaybe<Scalars["String"]["input"]>;
reserveeId?: InputMaybe<Scalars["String"]["input"]>;
reserveeIsUnregisteredAssociation?: InputMaybe<Scalars["Boolean"]["input"]>;
reserveeLanguage?: InputMaybe<ReserveeLanguage>;
reserveeLastName?: InputMaybe<Scalars["String"]["input"]>;
reserveeOrganisationName?: InputMaybe<Scalars["String"]["input"]>;
reserveePhone?: InputMaybe<Scalars["String"]["input"]>;
Expand Down Expand Up @@ -3228,6 +3272,16 @@ export type ReservationStaffAdjustTimeMutationPayload = {
state?: Maybe<ReservationStateChoice>;
};

export type ReservationStaffChangeAccessCodeMutationInput = {
pk: Scalars["Int"]["input"];
};

export type ReservationStaffChangeAccessCodeMutationPayload = {
accessCodeGeneratedAt?: Maybe<Scalars["DateTime"]["output"]>;
accessCodeIsActive?: Maybe<Scalars["Boolean"]["output"]>;
pk?: Maybe<Scalars["Int"]["output"]>;
};

export type ReservationStaffCreateMutationInput = {
ageGroup?: InputMaybe<Scalars["Int"]["input"]>;
applyingForFreeOfCharge?: InputMaybe<Scalars["Boolean"]["input"]>;
Expand Down Expand Up @@ -3328,7 +3382,6 @@ export type ReservationStaffModifyMutationInput = {
reserveeFirstName?: InputMaybe<Scalars["String"]["input"]>;
reserveeId?: InputMaybe<Scalars["String"]["input"]>;
reserveeIsUnregisteredAssociation?: InputMaybe<Scalars["Boolean"]["input"]>;
reserveeLanguage?: InputMaybe<ReserveeLanguage>;
reserveeLastName?: InputMaybe<Scalars["String"]["input"]>;
reserveeOrganisationName?: InputMaybe<Scalars["String"]["input"]>;
reserveePhone?: InputMaybe<Scalars["String"]["input"]>;
Expand Down Expand Up @@ -3369,7 +3422,6 @@ export type ReservationStaffModifyMutationPayload = {
reserveeFirstName?: Maybe<Scalars["String"]["output"]>;
reserveeId?: Maybe<Scalars["String"]["output"]>;
reserveeIsUnregisteredAssociation?: Maybe<Scalars["Boolean"]["output"]>;
reserveeLanguage?: Maybe<ReserveeLanguage>;
reserveeLastName?: Maybe<Scalars["String"]["output"]>;
reserveeOrganisationName?: Maybe<Scalars["String"]["output"]>;
reserveePhone?: Maybe<Scalars["String"]["output"]>;
Expand All @@ -3380,6 +3432,16 @@ export type ReservationStaffModifyMutationPayload = {
unitPrice?: Maybe<Scalars["Decimal"]["output"]>;
};

export type ReservationStaffRepairAccessCodeMutationInput = {
pk: Scalars["Int"]["input"];
};

export type ReservationStaffRepairAccessCodeMutationPayload = {
accessCodeGeneratedAt?: Maybe<Scalars["DateTime"]["output"]>;
accessCodeIsActive?: Maybe<Scalars["Boolean"]["output"]>;
pk?: Maybe<Scalars["Int"]["output"]>;
};

/** An enumeration. */
export enum ReservationStartInterval {
/** 15 minuuttia */
Expand Down Expand Up @@ -3478,6 +3540,9 @@ export enum ReservationUnitCancellationRuleOrderingChoices {
}

export type ReservationUnitCreateMutationInput = {
accessType?: InputMaybe<AccessType>;
accessTypeEndDate?: InputMaybe<Scalars["Date"]["input"]>;
accessTypeStartDate?: InputMaybe<Scalars["Date"]["input"]>;
allowReservationsWithoutOpeningHours?: InputMaybe<
Scalars["Boolean"]["input"]
>;
Expand Down Expand Up @@ -3557,6 +3622,9 @@ export type ReservationUnitCreateMutationInput = {
};

export type ReservationUnitCreateMutationPayload = {
accessType?: Maybe<AccessType>;
accessTypeEndDate?: Maybe<Scalars["Date"]["output"]>;
accessTypeStartDate?: Maybe<Scalars["Date"]["output"]>;
allowReservationsWithoutOpeningHours?: Maybe<Scalars["Boolean"]["output"]>;
applicationRoundTimeSlots?: Maybe<Array<Maybe<ApplicationRoundTimeSlotNode>>>;
authentication?: Maybe<Authentication>;
Expand Down Expand Up @@ -4068,6 +4136,9 @@ export enum ReservationUnitTypeOrderingChoices {
}

export type ReservationUnitUpdateMutationInput = {
accessType?: InputMaybe<AccessType>;
accessTypeEndDate?: InputMaybe<Scalars["Date"]["input"]>;
accessTypeStartDate?: InputMaybe<Scalars["Date"]["input"]>;
allowReservationsWithoutOpeningHours?: InputMaybe<
Scalars["Boolean"]["input"]
>;
Expand Down Expand Up @@ -4147,6 +4218,9 @@ export type ReservationUnitUpdateMutationInput = {
};

export type ReservationUnitUpdateMutationPayload = {
accessType?: Maybe<AccessType>;
accessTypeEndDate?: Maybe<Scalars["Date"]["output"]>;
accessTypeStartDate?: Maybe<Scalars["Date"]["output"]>;
allowReservationsWithoutOpeningHours?: Maybe<Scalars["Boolean"]["output"]>;
applicationRoundTimeSlots?: Maybe<Array<Maybe<ApplicationRoundTimeSlotNode>>>;
authentication?: Maybe<Authentication>;
Expand Down Expand Up @@ -4290,17 +4364,6 @@ export type ReservationWorkingMemoMutationPayload = {
workingMemo?: Maybe<Scalars["String"]["output"]>;
};

/** An enumeration. */
export enum ReserveeLanguage {
A = "A_",
/** Englanti */
En = "EN",
/** Suomi */
Fi = "FI",
/** Ruotsi */
Sv = "SV",
}

/** An enumeration. */
export enum ReserveeType {
/** Yritys */
Expand Down Expand Up @@ -5055,7 +5118,6 @@ export type UpdateReservationSeriesReservationUpdateSerializerInput = {
reserveeFirstName?: InputMaybe<Scalars["String"]["input"]>;
reserveeId?: InputMaybe<Scalars["String"]["input"]>;
reserveeIsUnregisteredAssociation?: InputMaybe<Scalars["Boolean"]["input"]>;
reserveeLanguage?: InputMaybe<ReserveeLanguage>;
reserveeLastName?: InputMaybe<Scalars["String"]["input"]>;
reserveeOrganisationName?: InputMaybe<Scalars["String"]["input"]>;
reserveePhone?: InputMaybe<Scalars["String"]["input"]>;
Expand Down Expand Up @@ -6094,6 +6156,14 @@ export type StaffAdjustReservationTimeMutation = {
} | null;
};

export type AddReservationToSeriesMutationVariables = Exact<{
input: ReservationSeriesAddMutationInput;
}>;

export type AddReservationToSeriesMutation = {
addReservationToSeries?: { pk?: number | null } | null;
};

export type ChangeReservationTimeFragment = {
id: string;
pk?: number | null;
Expand Down Expand Up @@ -10292,6 +10362,56 @@ export type StaffAdjustReservationTimeMutationOptions =
StaffAdjustReservationTimeMutation,
StaffAdjustReservationTimeMutationVariables
>;
export const AddReservationToSeriesDocument = gql`
mutation AddReservationToSeries($input: ReservationSeriesAddMutationInput!) {
addReservationToSeries(input: $input) {
pk
}
}
`;
export type AddReservationToSeriesMutationFn = Apollo.MutationFunction<
AddReservationToSeriesMutation,
AddReservationToSeriesMutationVariables
>;

/**
* __useAddReservationToSeriesMutation__
*
* To run a mutation, you first call `useAddReservationToSeriesMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useAddReservationToSeriesMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [addReservationToSeriesMutation, { data, loading, error }] = useAddReservationToSeriesMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useAddReservationToSeriesMutation(
baseOptions?: Apollo.MutationHookOptions<
AddReservationToSeriesMutation,
AddReservationToSeriesMutationVariables
>
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useMutation<
AddReservationToSeriesMutation,
AddReservationToSeriesMutationVariables
>(AddReservationToSeriesDocument, options);
}
export type AddReservationToSeriesMutationHookResult = ReturnType<
typeof useAddReservationToSeriesMutation
>;
export type AddReservationToSeriesMutationResult =
Apollo.MutationResult<AddReservationToSeriesMutation>;
export type AddReservationToSeriesMutationOptions = Apollo.BaseMutationOptions<
AddReservationToSeriesMutation,
AddReservationToSeriesMutationVariables
>;
export const UpdateReservationWorkingMemoDocument = gql`
mutation UpdateReservationWorkingMemo($pk: Int!, $workingMemo: String!) {
updateReservationWorkingMemo(
Expand Down
14 changes: 8 additions & 6 deletions apps/admin-ui/src/component/BufferToggles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import { useTranslation } from "react-i18next";
import { Flex } from "common/styles/util";

type BufferControllerProps = {
name: "bufferTimeBefore" | "bufferTimeAfter";
name: "enableBufferTimeBefore" | "enableBufferTimeAfter";
seconds: number;
control: ReturnType<typeof useFormContext>["control"];
};

function BufferController({ name, seconds, control }: BufferControllerProps) {
const { t } = useTranslation();

const trKeyName = name.replace("enableB", "b");
const label = t(`reservationApplication:buffers.${trKeyName}`, {
minutes: seconds / 60,
});
return (
<Controller
name={name}
Expand All @@ -21,9 +25,7 @@ function BufferController({ name, seconds, control }: BufferControllerProps) {
<Checkbox
id={name}
checked={String(value) === "true"}
label={t(`reservationApplication:buffers.${name}`, {
minutes: seconds / 60,
})}
label={label}
value={String(value)}
onChange={() => {
onChange(!value);
Expand Down Expand Up @@ -57,14 +59,14 @@ export function BufferToggles({
</Flex>
{before !== 0 && (
<BufferController
name="bufferTimeBefore"
name="enableBufferTimeBefore"
control={control}
seconds={before}
/>
)}
{after !== 0 && (
<BufferController
name="bufferTimeAfter"
name="enableBufferTimeAfter"
control={control}
seconds={after}
/>
Expand Down
Loading

0 comments on commit 30d60db

Please sign in to comment.