Skip to content

Commit

Permalink
fix: type errors from api change
Browse files Browse the repository at this point in the history
  • Loading branch information
joonatank committed Sep 13, 2024
1 parent 45e43c9 commit 4c71d53
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 77 deletions.
83 changes: 50 additions & 33 deletions apps/admin-ui/gql/gql-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ export type ApplicationRoundNodeReservationUnitsArgs = {
onlyWithPermission?: InputMaybe<Scalars["Boolean"]["input"]>;
orderBy?: InputMaybe<Array<InputMaybe<ReservationUnitOrderingChoices>>>;
pk?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
publishingState?: InputMaybe<
Array<InputMaybe<ReservationUnitPublishingState>>
>;
purposes?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
qualifiers?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
rankGte?: InputMaybe<Scalars["Decimal"]["input"]>;
Expand All @@ -414,10 +417,11 @@ export type ApplicationRoundNodeReservationUnitsArgs = {
reservableTimeEnd?: InputMaybe<Scalars["Time"]["input"]>;
reservableTimeStart?: InputMaybe<Scalars["Time"]["input"]>;
reservationKind?: InputMaybe<Scalars["String"]["input"]>;
reservationState?: InputMaybe<Array<InputMaybe<ReservationState>>>;
reservationState?: InputMaybe<
Array<InputMaybe<ReservationUnitReservationState>>
>;
reservationUnitType?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
showOnlyReservable?: InputMaybe<Scalars["Boolean"]["input"]>;
state?: InputMaybe<Array<InputMaybe<ReservationUnitState>>>;
surfaceAreaGte?: InputMaybe<Scalars["Decimal"]["input"]>;
surfaceAreaLte?: InputMaybe<Scalars["Decimal"]["input"]>;
textSearch?: InputMaybe<Scalars["String"]["input"]>;
Expand Down Expand Up @@ -2296,6 +2300,9 @@ export type QueryReservationUnitsArgs = {
onlyWithPermission?: InputMaybe<Scalars["Boolean"]["input"]>;
orderBy?: InputMaybe<Array<InputMaybe<ReservationUnitOrderingChoices>>>;
pk?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
publishingState?: InputMaybe<
Array<InputMaybe<ReservationUnitPublishingState>>
>;
purposes?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
qualifiers?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
rankGte?: InputMaybe<Scalars["Decimal"]["input"]>;
Expand All @@ -2306,10 +2313,11 @@ export type QueryReservationUnitsArgs = {
reservableTimeEnd?: InputMaybe<Scalars["Time"]["input"]>;
reservableTimeStart?: InputMaybe<Scalars["Time"]["input"]>;
reservationKind?: InputMaybe<Scalars["String"]["input"]>;
reservationState?: InputMaybe<Array<InputMaybe<ReservationState>>>;
reservationState?: InputMaybe<
Array<InputMaybe<ReservationUnitReservationState>>
>;
reservationUnitType?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
showOnlyReservable?: InputMaybe<Scalars["Boolean"]["input"]>;
state?: InputMaybe<Array<InputMaybe<ReservationUnitState>>>;
surfaceAreaGte?: InputMaybe<Scalars["Decimal"]["input"]>;
surfaceAreaLte?: InputMaybe<Scalars["Decimal"]["input"]>;
textSearch?: InputMaybe<Scalars["String"]["input"]>;
Expand Down Expand Up @@ -3112,6 +3120,9 @@ export type ReservationNodeReservationUnitArgs = {
onlyWithPermission?: InputMaybe<Scalars["Boolean"]["input"]>;
orderBy?: InputMaybe<Array<InputMaybe<ReservationUnitOrderingChoices>>>;
pk?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
publishingState?: InputMaybe<
Array<InputMaybe<ReservationUnitPublishingState>>
>;
purposes?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
qualifiers?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
rankGte?: InputMaybe<Scalars["Decimal"]["input"]>;
Expand All @@ -3122,10 +3133,11 @@ export type ReservationNodeReservationUnitArgs = {
reservableTimeEnd?: InputMaybe<Scalars["Time"]["input"]>;
reservableTimeStart?: InputMaybe<Scalars["Time"]["input"]>;
reservationKind?: InputMaybe<Scalars["String"]["input"]>;
reservationState?: InputMaybe<Array<InputMaybe<ReservationState>>>;
reservationState?: InputMaybe<
Array<InputMaybe<ReservationUnitReservationState>>
>;
reservationUnitType?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
showOnlyReservable?: InputMaybe<Scalars["Boolean"]["input"]>;
state?: InputMaybe<Array<InputMaybe<ReservationUnitState>>>;
surfaceAreaGte?: InputMaybe<Scalars["Decimal"]["input"]>;
surfaceAreaLte?: InputMaybe<Scalars["Decimal"]["input"]>;
textSearch?: InputMaybe<Scalars["String"]["input"]>;
Expand Down Expand Up @@ -3525,15 +3537,6 @@ export enum ReservationStartInterval {
Interval_420Mins = "INTERVAL_420_MINS",
}

/** An enumeration. */
export enum ReservationState {
Reservable = "RESERVABLE",
ReservationClosed = "RESERVATION_CLOSED",
ScheduledClosing = "SCHEDULED_CLOSING",
ScheduledPeriod = "SCHEDULED_PERIOD",
ScheduledReservation = "SCHEDULED_RESERVATION",
}

/** An enumeration. */
export enum ReservationStateChoice {
Cancelled = "CANCELLED",
Expand Down Expand Up @@ -3712,6 +3715,7 @@ export type ReservationUnitCreateMutationPayload = {
pricings?: Maybe<Array<Maybe<ReservationUnitPricingNode>>>;
publishBegins?: Maybe<Scalars["DateTime"]["output"]>;
publishEnds?: Maybe<Scalars["DateTime"]["output"]>;
publishingState?: Maybe<Scalars["String"]["output"]>;
purposes?: Maybe<Array<Maybe<Scalars["Int"]["output"]>>>;
qualifiers?: Maybe<Array<Maybe<Scalars["Int"]["output"]>>>;
requireIntroduction?: Maybe<Scalars["Boolean"]["output"]>;
Expand Down Expand Up @@ -3740,7 +3744,6 @@ export type ReservationUnitCreateMutationPayload = {
serviceSpecificTerms?: Maybe<Scalars["String"]["output"]>;
services?: Maybe<Array<Maybe<Scalars["Int"]["output"]>>>;
spaces?: Maybe<Array<Maybe<Scalars["Int"]["output"]>>>;
state?: Maybe<Scalars["String"]["output"]>;
surfaceArea?: Maybe<Scalars["Int"]["output"]>;
termsOfUse?: Maybe<Scalars["String"]["output"]>;
termsOfUseEn?: Maybe<Scalars["String"]["output"]>;
Expand Down Expand Up @@ -3846,6 +3849,7 @@ export type ReservationUnitNode = Node & {
pricings: Array<ReservationUnitPricingNode>;
publishBegins?: Maybe<Scalars["DateTime"]["output"]>;
publishEnds?: Maybe<Scalars["DateTime"]["output"]>;
publishingState?: Maybe<ReservationUnitPublishingState>;
purposes: Array<PurposeNode>;
qualifiers: Array<QualifierNode>;
rank?: Maybe<Scalars["Int"]["output"]>;
Expand All @@ -3870,15 +3874,14 @@ export type ReservationUnitNode = Node & {
reservationPendingInstructionsSv?: Maybe<Scalars["String"]["output"]>;
reservationSet?: Maybe<Array<ReservationNode>>;
reservationStartInterval: ReservationStartInterval;
reservationState?: Maybe<ReservationState>;
reservationState?: Maybe<ReservationUnitReservationState>;
reservationUnitType?: Maybe<ReservationUnitTypeNode>;
reservationsMaxDaysBefore?: Maybe<Scalars["Int"]["output"]>;
reservationsMinDaysBefore?: Maybe<Scalars["Int"]["output"]>;
resources: Array<ResourceNode>;
serviceSpecificTerms?: Maybe<TermsOfUseNode>;
services: Array<ServiceNode>;
spaces: Array<SpaceNode>;
state?: Maybe<ReservationUnitState>;
surfaceArea?: Maybe<Scalars["Int"]["output"]>;
termsOfUse?: Maybe<Scalars["String"]["output"]>;
termsOfUseEn?: Maybe<Scalars["String"]["output"]>;
Expand Down Expand Up @@ -4142,7 +4145,7 @@ export type ReservationUnitPricingSerializerInput = {
};

/** An enumeration. */
export enum ReservationUnitState {
export enum ReservationUnitPublishingState {
Archived = "ARCHIVED",
Draft = "DRAFT",
Hidden = "HIDDEN",
Expand All @@ -4152,6 +4155,15 @@ export enum ReservationUnitState {
ScheduledPublishing = "SCHEDULED_PUBLISHING",
}

/** An enumeration. */
export enum ReservationUnitReservationState {
Reservable = "RESERVABLE",
ReservationClosed = "RESERVATION_CLOSED",
ScheduledClosing = "SCHEDULED_CLOSING",
ScheduledPeriod = "SCHEDULED_PERIOD",
ScheduledReservation = "SCHEDULED_RESERVATION",
}

export type ReservationUnitTypeNode = Node & {
/** The ID of the object */
id: Scalars["ID"]["output"];
Expand Down Expand Up @@ -4306,6 +4318,7 @@ export type ReservationUnitUpdateMutationPayload = {
pricings?: Maybe<Array<Maybe<ReservationUnitPricingNode>>>;
publishBegins?: Maybe<Scalars["DateTime"]["output"]>;
publishEnds?: Maybe<Scalars["DateTime"]["output"]>;
publishingState?: Maybe<Scalars["String"]["output"]>;
purposes?: Maybe<Array<Maybe<Scalars["Int"]["output"]>>>;
qualifiers?: Maybe<Array<Maybe<Scalars["Int"]["output"]>>>;
requireIntroduction?: Maybe<Scalars["Boolean"]["output"]>;
Expand Down Expand Up @@ -4334,7 +4347,6 @@ export type ReservationUnitUpdateMutationPayload = {
serviceSpecificTerms?: Maybe<Scalars["String"]["output"]>;
services?: Maybe<Array<Maybe<Scalars["Int"]["output"]>>>;
spaces?: Maybe<Array<Maybe<Scalars["Int"]["output"]>>>;
state?: Maybe<Scalars["String"]["output"]>;
surfaceArea?: Maybe<Scalars["Int"]["output"]>;
termsOfUse?: Maybe<Scalars["String"]["output"]>;
termsOfUseEn?: Maybe<Scalars["String"]["output"]>;
Expand Down Expand Up @@ -4994,6 +5006,9 @@ export type UnitNodeReservationunitSetArgs = {
onlyWithPermission?: InputMaybe<Scalars["Boolean"]["input"]>;
orderBy?: InputMaybe<Array<InputMaybe<ReservationUnitOrderingChoices>>>;
pk?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
publishingState?: InputMaybe<
Array<InputMaybe<ReservationUnitPublishingState>>
>;
purposes?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
qualifiers?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
rankGte?: InputMaybe<Scalars["Decimal"]["input"]>;
Expand All @@ -5004,10 +5019,11 @@ export type UnitNodeReservationunitSetArgs = {
reservableTimeEnd?: InputMaybe<Scalars["Time"]["input"]>;
reservableTimeStart?: InputMaybe<Scalars["Time"]["input"]>;
reservationKind?: InputMaybe<Scalars["String"]["input"]>;
reservationState?: InputMaybe<Array<InputMaybe<ReservationState>>>;
reservationState?: InputMaybe<
Array<InputMaybe<ReservationUnitReservationState>>
>;
reservationUnitType?: InputMaybe<Array<InputMaybe<Scalars["Int"]["input"]>>>;
showOnlyReservable?: InputMaybe<Scalars["Boolean"]["input"]>;
state?: InputMaybe<Array<InputMaybe<ReservationUnitState>>>;
surfaceAreaGte?: InputMaybe<Scalars["Decimal"]["input"]>;
surfaceAreaLte?: InputMaybe<Scalars["Decimal"]["input"]>;
textSearch?: InputMaybe<Scalars["String"]["input"]>;
Expand Down Expand Up @@ -6708,8 +6724,9 @@ export type SearchReservationUnitsQueryVariables = Exact<{
| Array<InputMaybe<ReservationUnitOrderingChoices>>
| InputMaybe<ReservationUnitOrderingChoices>
>;
state?: InputMaybe<
Array<InputMaybe<ReservationUnitState>> | InputMaybe<ReservationUnitState>
publishingState?: InputMaybe<
| Array<InputMaybe<ReservationUnitPublishingState>>
| InputMaybe<ReservationUnitPublishingState>
>;
}>;

Expand All @@ -6723,8 +6740,8 @@ export type SearchReservationUnitsQuery = {
nameFi?: string | null;
maxPersons?: number | null;
surfaceArea?: number | null;
state?: ReservationUnitState | null;
reservationState?: ReservationState | null;
publishingState?: ReservationUnitPublishingState | null;
reservationState?: ReservationUnitReservationState | null;
unit?: {
id: string;
nameFi?: string | null;
Expand Down Expand Up @@ -7460,8 +7477,8 @@ export type ReservationUnitEditQuery = {
reservationUnit?: {
id: string;
pk?: number | null;
state?: ReservationUnitState | null;
reservationState?: ReservationState | null;
publishingState?: ReservationUnitPublishingState | null;
reservationState?: ReservationUnitReservationState | null;
haukiUrl?: string | null;
requireReservationHandling: boolean;
nameFi?: string | null;
Expand Down Expand Up @@ -11571,7 +11588,7 @@ export const SearchReservationUnitsDocument = gql`
$unit: [Int]
$reservationUnitType: [Int]
$orderBy: [ReservationUnitOrderingChoices]
$state: [ReservationUnitState]
$publishingState: [ReservationUnitPublishingState]
) {
reservationUnits(
first: $first
Expand All @@ -11586,7 +11603,7 @@ export const SearchReservationUnitsDocument = gql`
surfaceAreaLte: $surfaceAreaLte
unit: $unit
reservationUnitType: $reservationUnitType
state: $state
publishingState: $publishingState
onlyWithPermission: true
) {
edges {
Expand All @@ -11605,7 +11622,7 @@ export const SearchReservationUnitsDocument = gql`
}
maxPersons
surfaceArea
state
publishingState
reservationState
}
}
Expand Down Expand Up @@ -11640,7 +11657,7 @@ export const SearchReservationUnitsDocument = gql`
* unit: // value for 'unit'
* reservationUnitType: // value for 'reservationUnitType'
* orderBy: // value for 'orderBy'
* state: // value for 'state'
* publishingState: // value for 'publishingState'
* },
* });
*/
Expand Down Expand Up @@ -13129,7 +13146,7 @@ export const ReservationUnitEditDocument = gql`
reservationUnit(id: $id) {
id
pk
state
publishingState
reservationState
images {
pk
Expand Down
8 changes: 5 additions & 3 deletions apps/admin-ui/src/component/reservation-units/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from "styled-components";
import ShowAllContainer from "common/src/components/ShowAllContainer";
import { AutoGrid } from "@/styles/layout";
import { useReservationUnitTypes, useUnitOptions } from "@/hooks";
import { ReservationUnitState } from "@gql/gql-types";
import { ReservationUnitPublishingState } from "@gql/gql-types";
import {
MultiSelectFilter,
SearchFilter,
Expand All @@ -30,8 +30,10 @@ const MoreWrapper = styled(ShowAllContainer)`
function Filters(): JSX.Element {
const { t } = useTranslation();

const reservationUnitStateOptions = Object.values(ReservationUnitState)
.filter((x) => x !== ReservationUnitState.Archived)
const reservationUnitStateOptions = Object.values(
ReservationUnitPublishingState
)
.filter((x) => x !== ReservationUnitPublishingState.Archived)
.map((s) => ({
value: s,
label: t(`ReservationUnits.state.${s}`),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from "react";
import { type ApolloError } from "@apollo/client";
import {
ReservationUnitOrderingChoices,
ReservationUnitState,
ReservationUnitPublishingState,
useSearchReservationUnitsQuery,
} from "@gql/gql-types";
import { filterNonNullable, toNumber } from "common/src/helpers";
Expand Down Expand Up @@ -95,22 +95,22 @@ export function ReservationUnitsDataReader(): JSX.Element {

function convertToReservationUnitState(
state: string
): ReservationUnitState | null {
): ReservationUnitPublishingState | null {
switch (state) {
case ReservationUnitState.Archived:
return ReservationUnitState.Archived;
case ReservationUnitState.Draft:
return ReservationUnitState.Draft;
case ReservationUnitState.Hidden:
return ReservationUnitState.Hidden;
case ReservationUnitState.Published:
return ReservationUnitState.Published;
case ReservationUnitState.ScheduledHiding:
return ReservationUnitState.ScheduledHiding;
case ReservationUnitState.ScheduledPeriod:
return ReservationUnitState.ScheduledPeriod;
case ReservationUnitState.ScheduledPublishing:
return ReservationUnitState.ScheduledPublishing;
case ReservationUnitPublishingState.Archived:
return ReservationUnitPublishingState.Archived;
case ReservationUnitPublishingState.Draft:
return ReservationUnitPublishingState.Draft;
case ReservationUnitPublishingState.Hidden:
return ReservationUnitPublishingState.Hidden;
case ReservationUnitPublishingState.Published:
return ReservationUnitPublishingState.Published;
case ReservationUnitPublishingState.ScheduledHiding:
return ReservationUnitPublishingState.ScheduledHiding;
case ReservationUnitPublishingState.ScheduledPeriod:
return ReservationUnitPublishingState.ScheduledPeriod;
case ReservationUnitPublishingState.ScheduledPublishing:
return ReservationUnitPublishingState.ScheduledPublishing;
default:
return null;
}
Expand All @@ -126,7 +126,7 @@ export function ReservationUnitsDataReader(): JSX.Element {
surfaceAreaGte,
nameFi: searchFilter,
unit,
state: reservationUnitStates.map((state) =>
publishingState: reservationUnitStates.map((state) =>
convertToReservationUnitState(state)
),
reservationUnitType: reservationUnitTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const getColConfig = (t: TFunction) => [
{
headerName: t("ReservationUnits.headings.state"),
key: "state",
transform: ({ state }: ReservationUnitNode) =>
t(`ReservationUnits.state.${state}`),
transform: ({ publishingState }: ReservationUnitNode) =>
t(`ReservationUnits.state.${publishingState}`),
},
{
headerName: t("ReservationUnits.headings.reservationState"),
Expand Down
10 changes: 5 additions & 5 deletions apps/admin-ui/src/spa/ReservationUnit/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { zodResolver } from "@hookform/resolvers/zod";
import {
ReservationStartInterval,
Authentication,
type ReservationState,
type ReservationUnitState,
type ReservationUnitPublishingState,
type ReservationUnitReservationState,
TermsType,
Status,
ImageType,
Expand Down Expand Up @@ -421,8 +421,8 @@ function DisplayUnit({
}: {
heading: string;
unit?: UnitWithSpacesAndResourcesQuery["unit"];
unitState?: ReservationUnitState;
reservationState?: ReservationState;
unitState?: ReservationUnitPublishingState;
reservationState?: ReservationUnitReservationState;
}): JSX.Element {
const location = unit?.location;
return (
Expand Down Expand Up @@ -2112,7 +2112,7 @@ function ReservationUnitEditor({
}
unit={unit ?? undefined}
reservationState={reservationUnit?.reservationState ?? undefined}
unitState={reservationUnit?.state ?? undefined}
unitState={reservationUnit?.publishingState ?? undefined}
/>
<ErrorInfo form={form} />
<BasicSection form={form} unit={unit} />
Expand Down
Loading

0 comments on commit 4c71d53

Please sign in to comment.