diff --git a/front/src/components/BoxReconciliationOverlay/BoxReconciliationOverlay.tsx b/front/src/components/BoxReconciliationOverlay/BoxReconciliationOverlay.tsx index 2b9c9d02f..237fb1f7f 100644 --- a/front/src/components/BoxReconciliationOverlay/BoxReconciliationOverlay.tsx +++ b/front/src/components/BoxReconciliationOverlay/BoxReconciliationOverlay.tsx @@ -14,10 +14,10 @@ import { IProductWithSizeRangeData, } from "./components/BoxReconciliationView"; import { useBaseIdParam } from "hooks/useBaseIdParam"; -import { introspection_types } from "../../../../generated/graphql-env"; +import { ShipmentDetail } from "types/query-types"; export interface IBoxReconciliationOverlayData { - shipmentDetail: introspection_types["ShipmentDetail"]; + shipmentDetail: ShipmentDetail; } export function BoxReconciliationOverlay({ @@ -209,7 +209,7 @@ export function BoxReconciliationOverlay({ onClose={onOverlayClose} onBoxUndelivered={setBoxUndeliveredAYSState} onBoxDelivered={onBoxDelivered} - shipmentDetail={shipmentDetail} + shipmentDetail={shipmentDetail as ShipmentDetail} allLocations={allLocations as ILocationData[]} productAndSizesData={productAndSizesData as IProductWithSizeRangeData[]} closeOnOverlayClick={closeOnOverlayClick} diff --git a/front/src/components/BoxReconciliationOverlay/components/BoxReconciliationAccordion.tsx b/front/src/components/BoxReconciliationOverlay/components/BoxReconciliationAccordion.tsx index 533aa26ac..26ccdbe59 100644 --- a/front/src/components/BoxReconciliationOverlay/components/BoxReconciliationAccordion.tsx +++ b/front/src/components/BoxReconciliationOverlay/components/BoxReconciliationAccordion.tsx @@ -5,10 +5,10 @@ import { RiQuestionFill } from "react-icons/ri"; import { ILocationData, IProductWithSizeRangeData } from "./BoxReconciliationView"; import { IMatchProductsFormData, MatchProductsForm } from "./MatchProductsForm"; import { IReceiveLocationFormData, ReceiveLocationForm } from "./ReceiveLocationForm"; -import { introspection_types } from "../../../../../generated/graphql-env"; +import { ShipmentDetail } from "types/query-types"; interface IBoxReconcilationAccordionProps { - shipmentDetail: introspection_types["ShipmentDetail"]["fields"]; + shipmentDetail: ShipmentDetail; productAndSizesData: IProductWithSizeRangeData[]; allLocations: ILocationData[]; loading: boolean; diff --git a/front/src/components/BoxReconciliationOverlay/components/BoxReconciliationView.tsx b/front/src/components/BoxReconciliationOverlay/components/BoxReconciliationView.tsx index 6aa42ff08..5c361cd5c 100644 --- a/front/src/components/BoxReconciliationOverlay/components/BoxReconciliationView.tsx +++ b/front/src/components/BoxReconciliationOverlay/components/BoxReconciliationView.tsx @@ -14,6 +14,7 @@ import { BiTrash } from "react-icons/bi"; import { BoxReconcilationAccordion } from "./BoxReconciliationAccordion"; import { introspection_types } from "../../../../../generated/graphql-env"; +import { ShipmentDetail } from "types/query-types"; export interface ICategoryData { name: string; @@ -44,7 +45,7 @@ export interface ILocationData { } interface IBoxReconciliationViewProps { - shipmentDetail: introspection_types["ShipmentDetail"]["fields"]; + shipmentDetail: ShipmentDetail; productAndSizesData: IProductWithSizeRangeData[]; allLocations: ILocationData[]; isOpen: boolean; diff --git a/front/src/components/BoxReconciliationOverlay/components/MatchProductsForm.tsx b/front/src/components/BoxReconciliationOverlay/components/MatchProductsForm.tsx index 376d94568..e825eaf80 100644 --- a/front/src/components/BoxReconciliationOverlay/components/MatchProductsForm.tsx +++ b/front/src/components/BoxReconciliationOverlay/components/MatchProductsForm.tsx @@ -9,7 +9,7 @@ import { BiSubdirectoryRight } from "react-icons/bi"; import { BsFillCheckCircleFill } from "react-icons/bs"; import { z } from "zod"; import { IProductWithSizeRangeData } from "./BoxReconciliationView"; -import { introspection_types } from "../../../../../generated/graphql-env"; +import { ShipmentDetail } from "types/query-types"; export interface ICategoryData { name: string; @@ -58,7 +58,7 @@ export const MatchProductsFormDataSchema = z.object({ export type IMatchProductsFormData = z.infer; interface IMatchProductsFormProps { - shipmentDetail: introspection_types["ShipmentDetail"]["fields"]; + shipmentDetail: ShipmentDetail; productAndSizesData: IProductWithSizeRangeData[]; loading: boolean; onSubmitMatchProductsForm: (matchedProductsFormData: IMatchProductsFormData) => void; diff --git a/front/src/components/QrReader/components/QrReaderMultiBoxContainer.tsx b/front/src/components/QrReader/components/QrReaderMultiBoxContainer.tsx index be8fe7369..26404a856 100644 --- a/front/src/components/QrReader/components/QrReaderMultiBoxContainer.tsx +++ b/front/src/components/QrReader/components/QrReaderMultiBoxContainer.tsx @@ -1,12 +1,6 @@ import { useCallback, useEffect, useMemo, useState } from "react"; import { useQuery } from "@apollo/client"; import { GET_SCANNED_BOXES } from "queries/local-only"; -import { - BoxState, - ShipmentState, - MultiBoxActionOptionsForLocationsTagsAndShipmentsQuery, - TagType, -} from "types/generated/graphql"; import { MULTI_BOX_ACTION_OPTIONS_FOR_LOCATIONS_TAGS_AND_SHIPMENTS_QUERY } from "queries/queries"; import { IDropdownOption } from "components/Form/SelectField"; import { AlertWithAction, AlertWithoutAction } from "components/Alerts"; @@ -46,7 +40,7 @@ function QrReaderMultiBoxContainer() { const scannedBoxesQueryResult = useQuery(GET_SCANNED_BOXES); // fetch location and shipments data - const optionsQueryResult = useQuery( + const optionsQueryResult = useQuery( MULTI_BOX_ACTION_OPTIONS_FOR_LOCATIONS_TAGS_AND_SHIPMENTS_QUERY, { variables: { baseId }, @@ -113,7 +107,7 @@ function QrReaderMultiBoxContainer() { const tagOptions: IDropdownOption[] = useMemo( () => optionsQueryResult.data?.base?.tags - ?.filter((tag) => tag?.type === TagType.All || tag?.type === TagType.Box) + ?.filter((tag) => tag?.type === "All" || tag?.type === "Box") ?.sort((a, b) => { const nameA = a.name.toLowerCase(); const nameB = b.name.toLowerCase(); @@ -133,10 +127,7 @@ function QrReaderMultiBoxContainer() { const shipmentOptions: IDropdownOption[] = useMemo( () => optionsQueryResult.data?.shipments - ?.filter( - (shipment) => - shipment.state === ShipmentState.Preparing && shipment.sourceBase.id === baseId, - ) + ?.filter((shipment) => shipment.state === "Preparing" && shipment.sourceBase.id === baseId) ?.map((shipment) => ({ label: `${shipment.targetBase.name} - ${shipment.targetBase.organisation.name}`, value: shipment.id, @@ -153,9 +144,7 @@ function QrReaderMultiBoxContainer() { }, [shipmentOptions]); const notInStockBoxes = useMemo( - () => - scannedBoxesQueryResult.data?.scannedBoxes.filter((box) => box.state !== BoxState.InStock) ?? - [], + () => scannedBoxesQueryResult.data?.scannedBoxes.filter((box) => box.state !== "InStock") ?? [], [scannedBoxesQueryResult.data?.scannedBoxes], ); diff --git a/front/src/components/Timeline/Timeline.tsx b/front/src/components/Timeline/Timeline.tsx index 7b82437c0..a34d52d78 100644 --- a/front/src/components/Timeline/Timeline.tsx +++ b/front/src/components/Timeline/Timeline.tsx @@ -1,6 +1,6 @@ import { Box, Flex, Text } from "@chakra-ui/react"; -import { User } from "types/generated/graphql"; import TimelineEntry from "./components/TimelineEntry"; +import { User } from "types/query-types"; export interface ITimelineEntry { action: string; diff --git a/front/src/hooks/useDeleteBoxes.ts b/front/src/hooks/useDeleteBoxes.ts index 07d520f8c..ca868402e 100644 --- a/front/src/hooks/useDeleteBoxes.ts +++ b/front/src/hooks/useDeleteBoxes.ts @@ -115,7 +115,7 @@ export const useDeleteBoxes = () => { requestedBoxes: boxes, deletedBoxes, invalidIdentifiers, - } as IDeleteBoxResult; + } /* TODO: should we fix this type cast? as IDeleteBoxResult */; } return { diff --git a/front/src/hooks/useLabelIdentifierResolver.ts b/front/src/hooks/useLabelIdentifierResolver.ts index 07a5add3a..f3e776f60 100644 --- a/front/src/hooks/useLabelIdentifierResolver.ts +++ b/front/src/hooks/useLabelIdentifierResolver.ts @@ -1,6 +1,5 @@ import { useCallback, useState } from "react"; import { useApolloClient } from "@apollo/client"; -import { BoxDetailsQuery, BoxDetailsQueryVariables } from "types/generated/graphql"; import { BOX_DETAILS_BY_LABEL_IDENTIFIER_QUERY } from "queries/queries"; export enum ILabelIdentifierResolverResultKind { @@ -28,7 +27,7 @@ export const useLabelIdentifierResolver = () => { async (labelIdentifier: string): Promise => { setLoading(true); const labelIdentifierResolvedValue: ILabelIdentifierResolvedValue = await apolloClient - .query({ + .query({ query: BOX_DETAILS_BY_LABEL_IDENTIFIER_QUERY, variables: { labelIdentifier }, fetchPolicy: "network-only", diff --git a/front/src/hooks/useLoadAndSetGlobalPreferences.ts b/front/src/hooks/useLoadAndSetGlobalPreferences.ts index c0e7a05cf..2adc35989 100644 --- a/front/src/hooks/useLoadAndSetGlobalPreferences.ts +++ b/front/src/hooks/useLoadAndSetGlobalPreferences.ts @@ -3,7 +3,6 @@ import { useAuth0 } from "@auth0/auth0-react"; import { useLazyQuery } from "@apollo/client"; import { useLocation, useNavigate } from "react-router-dom"; import { GlobalPreferencesContext } from "providers/GlobalPreferencesProvider"; -import { OrganisationAndBasesQuery } from "types/generated/graphql"; import { ORGANISATION_AND_BASES_QUERY } from "queries/queries"; import { useBaseIdParam } from "./useBaseIdParam"; @@ -17,7 +16,7 @@ export const useLoadAndSetGlobalPreferences = () => { const { baseId } = useBaseIdParam(); const [runOrganisationAndBasesQuery, { loading: isOrganisationAndBasesQueryLoading, data: organisationAndBaseData }] = - useLazyQuery(ORGANISATION_AND_BASES_QUERY); + useLazyQuery(ORGANISATION_AND_BASES_QUERY); useEffect(() => { // run query only if the access token is in the request header from the apollo client and the base is not set diff --git a/front/src/hooks/useQrResolver.ts b/front/src/hooks/useQrResolver.ts index 6ec98093d..fdf46a428 100644 --- a/front/src/hooks/useQrResolver.ts +++ b/front/src/hooks/useQrResolver.ts @@ -2,10 +2,6 @@ import { useCallback, useState } from "react"; import { FetchPolicy, useApolloClient } from "@apollo/client"; import { GET_BOX_LABEL_IDENTIFIER_BY_QR_CODE } from "queries/queries"; import { BOX_SCANNED_ON_FRAGMENT } from "queries/local-only"; -import { - GetBoxLabelIdentifierForQrCodeQuery, - GetBoxLabelIdentifierForQrCodeQueryVariables, -} from "types/generated/graphql"; import { useErrorHandling } from "./useErrorHandling"; export enum IQrResolverResultKind { @@ -49,7 +45,7 @@ export const useQrResolver = () => { async (hash: string, fetchPolicy: FetchPolicy): Promise => { setLoading(true); const qrResolvedValue: IQrResolvedValue = await apolloClient - .query({ + .query({ query: GET_BOX_LABEL_IDENTIFIER_BY_QR_CODE, variables: { qrCode: hash }, fetchPolicy, diff --git a/front/src/hooks/useScannedBoxesActions.ts b/front/src/hooks/useScannedBoxesActions.ts index 9effce4f5..4f049a260 100644 --- a/front/src/hooks/useScannedBoxesActions.ts +++ b/front/src/hooks/useScannedBoxesActions.ts @@ -1,16 +1,16 @@ import { useCallback } from "react"; import { useApolloClient } from "@apollo/client"; import { GET_SCANNED_BOXES } from "queries/local-only"; -import { BoxFieldsFragment, BoxState } from "types/generated/graphql"; -import { IBoxBasicFields, IScannedBoxesData } from "types/graphql-local-only"; +import { IScannedBoxesData } from "types/graphql-local-only"; import { useNotification } from "./useNotification"; +import { Box } from "types/query-types"; export const useScannedBoxesActions = () => { const apolloClient = useApolloClient(); const { createToast } = useNotification(); const addBox = useCallback( - (box: BoxFieldsFragment) => + (box: Box) => apolloClient.cache.updateQuery( { query: GET_SCANNED_BOXES, @@ -19,12 +19,12 @@ export const useScannedBoxesActions = () => { const existingBoxRefs = data.scannedBoxes; const alreadyExists = existingBoxRefs.some( - (ref) => ref.labelIdentifier === box.labelIdentifier, + (ref) => ref.labelIdentifier === box?.labelIdentifier, ); if (alreadyExists) { createToast({ - message: `Box ${box.labelIdentifier} is already on the list.`, + message: `Box ${box?.labelIdentifier} is already on the list.`, type: "info", }); @@ -32,12 +32,12 @@ export const useScannedBoxesActions = () => { } // execute rest only if Box is not in the scannedBoxes already createToast({ - message: `Box ${box.labelIdentifier} was added to the list.`, + message: `Box ${box?.labelIdentifier} was added to the list.`, type: "success", }); return { - scannedBoxes: [...existingBoxRefs, box as IBoxBasicFields], + scannedBoxes: [...existingBoxRefs, box], } as IScannedBoxesData; }, ), @@ -75,7 +75,7 @@ export const useScannedBoxesActions = () => { }, (data: IScannedBoxesData) => ({ - scannedBoxes: data.scannedBoxes.filter((box) => box.state === BoxState.InStock), + scannedBoxes: data.scannedBoxes.filter((box) => box.state === "InStock"), }) as IScannedBoxesData, ); }, [apolloClient]); diff --git a/front/src/hooks/useUnassignBoxesFromShipments.ts b/front/src/hooks/useUnassignBoxesFromShipments.ts index 72cbabb16..7df48ab8a 100644 --- a/front/src/hooks/useUnassignBoxesFromShipments.ts +++ b/front/src/hooks/useUnassignBoxesFromShipments.ts @@ -1,6 +1,5 @@ import { useApolloClient } from "@apollo/client"; import { useState, useCallback } from "react"; -import { BoxState } from "types/generated/graphql"; import { IBoxBasicFields } from "types/graphql-local-only"; import { IUnassignmentFromShipment, @@ -37,11 +36,11 @@ export const useUnassignBoxesFromShipments = () => { (boxes: IBoxBasicFields[]) => { setIsLoading(true); const markedForShipmentBoxes = boxes.filter( - (box) => box.state === BoxState.MarkedForShipment, + (box) => box.state === "MarkedForShipment", ); const notMarkedForShipmentBoxes = boxes.filter( - (box) => box.state !== BoxState.MarkedForShipment, + (box) => box.state !== "MarkedForShipment", ); const shipmentBoxDictionary = markedForShipmentBoxes.reduce( @@ -122,9 +121,8 @@ export const useUnassignBoxesFromShipments = () => { // some boxes were unassigned if (unassignedBoxes.length > 0) { createToast({ - message: `${ - unassignedBoxes.length === 1 ? "A Box was" : `${unassignedBoxes.length} Boxes were` - } successfully unassigned from their corresponding shipment.`, + message: `${unassignedBoxes.length === 1 ? "A Box was" : `${unassignedBoxes.length} Boxes were` + } successfully unassigned from their corresponding shipment.`, }); } if (failedBoxes.length > 0) { diff --git a/front/src/mocks/locations.ts b/front/src/mocks/locations.ts index a93ec2db6..33ebaa8ba 100644 --- a/front/src/mocks/locations.ts +++ b/front/src/mocks/locations.ts @@ -1,4 +1,3 @@ -import { BoxState } from "types/generated/graphql"; import { organisation1 } from "./organisations"; export const location1 = { @@ -23,7 +22,7 @@ const location2 = { }; export const generateMockLocationWithBase = ({ - defaultBoxState = BoxState.InStock, + defaultBoxState = "InStock", defaultLocationName = "WH Men", defaultLocationId = 7, }) => ({ diff --git a/front/src/mocks/products.ts b/front/src/mocks/products.ts index ce40a2410..699ddabcc 100644 --- a/front/src/mocks/products.ts +++ b/front/src/mocks/products.ts @@ -1,10 +1,9 @@ -import { ProductGender } from "types/generated/graphql"; import { sizeRange1, sizeRange2 } from "./sizeRanges"; export const product1 = { id: "1", name: "Long Sleeves", - gender: ProductGender.Women, + gender: "Women", category: { name: "Tops", __typename: "ProductCategory", @@ -17,7 +16,7 @@ export const product1 = { export const productBasic1 = { id: "1", name: "Snow trousers", - gender: ProductGender.Boy, + gender: "Boy", deletedOn: null, __typename: "Product", }; @@ -25,7 +24,7 @@ export const productBasic1 = { export const product3 = { id: "3", name: "Long Sleeves", - gender: ProductGender.None, + gender: "None", category: { name: "Tops", __typename: "ProductCategory", @@ -40,7 +39,7 @@ export const products = [ { id: "2", name: "Winter Jackets", - gender: ProductGender.Men, + gender: "Men", category: { name: "Jackets / Outerwear", __typename: "ProductCategory", diff --git a/front/src/mocks/tags.ts b/front/src/mocks/tags.ts index b2509b9f7..a6df0cb91 100644 --- a/front/src/mocks/tags.ts +++ b/front/src/mocks/tags.ts @@ -1,12 +1,10 @@ -import { TagType } from "types/generated/graphql"; - export const tag1 = { color: "#20963f", label: "tag1", value: "1", id: "1", name: "tag1", - type: TagType.All, + type: "All", description: "tag1", __typename: "Tag", }; @@ -17,7 +15,7 @@ export const tag2 = { name: "test tag", label: "tag1", value: "1", - type: TagType.All, + type: "All", description: "tag17", __typename: "Tag", }; @@ -37,7 +35,7 @@ export const tagsArray = [ color: "#20963f", name: "tag1", id: "1", - type: TagType.All, + type: "All", description: "tag1", __typename: "Tag", }, @@ -45,7 +43,7 @@ export const tagsArray = [ color: "#20969f", name: "tag2", id: "2", - type: TagType.Box, + type: "Box", description: "tag2", __typename: "Tag", }, diff --git a/front/src/mocks/transferAgreements.ts b/front/src/mocks/transferAgreements.ts index 70fb28b06..4cfb3bd6e 100644 --- a/front/src/mocks/transferAgreements.ts +++ b/front/src/mocks/transferAgreements.ts @@ -1,20 +1,15 @@ -import { - ShipmentState, - TransferAgreementState, - TransferAgreementType, -} from "types/generated/graphql"; import { base1, base2 } from "./bases"; import { organisation1, organisation2 } from "./organisations"; export const generateMockTransferAgreement = ({ - type = TransferAgreementType.Bidirectional, - state = TransferAgreementState.UnderReview, + type = "Bidirectional", + state = "UnderReview", comment = "Good Comment", isInitiator = true, }) => { const iAmSource = - (isInitiator && type !== TransferAgreementType.ReceivingFrom) || - (!isInitiator && type === TransferAgreementType.ReceivingFrom); + (isInitiator && type !== "ReceivingFrom") || + (!isInitiator && type === "ReceivingFrom"); return { id: "1", @@ -30,7 +25,7 @@ export const generateMockTransferAgreement = ({ shipments: [ { id: "1", - state: ShipmentState.Preparing, + state: "Preparing", sourceBase: iAmSource ? base1 : base2, targetBase: iAmSource ? base2 : base1, __typename: "Shipment", diff --git a/front/src/queries/fragments.ts b/front/src/queries/fragments.ts index a357db7e7..472d7f06e 100644 --- a/front/src/queries/fragments.ts +++ b/front/src/queries/fragments.ts @@ -395,4 +395,4 @@ export const SHIPMENT_FIELDS_FRAGMENT = graphql(` ...UserBasicFields } } -`, [BASE_ORG_FIELDS_FRAGMENT, SHIPMENT_DETAIL_FIELDS_FRAGMENT]); +`, [BASE_ORG_FIELDS_FRAGMENT, SHIPMENT_DETAIL_FIELDS_FRAGMENT, USER_BASIC_FIELDS_FRAGMENT]); diff --git a/front/src/queries/queries.ts b/front/src/queries/queries.ts index a0d8dc115..de1a5d54b 100644 --- a/front/src/queries/queries.ts +++ b/front/src/queries/queries.ts @@ -181,3 +181,106 @@ export const MULTI_BOX_ACTION_OPTIONS_FOR_LOCATIONS_TAGS_AND_SHIPMENTS_QUERY = g } } `, [LOCATION_BASIC_FIELDS_FRAGMENT, TAG_BASIC_FIELDS_FRAGMENT, BASE_ORG_FIELDS_FRAGMENT]); + +export const LOCATIONS_QUERY = graphql(` + query Locations { + locations { + id + name + defaultBoxState + seq + } + } + `) + +export const BOX_QUERY = graphql(` + query Box($labelIdentifier: String!) { + box(labelIdentifier: $labelIdentifier) { + id + labelIdentifier + state + comment + numberOfItems + product { + id + } + history { + id + changes + changeDate + } + size { + id + label + } + tags { + id + name + color + } + shipmentDetail { + id + createdBy { + id + } + createdOn + removedBy { + id + } + removedOn + lostBy { + id + } + shipment { + id + details { + id + box { + id + labelIdentifier + } + } + } + } + location { + id + name + ... on ClassicLocation { + defaultBoxState + } + base { + locations { + id + name + seq + defaultBoxState + } + } + } + } + } + `) + +export const USER_QUERY = graphql(` + query User { + users { + id + name + email + lastLogin + lastAction + validFirstDay + validLastDay + organisation { + id + name + bases { + id + } + } + bases { + id + } + } + } + `) diff --git a/front/src/types/base-types.ts b/front/src/types/base-types.ts index 47b3d3b56..070f97988 100644 --- a/front/src/types/base-types.ts +++ b/front/src/types/base-types.ts @@ -1,4 +1,4 @@ -import { ProductGender } from "types/generated/graphql"; +import { ProductGender } from "./query-types"; export interface IBoxDetailsData { labelIdentifier: string; diff --git a/front/src/types/graphql-local-only.ts b/front/src/types/graphql-local-only.ts index ac265fcb7..c8a3ebcc3 100644 --- a/front/src/types/graphql-local-only.ts +++ b/front/src/types/graphql-local-only.ts @@ -1,7 +1,9 @@ +import { introspection_types } from "../../../generated/graphql-env"; + export interface IBoxBasicFields { __typename?: "Box"; labelIdentifier: string; - state: BoxState; + state: introspection_types["BoxState"]["enumValues"]; shipmentDetail: { id: string; shipment: { id: string } } | null; } diff --git a/front/src/types/query-types.ts b/front/src/types/query-types.ts new file mode 100644 index 000000000..24dbaa39f --- /dev/null +++ b/front/src/types/query-types.ts @@ -0,0 +1,29 @@ +import { ResultOf } from "gql.tada" + +import { ALL_SHIPMENTS_QUERY, BOX_QUERY, LOCATIONS_QUERY, USER_QUERY } from "queries/queries"; +import { ALL_TRANSFER_AGREEMENTS_QUERY } from "views/Transfers/TransferAgreementOverview/TransferAgreementOverviewView"; +import { introspection_types } from "../../../generated/graphql-env"; + +export type Box = ResultOf["box"]; + +export type User = ResultOf["users"][0]; + +export type Users = ResultOf["users"]; + +export type Shipment = ResultOf["shipments"][0]; + +export type Shipments = ResultOf["shipments"]; + +export type ShipmentDetail = Shipments[0]["details"][0] + +export type TransferAgreements = ResultOf["transferAgreements"] + +export type Locations = ResultOf["locations"]; + +export type BoxState = introspection_types["BoxState"]["enumValues"]; + +export type ShipmentState = introspection_types["ShipmentState"]["enumValues"]; + +export type ProductGender = introspection_types["ProductGender"]["enumValues"]; + +export type DistributionEventState = introspection_types["DistributionEventState"]["enumValues"]; diff --git a/front/src/utils/transformers.ts b/front/src/utils/transformers.ts index d6e8807fc..c075471c4 100644 --- a/front/src/utils/transformers.ts +++ b/front/src/utils/transformers.ts @@ -1,14 +1,8 @@ import { IDropdownOption } from "components/Form/SelectField"; -import { ActionOptionsForBoxesViewQuery, BoxState, ShipmentState } from "types/generated/graphql"; +import { Locations } from "types/query-types"; export function locationToDropdownOptionTransformer( - locations: { - __typename?: "ClassicLocation" | undefined; - defaultBoxState?: BoxState | null | undefined; - id: string; - seq?: number | null | undefined; - name?: string | null | undefined; - }[], + locations: Locations, ): IDropdownOption[] { return ( locations @@ -19,11 +13,10 @@ export function locationToDropdownOptionTransformer( ) ?.sort((a, b) => Number(a?.seq) - Number(b?.seq)) ?.map((location) => ({ - label: `${location.name}${ - location.defaultBoxState !== BoxState.InStock - ? ` - Boxes are ${location.defaultBoxState}` - : "" - }`, + label: `${location.name}${location.defaultBoxState !== BoxState.InStock + ? ` - Boxes are ${location.defaultBoxState}` + : "" + }`, value: location.id, })) ?? [] ); diff --git a/front/src/views/BaseDashboard/BaseDashboardView.tsx b/front/src/views/BaseDashboard/BaseDashboardView.tsx index 43d3c0ab1..eed1c691e 100644 --- a/front/src/views/BaseDashboard/BaseDashboardView.tsx +++ b/front/src/views/BaseDashboard/BaseDashboardView.tsx @@ -2,7 +2,6 @@ import { useQuery } from "@apollo/client"; import { graphql } from "../../../../graphql"; import { Center, Heading, Text } from "@chakra-ui/react"; import { useBaseIdParam } from "hooks/useBaseIdParam"; -import { BaseDataQuery, BaseDataQueryVariables } from "types/generated/graphql"; export const BASE_DATA = graphql(` query BaseData($baseId: ID!) { diff --git a/front/src/views/Box/BoxView.test.tsx b/front/src/views/Box/BoxView.test.tsx index aa6f823ec..305eaa82c 100644 --- a/front/src/views/Box/BoxView.test.tsx +++ b/front/src/views/Box/BoxView.test.tsx @@ -3,7 +3,6 @@ import { screen, render, waitFor } from "tests/test-utils"; import { userEvent } from "@testing-library/user-event"; import { cache } from "queries/cache"; import { generateMockBox } from "mocks/boxes"; -import { BoxState } from "types/generated/graphql"; import { generateMockLocationWithBase, locations } from "mocks/locations"; import { product1, product3, products } from "mocks/products"; import { BOX_BY_LABEL_IDENTIFIER_AND_ALL_PRODUCTS_WITH_BASEID_QUERY } from "views/BoxEdit/BoxEditView"; @@ -62,11 +61,11 @@ const initialQueryForBoxInLegacyLostLocation = { box: generateMockBox({ labelIdentifier: "1234", location: generateMockLocationWithBase({ - defaultBoxState: BoxState.Lost, + defaultBoxState: "Lost", defaultLocationName: "LOST", defaultLocationId: 1, }), - state: BoxState.Lost, + state: "Lost", }), shipments: null, }, @@ -84,7 +83,7 @@ const initialQueryForBoxLostState = { data: { box: generateMockBox({ labelIdentifier: "1234", - state: BoxState.Lost, + state: "Lost", }), shipments: null, }, @@ -102,7 +101,7 @@ const initialQueryForBoxScrapState = { data: { box: generateMockBox({ labelIdentifier: "1234", - state: BoxState.Scrap, + state: "Scrap", }), shipments: null, }, @@ -120,7 +119,7 @@ const initialQueryForBoxMarkedForShipmentState = { data: { box: generateMockBox({ labelIdentifier: "1234", - state: BoxState.MarkedForShipment, + state: "MarkedForShipment", }), shipments: null, }, @@ -206,7 +205,7 @@ const initialQueryMoveLocationOfBox = { data: { box: generateMockBox({ labelIdentifier: "125", - state: BoxState.InStock, + state: "InStock", }), shipments: null, }, @@ -226,7 +225,7 @@ const moveLocationOfBoxMutation = { updateBox: generateMockBox({ product: product1, labelIdentifier: "125", - state: BoxState.InStock, + state: "InStock", location: generateMockLocationWithBase({ defaultLocationId: 6, defaultLocationName: "WH Women", @@ -242,14 +241,14 @@ const updateBoxStateToScrapMutation = { query: UPDATE_STATE_IN_BOX_MUTATION, variables: { boxLabelIdentifier: "123", - newState: BoxState.Scrap, + newState: "Scrap", }, }, result: { data: { updateBox: generateMockBox({ labelIdentifier: "123", - state: BoxState.Scrap, + state: "Scrap", }), }, }, @@ -265,7 +264,7 @@ const updateBoxStateToLostMutation = { }, result: { data: { - updateBox: generateMockBox({ state: BoxState.Lost }), + updateBox: generateMockBox({ state: "Lost" }), shipments: null, }, }, diff --git a/front/src/views/Box/BoxView.tsx b/front/src/views/Box/BoxView.tsx index 78616e126..d76a74a02 100644 --- a/front/src/views/Box/BoxView.tsx +++ b/front/src/views/Box/BoxView.tsx @@ -12,25 +12,6 @@ import { } from "@chakra-ui/react"; import { GlobalPreferencesContext } from "providers/GlobalPreferencesProvider"; import { useNavigate, useParams } from "react-router-dom"; -import { - AssignBoxToDistributionEventMutation, - AssignBoxToDistributionEventMutationVariables, - BoxByLabelIdentifierQuery, - BoxByLabelIdentifierQueryVariables, - BoxState, - UnassignBoxFromDistributionEventMutation, - UnassignBoxFromDistributionEventMutationVariables, - UpdateLocationOfBoxMutation, - UpdateLocationOfBoxMutationVariables, - UpdateNumberOfItemsMutation, - UpdateNumberOfItemsMutationVariables, - UpdateStateMutationVariables, - UpdateStateMutation, - ClassicLocation, - ShipmentState, - User, - HistoryEntry, -} from "types/generated/graphql"; import { ASSIGN_BOX_TO_DISTRIBUTION_MUTATION, PACKING_LIST_ENTRIES_FOR_DISTRIBUTION_EVENT_QUERY, @@ -64,6 +45,7 @@ import BoxDetails from "./components/BoxDetails"; import TakeItemsFromBoxOverlay from "./components/TakeItemsFromBoxOverlay"; import AddItemsToBoxOverlay from "./components/AddItemsToBoxOverlay"; import { useBaseIdParam } from "hooks/useBaseIdParam"; +import { BoxState } from "types/query-types"; // Queries and Mutations const refetchBoxByLabelIdentifierQueryConfig = (labelIdentifier: string) => ({ @@ -169,32 +151,28 @@ function BTBox() { isLoading: isAssignBoxesToShipmentLoading, } = useAssignBoxesToShipment(); - const allData = useQuery( - BOX_BY_LABEL_IDENTIFIER_AND_ALL_SHIPMENTS_QUERY, - { - variables: { - labelIdentifier, - }, - notifyOnNetworkStatusChange: true, + const allData = useQuery(BOX_BY_LABEL_IDENTIFIER_AND_ALL_SHIPMENTS_QUERY, { + variables: { + labelIdentifier, }, - ); + notifyOnNetworkStatusChange: true, + }); const shipmentsQueryResult = allData.data?.shipments; const boxInTransit = currentBoxState - ? [BoxState.Receiving, BoxState.MarkedForShipment, BoxState.InTransit].includes(currentBoxState) + ? ["Receiving", "MarkedForShipment", "InTransit"].includes(currentBoxState) : false; // map over each box HistoryEntry to compile its timeline records - const boxLogs: ITimelineEntry[] = (allData.data?.box?.history as HistoryEntry[])?.flatMap( - (histories) => - _.compact([ - histories?.user && { - action: prepareBoxHistoryEntryText(`${histories.user.name} ${histories.changes}`), - createdBy: histories.user as User, - createdOn: new Date(histories.changeDate), - }, - ]), + const boxLogs: ITimelineEntry[] = allData.data?.box?.history?.flatMap((histories) => + _.compact([ + histories?.user && { + action: prepareBoxHistoryEntryText(`${histories.user.name} ${histories.changes}`), + createdBy: histories.user, + createdOn: new Date(histories.changeDate || ""), + }, + ]), ) as ITimelineEntry[]; const allLogs = _.orderBy( @@ -217,32 +195,21 @@ function BTBox() { .orderBy((entry) => new Date(entry.date), "desc") .value(); - const [updateNumberOfItemsMutation, updateNumberOfItemsMutationStatus] = useMutation< - UpdateNumberOfItemsMutation, - UpdateNumberOfItemsMutationVariables - >(UPDATE_NUMBER_OF_ITEMS_IN_BOX_MUTATION); + const [updateNumberOfItemsMutation, updateNumberOfItemsMutationStatus] = useMutation( + UPDATE_NUMBER_OF_ITEMS_IN_BOX_MUTATION, + ); const [assignBoxToDistributionEventMutation, assignBoxToDistributionEventMutationStatus] = - useMutation< - AssignBoxToDistributionEventMutation, - AssignBoxToDistributionEventMutationVariables - >(ASSIGN_BOX_TO_DISTRIBUTION_MUTATION); + useMutation(ASSIGN_BOX_TO_DISTRIBUTION_MUTATION); const [unassignBoxFromDistributionEventMutation, unassignBoxFromDistributionEventMutationStatus] = - useMutation< - UnassignBoxFromDistributionEventMutation, - UnassignBoxFromDistributionEventMutationVariables - >(UNASSIGN_BOX_FROM_DISTRIBUTION_MUTATION); + useMutation(UNASSIGN_BOX_FROM_DISTRIBUTION_MUTATION); - const [updateStateMutation, updateStateMutationStatus] = useMutation< - UpdateStateMutation, - UpdateStateMutationVariables - >(UPDATE_STATE_IN_BOX_MUTATION); + const [updateStateMutation, updateStateMutationStatus] = useMutation( + UPDATE_STATE_IN_BOX_MUTATION, + ); - const [updateBoxLocation, updateBoxLocationMutationStatus] = useMutation< - UpdateLocationOfBoxMutation, - UpdateLocationOfBoxMutationVariables - >(UPDATE_BOX_MUTATION); + const [updateBoxLocation, updateBoxLocationMutationStatus] = useMutation(UPDATE_BOX_MUTATION); const { isOpen: isPlusOpen, onOpen: onPlusOpen, onClose: onPlusClose } = useDisclosure(); const { isOpen: isMinusOpen, onOpen: onMinusOpen, onClose: onMinusClose } = useDisclosure(); @@ -253,13 +220,13 @@ function BTBox() { setCurrentState(boxData?.state); const shipmentId = boxData?.shipmentDetail?.shipment.id; // open reconciliation overlay if the box state is receiving - if (shipmentId && boxData?.state === BoxState.Receiving) { + if (shipmentId && boxData?.state === "Receiving") { boxReconciliationOverlayVar({ labelIdentifier: boxData.labelIdentifier, isOpen: true, shipmentId, }); - } else if (shipmentId && boxData?.state === BoxState.InTransit) { + } else if (shipmentId && boxData?.state === "InTransit") { navigate(`/bases/${currentBaseId}/transfers/shipments/${shipmentId}`); } }, [boxData, globalPreferences, navigate, currentBaseId]); @@ -589,8 +556,7 @@ function BTBox() { () => shipmentsQueryResult ?.filter( - (shipment) => - shipment.state === ShipmentState.Preparing && shipment.sourceBase.id === currentBaseId, + (shipment) => shipment.state === "Preparing" && shipment.sourceBase.id === currentBaseId, ) ?.map((shipment) => ({ label: `${shipment.targetBase.name} - ${shipment.targetBase.organisation.name}`, @@ -615,25 +581,22 @@ function BTBox() { warehouse location. Boxtribute no longer supports LOST and SCRAP locations.`; const alertMessageForBoxWithLostScrapState = `To edit or move this box, remove the ${ - boxData?.state === BoxState.Lost ? "Lost" : "Scrap" + boxData?.state === "Lost" ? "Lost" : "Scrap" } status.`; const location = - boxData?.state === BoxState.Receiving + boxData?.state === "Receiving" ? boxData?.shipmentDetail?.shipment.details.filter( (b) => b.box.labelIdentifier === boxData.labelIdentifier, )[0]?.sourceLocation : boxData?.location; const boxInLegacyLocation = - (location as ClassicLocation)?.defaultBoxState === BoxState.Lost || - (location as ClassicLocation)?.defaultBoxState === BoxState.Scrap; + location?.defaultBoxState === "Lost" || location?.defaultBoxState === "Scrap"; return ( - {(boxInLegacyLocation || - boxData?.state === BoxState.Lost || - boxData?.state === BoxState.Scrap) && ( + {(boxInLegacyLocation || boxData?.state === "Lost" || boxData?.state === "Scrap") && ( void; onPlusOpen: () => void; onMinusOpen: () => void; - onStateChange: (boxState: BoxState) => void; + onStateChange: (boxState: string) => void; isLoading: boolean; } @@ -68,21 +63,21 @@ function BoxCard({ const hasTag = !!boxData?.tags?.length; const product = - boxData?.state === BoxState.Receiving + boxData?.state === "Receiving" ? boxData?.shipmentDetail?.shipment.details.filter( (b) => b.box.labelIdentifier === boxData.labelIdentifier, )[0].sourceProduct : boxData?.product; const numberOfItems = - boxData?.state === BoxState.Receiving + boxData?.state === "Receiving" ? boxData?.shipmentDetail?.shipment.details.filter( (b) => b.box.labelIdentifier === boxData.labelIdentifier, )[0].sourceQuantity : boxData?.numberOfItems; const size = - boxData?.state === BoxState.Receiving + boxData?.state === "Receiving" ? boxData?.shipmentDetail?.shipment.details.filter( (b) => b.box.labelIdentifier === boxData.labelIdentifier, )[0]?.sourceSize @@ -106,9 +101,9 @@ function BoxCard({ border="2px" isDisabled={ isLoading || - BoxState.Lost === boxData?.state || - BoxState.Scrap === boxData?.state || - BoxState.NotDelivered === boxData?.state || + "Lost" === boxData?.state || + "Scrap" === boxData?.state || + "NotDelivered" === boxData?.state || boxInTransit } /> @@ -152,9 +147,9 @@ function BoxCard({ onStateChange( // If the current box state 'Scrap' is toggled, set the defaultBoxState of the box location - boxData?.state === BoxState.Scrap + boxData?.state === "Scrap" ? (boxData?.location as any)?.defaultBoxState - : BoxState.Scrap, + : "Scrap", ) } mr={2} @@ -276,19 +272,20 @@ function BoxCard({ data-testid="box-lost-btn" isDisabled={ boxInTransit || - boxData?.state === BoxState.NotDelivered || - (boxData?.location as ClassicLocation)?.defaultBoxState === BoxState.Lost + boxData?.state === "NotDelivered" || + (boxData?.location?.__typename === "ClassicLocation" && + boxData?.location?.defaultBoxState === "Lost") } onChange={() => onStateChange( // If the current box state 'Lost' is toggled, set the defaultBoxState of the box location - boxData?.state === BoxState.Lost + boxData?.state === "Lost" ? (boxData?.location as any)?.defaultBoxState - : BoxState.Lost, + : "Lost", ) } mr={2} - isChecked={boxData?.state === BoxState.Lost} + isChecked={boxData?.state === "Lost"} /> )} @@ -305,9 +302,7 @@ function BoxCard({ - {!isLoading && ( - - )} + {!isLoading && } {isLoading && ( )} diff --git a/front/src/views/Box/components/BoxDetails.tsx b/front/src/views/Box/components/BoxDetails.tsx index fd93be671..48f61f2be 100644 --- a/front/src/views/Box/components/BoxDetails.tsx +++ b/front/src/views/Box/components/BoxDetails.tsx @@ -1,10 +1,5 @@ import { Box, Stack } from "@chakra-ui/react"; import { IDropdownOption } from "components/Form/SelectField"; -import { - BoxByLabelIdentifierQuery, - BoxState, - UpdateLocationOfBoxMutation, -} from "types/generated/graphql"; import BoxCard from "./BoxCard"; import BoxDistributionEvent from "./BoxDistributionEvent"; import BoxTabs from "./BoxTabs"; diff --git a/front/src/views/Box/components/BoxMoveLocation.tsx b/front/src/views/Box/components/BoxMoveLocation.tsx index ff6630c73..f9f27e061 100644 --- a/front/src/views/Box/components/BoxMoveLocation.tsx +++ b/front/src/views/Box/components/BoxMoveLocation.tsx @@ -1,8 +1,8 @@ import { List, Text, Flex, WrapItem, Button, SkeletonText } from "@chakra-ui/react"; -import { BoxState, ClassicLocation } from "types/generated/graphql"; +import { Box } from "types/query-types"; export interface IBoxMoveLocationProps { - boxData: any; + boxData: Box; boxInTransit: boolean; isLoading: boolean; onMoveToLocationClick: (locationId: string) => void; @@ -26,19 +26,18 @@ function BoxMoveLocation({ noOfLines={1} /> )} - {!isLoading && boxData.state !== BoxState.MarkedForShipment && ( + {!isLoading && boxData?.state !== "MarkedForShipment" && ( - Move this box from {boxData.location?.name} to: + Move this box from {boxData?.location?.name} to: )} - {boxData.location?.base?.locations - ?.filter((location) => location.id !== boxData.location?.id) + {boxData?.location?.base?.locations + ?.filter((location) => location.id !== boxData?.location?.id) .filter( (location) => - location?.defaultBoxState !== BoxState.Lost && - location?.defaultBoxState !== BoxState.Scrap, + location?.defaultBoxState !== "Lost" && location?.defaultBoxState !== "Scrap", ) .sort((a, b) => Number(a?.seq) - Number(b?.seq)) .map((location) => ( @@ -49,18 +48,20 @@ function BoxMoveLocation({ isLoading={isLoading} onClick={() => onMoveToLocationClick(location.id)} isDisabled={ - (boxData.location as ClassicLocation).defaultBoxState !== BoxState.Lost && - (boxData.location as ClassicLocation).defaultBoxState !== BoxState.Scrap - ? BoxState.Lost === boxData.state || - BoxState.Scrap === boxData.state || - BoxState.NotDelivered === boxData.state || + boxData.location?.__typename === "ClassicLocation" && + boxData.location?.defaultBoxState !== "Lost" && + boxData.location?.__typename === "ClassicLocation" && + boxData.location?.defaultBoxState !== "Scrap" + ? "Lost" === boxData.state || + "Scrap" === boxData.state || + "NotDelivered" === boxData.state || boxInTransit : false } border="2px" > {location.name} - {location.defaultBoxState !== BoxState.InStock && ( + {location.defaultBoxState !== "InStock" && ( <> {" "} - Boxes are  {location.defaultBoxState} diff --git a/front/src/views/Box/components/BoxTabs.tsx b/front/src/views/Box/components/BoxTabs.tsx index b162cd524..6139a1a7c 100644 --- a/front/src/views/Box/components/BoxTabs.tsx +++ b/front/src/views/Box/components/BoxTabs.tsx @@ -18,7 +18,6 @@ import { IDropdownOption } from "components/Form/SelectField"; import { ShipmentIcon } from "components/Icon/Transfer/ShipmentIcon"; import { BiNetworkChart } from "react-icons/bi"; import { FaDollyFlatbed, FaWarehouse } from "react-icons/fa"; -import { BoxByLabelIdentifierQuery, BoxState } from "types/generated/graphql"; import AssignBoxToShipment from "./AssignBoxToShipment"; import BoxMoveLocation from "./BoxMoveLocation"; diff --git a/front/src/views/Box/components/HistoryEntries.tsx b/front/src/views/Box/components/HistoryEntries.tsx index 43eb916a6..02b97188b 100644 --- a/front/src/views/Box/components/HistoryEntries.tsx +++ b/front/src/views/Box/components/HistoryEntries.tsx @@ -1,7 +1,6 @@ import { ListItem, ListIcon, List, Stack, Flex, Text, Box } from "@chakra-ui/react"; import { IconType } from "react-icons"; import { MdCheckCircle, MdSettings, MdHistory } from "react-icons/md"; -import { HistoryEntry } from "types/generated/graphql"; import { prepareBoxHistoryEntryText } from "utils/helpers"; interface IHistoryEntriesProps { diff --git a/front/src/views/BoxCreate/BoxCreateView.tsx b/front/src/views/BoxCreate/BoxCreateView.tsx index 28d6b78b9..dc981c2d2 100644 --- a/front/src/views/BoxCreate/BoxCreateView.tsx +++ b/front/src/views/BoxCreate/BoxCreateView.tsx @@ -6,15 +6,6 @@ import { useErrorHandling } from "hooks/useErrorHandling"; import { useNotification } from "hooks/useNotification"; import APILoadingIndicator from "components/APILoadingIndicator"; import { useNavigate, useParams } from "react-router-dom"; -import { - AllProductsAndLocationsForBaseQuery, - AllProductsAndLocationsForBaseQueryVariables, - BoxState, - CreateBoxMutation, - CreateBoxMutationVariables, - CheckIfQrExistsInDbQuery, - CheckIfQrExistsInDbQueryVariables, -} from "types/generated/graphql"; import { TAG_OPTIONS_FRAGMENT, PRODUCT_FIELDS_FRAGMENT } from "queries/fragments"; import { CHECK_IF_QR_EXISTS_IN_DB } from "queries/queries"; import BoxCreate, { ICreateBoxFormData } from "./components/BoxCreate"; diff --git a/front/src/views/BoxCreate/components/BoxCreate.stories.tsx b/front/src/views/BoxCreate/components/BoxCreate.stories.tsx index ee372ae4a..be7b4756c 100644 --- a/front/src/views/BoxCreate/components/BoxCreate.stories.tsx +++ b/front/src/views/BoxCreate/components/BoxCreate.stories.tsx @@ -1,5 +1,4 @@ import { Meta, StoryFn } from "@storybook/react"; -import { ProductGender } from "types/generated/graphql"; // import { DistroEvent } from "../State1Planning/DistroEventPlanning"; import { action } from "@storybook/addon-actions"; import BoxCreate, { IBoxCreateProps, IProductWithSizeRangeData, ISizeRangeData } from "./BoxCreate"; diff --git a/front/src/views/BoxCreate/components/BoxCreate.tsx b/front/src/views/BoxCreate/components/BoxCreate.tsx index 7631da21f..bb1835f3d 100644 --- a/front/src/views/BoxCreate/components/BoxCreate.tsx +++ b/front/src/views/BoxCreate/components/BoxCreate.tsx @@ -12,7 +12,6 @@ import { import { useEffect, useState } from "react"; import { SubmitHandler, useForm } from "react-hook-form"; -import { ProductGender } from "types/generated/graphql"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; diff --git a/front/src/views/BoxEdit/BoxEditView.tsx b/front/src/views/BoxEdit/BoxEditView.tsx index 835a571c3..ddeffd522 100644 --- a/front/src/views/BoxEdit/BoxEditView.tsx +++ b/front/src/views/BoxEdit/BoxEditView.tsx @@ -3,13 +3,6 @@ import { useMutation, useQuery } from "@apollo/client"; import { graphql } from "../../../../graphql"; import APILoadingIndicator from "components/APILoadingIndicator"; import { useNavigate, useParams } from "react-router-dom"; -import { - BoxByLabelIdentifierAndAllProductsWithBaseIdQuery, - BoxByLabelIdentifierAndAllProductsWithBaseIdQueryVariables, - BoxState, - UpdateContentOfBoxMutation, - UpdateContentOfBoxMutationVariables, -} from "types/generated/graphql"; import { TAG_OPTIONS_FRAGMENT, BOX_FIELDS_FRAGMENT, diff --git a/front/src/views/BoxEdit/components/BoxEdit.tsx b/front/src/views/BoxEdit/components/BoxEdit.tsx index 8322ac67c..e8f385d78 100644 --- a/front/src/views/BoxEdit/components/BoxEdit.tsx +++ b/front/src/views/BoxEdit/components/BoxEdit.tsx @@ -11,10 +11,6 @@ import { } from "@chakra-ui/react"; import NumberField from "components/Form/NumberField"; import SelectField, { IDropdownOption } from "components/Form/SelectField"; -import { - BoxByLabelIdentifierAndAllProductsWithBaseIdQuery, - ProductGender, -} from "types/generated/graphql"; import { useEffect, useRef, useState } from "react"; import { zodResolver } from "@hookform/resolvers/zod"; diff --git a/front/src/views/Boxes/BoxesView.tsx b/front/src/views/Boxes/BoxesView.tsx index 273081266..20220479f 100644 --- a/front/src/views/Boxes/BoxesView.tsx +++ b/front/src/views/Boxes/BoxesView.tsx @@ -1,7 +1,6 @@ import { useMemo } from "react"; import { useBackgroundQuery, useSuspenseQuery } from "@apollo/client"; import { graphql } from "../../../../graphql"; -import { BoxesForBoxesViewQuery, ActionOptionsForBoxesViewQuery } from "types/generated/graphql"; import { BASE_ORG_FIELDS_FRAGMENT, PRODUCT_BASIC_FIELDS_FRAGMENT, diff --git a/front/src/views/Boxes/BoxesViewActions.test.tsx b/front/src/views/Boxes/BoxesViewActions.test.tsx index bfbee8b21..e5ce57576 100644 --- a/front/src/views/Boxes/BoxesViewActions.test.tsx +++ b/front/src/views/Boxes/BoxesViewActions.test.tsx @@ -2,7 +2,6 @@ import { vi, beforeEach, it, expect } from "vitest"; import { basicShipment, generateMockShipment } from "mocks/shipments"; import { location1 } from "mocks/locations"; import { generateMockBox } from "mocks/boxes"; -import { BoxState } from "types/generated/graphql"; import { shipmentDetail1 } from "mocks/shipmentDetail"; import { useAuth0 } from "@auth0/auth0-react"; import { mockAuthenticatedUser } from "mocks/hooks"; diff --git a/front/src/views/Boxes/components/BoxesActionsAndTable.tsx b/front/src/views/Boxes/components/BoxesActionsAndTable.tsx index cbb57e58c..d6b70dca4 100644 --- a/front/src/views/Boxes/components/BoxesActionsAndTable.tsx +++ b/front/src/views/Boxes/components/BoxesActionsAndTable.tsx @@ -7,11 +7,6 @@ import { useAssignBoxesToShipment } from "hooks/useAssignBoxesToShipment"; import { useDeleteBoxes } from "hooks/useDeleteBoxes"; import { IBoxBasicFields } from "types/graphql-local-only"; import { Button } from "@chakra-ui/react"; -import { - BoxState, - BoxesForBoxesViewQuery, - BoxesForBoxesViewQueryVariables, -} from "types/generated/graphql"; import { ShipmentIcon } from "components/Icon/Transfer/ShipmentIcon"; import { useUnassignBoxesFromShipments } from "hooks/useUnassignBoxesFromShipments"; import { useNotification } from "hooks/useNotification"; diff --git a/front/src/views/Boxes/components/BoxesTable.tsx b/front/src/views/Boxes/components/BoxesTable.tsx index a66245494..c186108fe 100644 --- a/front/src/views/Boxes/components/BoxesTable.tsx +++ b/front/src/views/Boxes/components/BoxesTable.tsx @@ -31,7 +31,6 @@ import { includesOneOfMulipleStringsFilterFn, includesSomeObjectFilterFn, } from "components/Table/Filter"; -import { BoxesForBoxesViewQuery, BoxesForBoxesViewQueryVariables } from "types/generated/graphql"; import { IUseTableConfigReturnType } from "hooks/hooks"; import IndeterminateCheckbox from "./Checkbox"; import { GlobalFilter } from "./GlobalFilter"; diff --git a/front/src/views/Boxes/components/Filter.tsx b/front/src/views/Boxes/components/Filter.tsx index bc38cd31d..b9664ed23 100644 --- a/front/src/views/Boxes/components/Filter.tsx +++ b/front/src/views/Boxes/components/Filter.tsx @@ -1,6 +1,5 @@ import { SelectColumnFilterUI } from "components/Table/Filter"; import { ColumnInstance } from "react-table"; -import { BoxState } from "types/generated/graphql"; import { BoxRow } from "./types"; interface ISelectBoxStateFilterProps { diff --git a/front/src/views/Boxes/components/TableCells.tsx b/front/src/views/Boxes/components/TableCells.tsx index d2cefd434..0f1ec8155 100644 --- a/front/src/views/Boxes/components/TableCells.tsx +++ b/front/src/views/Boxes/components/TableCells.tsx @@ -1,7 +1,6 @@ import { VStack, Tag, TagLabel, Wrap, WrapItem, chakra } from "@chakra-ui/react"; import { isDate } from "date-fns"; import { CellProps } from "react-table"; -import { BoxState } from "types/generated/graphql"; import { colorIsBright } from "utils/helpers"; import { Style } from "victory"; @@ -9,19 +8,15 @@ export function StateCell({ value }: CellProps) { let color = "inherit"; if ( - value === BoxState.MarkedForShipment || - value === BoxState.InTransit || - value === BoxState.Receiving || - value === BoxState.Donated + value === "MarkedForShipment" || + value === "InTransit" || + value === "Receiving" || + value === "Donated" ) { color = "blue.700"; - } else if (value === BoxState.InStock) { + } else if (value === "InStock") { color = "green.700"; - } else if ( - value === BoxState.Scrap || - value === BoxState.Lost || - value === BoxState.NotDelivered - ) { + } else if (value === "Scrap" || value === "Lost" || value === "NotDelivered") { color = "red.700"; } diff --git a/front/src/views/Boxes/components/transformers.ts b/front/src/views/Boxes/components/transformers.ts index 2b2c0967c..9fbc84087 100644 --- a/front/src/views/Boxes/components/transformers.ts +++ b/front/src/views/Boxes/components/transformers.ts @@ -1,5 +1,4 @@ import { differenceInDays } from "date-fns"; -import { BoxesForBoxesViewQuery, BoxesForBoxesViewQueryVariables } from "types/generated/graphql"; import { Filters } from "react-table"; import { BoxRow } from "./types"; diff --git a/front/src/views/Boxes/components/types.ts b/front/src/views/Boxes/components/types.ts index b2412f025..c584fc654 100644 --- a/front/src/views/Boxes/components/types.ts +++ b/front/src/views/Boxes/components/types.ts @@ -1,4 +1,4 @@ -import { Shipment, Tag } from "types/generated/graphql"; + export type BoxRow = { labelIdentifier: string; diff --git a/front/src/views/Distributions/CreateDirectDistributionEventView/CreateDirectDistributionEventView.tsx b/front/src/views/Distributions/CreateDirectDistributionEventView/CreateDirectDistributionEventView.tsx index b3e234f8c..988ca8b06 100644 --- a/front/src/views/Distributions/CreateDirectDistributionEventView/CreateDirectDistributionEventView.tsx +++ b/front/src/views/Distributions/CreateDirectDistributionEventView/CreateDirectDistributionEventView.tsx @@ -3,12 +3,6 @@ import { graphql } from "../../../../../graphql"; import APILoadingIndicator from "components/APILoadingIndicator"; import { useCallback } from "react"; import { useNavigate } from "react-router-dom"; -import { - CreateDistributionEventMutation, - CreateDistributionEventMutationVariables, - DistroSpotsForBaseIdQuery, - DistroSpotsForBaseIdQueryVariables, -} from "types/generated/graphql"; import CreateDirectDistroEvent, { CreateDistroEventFormData, } from "./components/CreateDirectDistributionEvent"; @@ -46,10 +40,7 @@ const CreateDirectDistributionEventView = () => { const navigate = useNavigate(); - const [createDistributionEventMutation] = useMutation< - CreateDistributionEventMutation, - CreateDistributionEventMutationVariables - >(CREATE_DISTRIBUTION_EVENT_MUTATION); + const [createDistributionEventMutation] = useMutation(CREATE_DISTRIBUTION_EVENT_MUTATION); const onSubmitNewDistroEvent = useCallback( (createDistroEventFormData: CreateDistroEventFormData) => { @@ -85,10 +76,7 @@ const CreateDirectDistributionEventView = () => { [createDistributionEventMutation, currentBaseId, navigate], ); - const { loading, error, data } = useQuery< - DistroSpotsForBaseIdQuery, - DistroSpotsForBaseIdQueryVariables - >(DISTRO_SPOTS_FOR_BASE_ID, { + const { loading, error, data } = useQuery(DISTRO_SPOTS_FOR_BASE_ID, { variables: { baseId: currentBaseId, }, diff --git a/front/src/views/Distributions/CreateDistributionEventView/CreateDistributionEventView.tsx b/front/src/views/Distributions/CreateDistributionEventView/CreateDistributionEventView.tsx index 5a10e5992..d7b6a1f9c 100644 --- a/front/src/views/Distributions/CreateDistributionEventView/CreateDistributionEventView.tsx +++ b/front/src/views/Distributions/CreateDistributionEventView/CreateDistributionEventView.tsx @@ -3,11 +3,6 @@ import { graphql } from "../../../../../graphql"; import APILoadingIndicator from "components/APILoadingIndicator"; import { useCallback } from "react"; import { useNavigate, useParams } from "react-router-dom"; -import { - CreateDistributionEventMutation, - CreateDistributionEventMutationVariables, - DistributionSpotQuery, -} from "types/generated/graphql"; import CreateDistroEvent, { CreateDistroEventFormData } from "./components/CreateDistributionEvent"; import { addHours } from "date-fns"; import { getISODateTimeFromDateAndTimeString } from "utils/helpers"; @@ -52,10 +47,7 @@ const CreateDistributionEventView = () => { }>(); const navigate = useNavigate(); - const [createDistributionEventMutation] = useMutation< - CreateDistributionEventMutation, - CreateDistributionEventMutationVariables - >(CREATE_DISTRIBUTION_EVENT_MUTATION); + const [createDistributionEventMutation] = useMutation(CREATE_DISTRIBUTION_EVENT_MUTATION); const onSubmitNewDistroEvent = useCallback( (createDistroEventFormData: CreateDistroEventFormData) => { @@ -91,8 +83,8 @@ const CreateDistributionEventView = () => { [baseId, createDistributionEventMutation, distributionSpotId, navigate], ); - const { data, loading, error } = useQuery(DISTRIBUTION_SPOT_QUERY, { - variables: { id: distributionSpotId }, + const { data, loading, error } = useQuery(DISTRIBUTION_SPOT_QUERY, { + variables: { id: distributionSpotId || "0" }, }); if (loading) { diff --git a/front/src/views/Distributions/DistributionReturnTrackings/DistributionReturnTrackingsView/DistributionReturnTrackingsView.tsx b/front/src/views/Distributions/DistributionReturnTrackings/DistributionReturnTrackingsView/DistributionReturnTrackingsView.tsx index 2bc6efba4..ed1609947 100644 --- a/front/src/views/Distributions/DistributionReturnTrackings/DistributionReturnTrackingsView/DistributionReturnTrackingsView.tsx +++ b/front/src/views/Distributions/DistributionReturnTrackings/DistributionReturnTrackingsView/DistributionReturnTrackingsView.tsx @@ -1,10 +1,6 @@ import { useQuery } from "@apollo/client"; import APILoadingIndicator from "components/APILoadingIndicator"; import { useParams } from "react-router-dom"; -import { - DataForReturnTrackingOverviewForBaseQuery, - DataForReturnTrackingOverviewForBaseQueryVariables, -} from "types/generated/graphql"; import { z } from "zod"; import { DATA_FOR_RETURN_TRACKING_OVERVIEW_FOR_BASE_QUERY } from "../../queries"; import { diff --git a/front/src/views/Distributions/DistributionReturnTrackings/DistributionReturnTrackingsView/components/DistributionListForReturnTracking.tsx b/front/src/views/Distributions/DistributionReturnTrackings/DistributionReturnTrackingsView/components/DistributionListForReturnTracking.tsx index b4009206c..1be476279 100644 --- a/front/src/views/Distributions/DistributionReturnTrackings/DistributionReturnTrackingsView/components/DistributionListForReturnTracking.tsx +++ b/front/src/views/Distributions/DistributionReturnTrackings/DistributionReturnTrackingsView/components/DistributionListForReturnTracking.tsx @@ -16,11 +16,6 @@ import { getDay, parseISO, isPast } from "date-fns"; import _ from "lodash"; import { useState } from "react"; import { useNavigate, useParams } from "react-router-dom"; -import { - DistributionEventState, - StartDistributionEventsTrackingGroupMutation, - StartDistributionEventsTrackingGroupMutationVariables, -} from "types/generated/graphql"; import { getDateNormalizedDateTime, weekDayNumberToWeekDayName } from "utils/helpers"; import { START_DISTRIBUTION_EVENTS_TRACKING_GROUP_MUTATION } from "views/Distributions/queries"; import { DistributionEventDetails, DistributionTrackingGroup } from "views/Distributions/types"; diff --git a/front/src/views/Distributions/DistributionReturnTrackings/DistrosReturnTrackingGroupView/DistrosReturnTrackingGroupView.tsx b/front/src/views/Distributions/DistributionReturnTrackings/DistrosReturnTrackingGroupView/DistrosReturnTrackingGroupView.tsx index fc35e5971..ede60429b 100644 --- a/front/src/views/Distributions/DistributionReturnTrackings/DistrosReturnTrackingGroupView/DistrosReturnTrackingGroupView.tsx +++ b/front/src/views/Distributions/DistributionReturnTrackings/DistrosReturnTrackingGroupView/DistrosReturnTrackingGroupView.tsx @@ -24,15 +24,6 @@ import APILoadingIndicator from "components/APILoadingIndicator"; import _ from "lodash"; import { useRef, useState } from "react"; import { useNavigate, useParams } from "react-router-dom"; -import { - CompleteDistributionEventsTrackingGroupMutation, - CompleteDistributionEventsTrackingGroupMutationVariables, - DistributionEventsTrackingGroupQuery, - DistributionEventsTrackingGroupQueryVariables, - DistributionEventTrackingFlowDirection, - SetReturnedNumberOfItemsForDistributionEventsTrackingGroupMutation, - SetReturnedNumberOfItemsForDistributionEventsTrackingGroupMutationVariables, -} from "types/generated/graphql"; import DistributionEventTimeRangeDisplay from "../../components/DistributionEventTimeRangeDisplay"; import { COMPLETE_DISTRIBUTION_EVENTS_TRACKING_GROUP_MUTATION, diff --git a/front/src/views/Distributions/DistroEventView/DistroEventView.tsx b/front/src/views/Distributions/DistroEventView/DistroEventView.tsx index 56b726bab..71cd7bad7 100644 --- a/front/src/views/Distributions/DistroEventView/DistroEventView.tsx +++ b/front/src/views/Distributions/DistroEventView/DistroEventView.tsx @@ -1,19 +1,14 @@ import { useQuery } from "@apollo/client"; import APILoadingIndicator from "components/APILoadingIndicator"; import { useParams } from "react-router-dom"; -import { - DistributionEventQuery, - DistributionEventQueryVariables -} from "types/generated/graphql"; import { DISTRIBUTION_EVENT_QUERY } from "../queries"; import { DistributionEventDetails, DistributionEventDetailsSchema } from "../types"; import DistroEventContainer from "./components/DistroEventContainer"; const graphqlToContainerTransformer = ( - distributionEventData: DistributionEventQuery | undefined + distributionEventData: DistributionEventQuery | undefined, ): DistributionEventDetails => { - - if(distributionEventData?.distributionEvent?.distributionSpot == null) { + if (distributionEventData?.distributionEvent?.distributionSpot == null) { throw new Error("distributionEventData.distributionEvent.distributionSpot is null"); } return DistributionEventDetailsSchema.parse(distributionEventData?.distributionEvent); @@ -43,7 +38,7 @@ const DistroEventView = () => { const transformedData = graphqlToContainerTransformer(data); - return ; + return ; }; export default DistroEventView; diff --git a/front/src/views/Distributions/DistroEventView/components/DistroEventContainer.tsx b/front/src/views/Distributions/DistroEventView/components/DistroEventContainer.tsx index addf11c34..288f1de29 100644 --- a/front/src/views/Distributions/DistroEventView/components/DistroEventContainer.tsx +++ b/front/src/views/Distributions/DistroEventView/components/DistroEventContainer.tsx @@ -17,11 +17,6 @@ import { } from "@chakra-ui/react"; import React, { useCallback } from "react"; import { Link as RouterLink } from "react-router-dom"; -import { - ChangeDistributionEventStateMutation, - ChangeDistributionEventStateMutationVariables, - DistributionEventState, -} from "types/generated/graphql"; import { useGetUrlForResourceHelpers } from "hooks/hooks"; import DistributionEventTimeRangeDisplay from "views/Distributions/components/DistributionEventTimeRangeDisplay"; import DistributionStateProgressBar from "views/Distributions/components/DistributionStateProgressBar"; diff --git a/front/src/views/Distributions/DistroEventView/components/State1Planning/DistroEventDetailsForPlanningState.stories.tsx b/front/src/views/Distributions/DistroEventView/components/State1Planning/DistroEventDetailsForPlanningState.stories.tsx index f6db05bca..6ab1bcb4c 100644 --- a/front/src/views/Distributions/DistroEventView/components/State1Planning/DistroEventDetailsForPlanningState.stories.tsx +++ b/front/src/views/Distributions/DistroEventView/components/State1Planning/DistroEventDetailsForPlanningState.stories.tsx @@ -1,6 +1,5 @@ import { action } from "@storybook/addon-actions"; import { Meta, StoryFn } from "@storybook/react"; -import { ProductGender } from "types/generated/graphql"; import { IPackingListEntry } from "views/Distributions/types"; import DistroEventDetailsForPlanningState from "./DistroEventDetailsForPlanningState"; diff --git a/front/src/views/Distributions/DistroEventView/components/State1Planning/DistroEventDetailsForPlanningState.tsx b/front/src/views/Distributions/DistroEventView/components/State1Planning/DistroEventDetailsForPlanningState.tsx index 32f0f9a2b..a6eb252a3 100644 --- a/front/src/views/Distributions/DistroEventView/components/State1Planning/DistroEventDetailsForPlanningState.tsx +++ b/front/src/views/Distributions/DistroEventView/components/State1Planning/DistroEventDetailsForPlanningState.tsx @@ -26,7 +26,6 @@ import { } from "@chakra-ui/react"; import _ from "lodash"; import { useContext, useEffect, useRef, useState } from "react"; -import { ProductGender } from "types/generated/graphql"; import { IPackingListEntry } from "views/Distributions/types"; import { DistroEventDetailsForPlanningStateContext } from "./DistroEventDetailsForPlanningStateContainer"; diff --git a/front/src/views/Distributions/DistroEventView/components/State2Packing/DistroEventDetailsForPackingState.stories.tsx b/front/src/views/Distributions/DistroEventView/components/State2Packing/DistroEventDetailsForPackingState.stories.tsx index 5c695e4d0..35e253d7b 100644 --- a/front/src/views/Distributions/DistroEventView/components/State2Packing/DistroEventDetailsForPackingState.stories.tsx +++ b/front/src/views/Distributions/DistroEventView/components/State2Packing/DistroEventDetailsForPackingState.stories.tsx @@ -1,5 +1,4 @@ import { StoryFn, Meta } from "@storybook/react"; -import { ProductGender } from "types/generated/graphql"; import DistroEventDetailsForPackingState from "./DistroEventDetailsForPackingState"; // import { DistroEvent } from "../State1Planning/DistroEventPlanning"; import { BoxData, IPackingListEntryForPackingState } from "views/Distributions/types"; diff --git a/front/src/views/Distributions/DistroEventView/components/State2Packing/DistroEventDetailsForPackingState.tsx b/front/src/views/Distributions/DistroEventView/components/State2Packing/DistroEventDetailsForPackingState.tsx index e5bffe0e0..709c9b573 100644 --- a/front/src/views/Distributions/DistroEventView/components/State2Packing/DistroEventDetailsForPackingState.tsx +++ b/front/src/views/Distributions/DistroEventView/components/State2Packing/DistroEventDetailsForPackingState.tsx @@ -20,12 +20,6 @@ import { } from "@chakra-ui/react"; import _ from "lodash"; import { useCallback } from "react"; -import { - AssignBoxToDistributionEventMutation, - AssignBoxToDistributionEventMutationVariables, - MoveItemsToDistributionEventMutation, - MoveItemsToDistributionEventMutationVariables, -} from "types/generated/graphql"; import { // MATCHING_PACKED_ITEMS_COLLECTIONS_FOR_PACKING_LIST_ENTRY, ASSIGN_BOX_TO_DISTRIBUTION_MUTATION, @@ -57,15 +51,9 @@ const PackingListEntry = ({ const toast = useToast(); - const [assignBoxToDistributionEventMutation] = useMutation< - AssignBoxToDistributionEventMutation, - AssignBoxToDistributionEventMutationVariables - >(ASSIGN_BOX_TO_DISTRIBUTION_MUTATION); + const [assignBoxToDistributionEventMutation] = useMutation(ASSIGN_BOX_TO_DISTRIBUTION_MUTATION); - const [moveItemsToDistributionEventMutation] = useMutation< - MoveItemsToDistributionEventMutation, - MoveItemsToDistributionEventMutationVariables - >(MOVE_ITEMS_TO_DISTRIBUTION_EVENT); + const [moveItemsToDistributionEventMutation] = useMutation(MOVE_ITEMS_TO_DISTRIBUTION_EVENT); const onAddUnboxedItemsToDistributionEvent = useCallback( (boxLabelIdentifier: string, numberOfItemsToMove: number) => { diff --git a/front/src/views/Distributions/DistroEventView/components/State2Packing/components/PackingAddBoxOrItemsForPackingListEntryOverlay/PackingScanBoxOrFindByLabelOverlayContent.tsx b/front/src/views/Distributions/DistroEventView/components/State2Packing/components/PackingAddBoxOrItemsForPackingListEntryOverlay/PackingScanBoxOrFindByLabelOverlayContent.tsx index 147817cc9..52cbaf7fe 100644 --- a/front/src/views/Distributions/DistroEventView/components/State2Packing/components/PackingAddBoxOrItemsForPackingListEntryOverlay/PackingScanBoxOrFindByLabelOverlayContent.tsx +++ b/front/src/views/Distributions/DistroEventView/components/State2Packing/components/PackingAddBoxOrItemsForPackingListEntryOverlay/PackingScanBoxOrFindByLabelOverlayContent.tsx @@ -13,12 +13,6 @@ import { import { QrReaderScanner } from "components/QrReader/components/QrReaderScanner"; import { useCallback, useState } from "react"; -import { - BoxDetailsQuery, - BoxDetailsQueryVariables, - GetBoxLabelIdentifierForQrCodeQuery, - GetBoxLabelIdentifierForQrCodeQueryVariables, -} from "types/generated/graphql"; import { extractQrCodeFromUrl } from "hooks/useQrResolver"; import { BOX_DETAILS_BY_LABEL_IDENTIFIER_QUERY, diff --git a/front/src/views/Distributions/DistroEventView/components/State4ReturnTrackingInProgress/DistroEventDetailsForReturnTrackingInProgressStateContainer.tsx b/front/src/views/Distributions/DistroEventView/components/State4ReturnTrackingInProgress/DistroEventDetailsForReturnTrackingInProgressStateContainer.tsx index 0f505bbeb..6f452bfe5 100644 --- a/front/src/views/Distributions/DistroEventView/components/State4ReturnTrackingInProgress/DistroEventDetailsForReturnTrackingInProgressStateContainer.tsx +++ b/front/src/views/Distributions/DistroEventView/components/State4ReturnTrackingInProgress/DistroEventDetailsForReturnTrackingInProgressStateContainer.tsx @@ -2,15 +2,9 @@ import { useQuery } from "@apollo/client"; import { Flex, Heading, Link, Text } from "@chakra-ui/react"; import APILoadingIndicator from "components/APILoadingIndicator"; import { Link as RouterLink } from "react-router-dom"; -import { - ReturnTrackingGroupIdForDistributionEventQuery, - ReturnTrackingGroupIdForDistributionEventQueryVariables -} from "types/generated/graphql"; import { useGetUrlForResourceHelpers } from "hooks/hooks"; import { RETURN_TRACKING_GROUP_ID_FOR_DISTRIBUTION_EVENT_QUERY } from "views/Distributions/queries"; -import { - DistributionEventDetails -} from "views/Distributions/types"; +import { DistributionEventDetails } from "views/Distributions/types"; interface DistroEventDetailsForPackingStateProps { distributionEventDetails: DistributionEventDetails; @@ -19,12 +13,11 @@ interface DistroEventDetailsForPackingStateProps { const DistroEventDetailsForReturnTrackingInProgressStateContainer = ({ distributionEventDetails, }: DistroEventDetailsForPackingStateProps) => { - const { getBaseRootUrlForCurrentBase } = useGetUrlForResourceHelpers(); const { data, loading, error } = useQuery< - ReturnTrackingGroupIdForDistributionEventQuery, - ReturnTrackingGroupIdForDistributionEventQueryVariables + ReturnTrackingGroupIdForDistributionEventQuery, + ReturnTrackingGroupIdForDistributionEventQueryVariables >(RETURN_TRACKING_GROUP_ID_FOR_DISTRIBUTION_EVENT_QUERY, { variables: { distributionEventId: distributionEventDetails.id }, // pollInterval: 5000, @@ -39,24 +32,24 @@ const DistroEventDetailsForReturnTrackingInProgressStateContainer = ({ } return ( - - - - Return Tracking In Progress - - Go to the{" "} - - Return Tracking - {" "} - in which this Distro Event is part of. - - + + + + Return Tracking In Progress + + Go to the{" "} + + Return Tracking + {" "} + in which this Distro Event is part of. + + ); }; diff --git a/front/src/views/Distributions/DistroEventView/components/State5Completed/DistroEventCompleted.stories.tsx b/front/src/views/Distributions/DistroEventView/components/State5Completed/DistroEventCompleted.stories.tsx index bb7022440..e9783f61a 100644 --- a/front/src/views/Distributions/DistroEventView/components/State5Completed/DistroEventCompleted.stories.tsx +++ b/front/src/views/Distributions/DistroEventView/components/State5Completed/DistroEventCompleted.stories.tsx @@ -1,6 +1,5 @@ import { StoryFn, Meta } from "@storybook/react"; import DistroEventCompleted, { DistroEventData } from "./DistroEventCompleted"; -import { DistributionEventState, ProductGender } from "types/generated/graphql"; const mockedDistroEvent: DistroEventData = { eventDate: new Date("2022/08/22"), diff --git a/front/src/views/Distributions/DistroEventView/components/State5Completed/DistroEventCompleted.tsx b/front/src/views/Distributions/DistroEventView/components/State5Completed/DistroEventCompleted.tsx index d1d631354..ccedd4110 100644 --- a/front/src/views/Distributions/DistroEventView/components/State5Completed/DistroEventCompleted.tsx +++ b/front/src/views/Distributions/DistroEventView/components/State5Completed/DistroEventCompleted.tsx @@ -1,10 +1,4 @@ -import { - Flex, - Box, - Text, - SimpleGrid, -} from "@chakra-ui/react"; -import { DistributionEventState, ProductGender } from "types/generated/graphql"; +import { Flex, Box, Text, SimpleGrid } from "@chakra-ui/react"; import { distroEventStateHumanReadableLabels } from "views/Distributions/baseData"; export interface BTBox { @@ -31,7 +25,7 @@ interface DistroEventProps { const DistroEventCompleted = ({ distroEventData }: DistroEventProps) => { return ( - + Distro Event @@ -44,14 +38,22 @@ const DistroEventCompleted = ({ distroEventData }: DistroEventProps) => { {(distroEventData?.outflows?.length || 0) > 0 ? ( - Outflows: + + Outflows: + ) : null} {distroEventData.outflows?.map((box) => { return ( <> - - {/* probably must be change to a react table */} - + {/* probably must be change to a react table */} + {box.labelIdentifier} {box.name} {box.numberOfItems} @@ -63,12 +65,21 @@ const DistroEventCompleted = ({ distroEventData }: DistroEventProps) => { ); })} {(distroEventData?.returns?.length || 0) > 0 ? ( - Returns: + + Returns: + ) : null} {distroEventData.returns?.map((box) => { return ( <> - + {box.labelIdentifier} {box.name} {box.numberOfItems} diff --git a/front/src/views/Distributions/DistroSpotsView/components/DistroSpots.stories.tsx b/front/src/views/Distributions/DistroSpotsView/components/DistroSpots.stories.tsx index 6b56bda61..cda0e0c89 100644 --- a/front/src/views/Distributions/DistroSpotsView/components/DistroSpots.stories.tsx +++ b/front/src/views/Distributions/DistroSpotsView/components/DistroSpots.stories.tsx @@ -1,7 +1,6 @@ import { StoryFn, Meta } from "@storybook/react"; import DistroSpots from "./DistroSpots"; import { DistributionSpotEnrichedData } from "views/Distributions/types"; -import { DistributionEventState } from "types/generated/graphql"; const mockedDistroSpots: DistributionSpotEnrichedData[] = [ { diff --git a/front/src/views/Distributions/DistroSpotsView/components/DistroSpots.tsx b/front/src/views/Distributions/DistroSpotsView/components/DistroSpots.tsx index 33a073116..7886ebe36 100644 --- a/front/src/views/Distributions/DistroSpotsView/components/DistroSpots.tsx +++ b/front/src/views/Distributions/DistroSpotsView/components/DistroSpots.tsx @@ -11,7 +11,6 @@ import { Text, Button, } from "@chakra-ui/react"; -import { DistributionEventState } from "types/generated/graphql"; import { distroEventStateHumanReadableLabels } from "views/Distributions/baseData"; import DistributionEventTimeRangeDisplay from "views/Distributions/components/DistributionEventTimeRangeDisplay"; import { DistributionSpotEnrichedData, DistroEventForSpot } from "views/Distributions/types"; diff --git a/front/src/views/Distributions/DistroSpotsView/components/DistroSpotsContainer.tsx b/front/src/views/Distributions/DistroSpotsView/components/DistroSpotsContainer.tsx index 804272b7e..cc4ac68bb 100644 --- a/front/src/views/Distributions/DistroSpotsView/components/DistroSpotsContainer.tsx +++ b/front/src/views/Distributions/DistroSpotsView/components/DistroSpotsContainer.tsx @@ -1,9 +1,5 @@ import { useQuery } from "@apollo/client"; import APILoadingIndicator from "components/APILoadingIndicator"; -import { - DistroSpotsForBaseIdQuery, - DistroSpotsForBaseIdQueryVariables -} from "types/generated/graphql"; import { useGlobalSiteState } from "hooks/hooks"; import { DISTRO_SPOTS_FOR_BASE_ID } from "views/Distributions/queries"; import { DistributionSpotEnrichedData } from "views/Distributions/types"; @@ -22,7 +18,6 @@ const DistroSpotsContainer = ({ }: DistroSpotsContainerProps) => { const { currentBaseId } = useGlobalSiteState(); - const { loading, error, data } = useQuery< DistroSpotsForBaseIdQuery, DistroSpotsForBaseIdQueryVariables @@ -44,31 +39,28 @@ const DistroSpotsContainer = ({ return <>No distro spot data; } - const transformedDistroSpotData = - data.base.distributionSpots.map((distroSpot) => { - return { - id: distroSpot.id, - name: distroSpot.name, - geoData: { - latitude: distroSpot.latitude, - longitude: distroSpot.longitude, - }, - distroEvents: distroSpot.distributionEvents.map((distroEvent) => ({ - id: distroEvent.id, - state: distroEvent.state, - plannedStartDateTime: new Date(distroEvent.plannedStartDateTime), - plannedEndDateTime: new Date(distroEvent.plannedEndDateTime), - })), - }; - }) as DistributionSpotEnrichedData[]; + const transformedDistroSpotData = data.base.distributionSpots.map((distroSpot) => { + return { + id: distroSpot.id, + name: distroSpot.name, + geoData: { + latitude: distroSpot.latitude, + longitude: distroSpot.longitude, + }, + distroEvents: distroSpot.distributionEvents.map((distroEvent) => ({ + id: distroEvent.id, + state: distroEvent.state, + plannedStartDateTime: new Date(distroEvent.plannedStartDateTime), + plannedEndDateTime: new Date(distroEvent.plannedEndDateTime), + })), + }; + }) as DistributionSpotEnrichedData[]; return ( ); diff --git a/front/src/views/Distributions/DistrosDashboardView/DistrosDashboardView.tsx b/front/src/views/Distributions/DistrosDashboardView/DistrosDashboardView.tsx index c1f096fb0..d32099b7e 100644 --- a/front/src/views/Distributions/DistrosDashboardView/DistrosDashboardView.tsx +++ b/front/src/views/Distributions/DistrosDashboardView/DistrosDashboardView.tsx @@ -19,10 +19,6 @@ import { import APILoadingIndicator from "components/APILoadingIndicator"; import { useCallback, useEffect, useState } from "react"; import { useNavigate, useParams, useSearchParams } from "react-router-dom"; -import { - DistributionEventsForBaseQuery, - DistributionEventsForBaseQueryVariables, -} from "types/generated/graphql"; import { z } from "zod"; import { DISTRIBUTION_EVENTS_FOR_BASE_ID } from "../queries"; import { DistributionEventDetails, DistributionEventDetailsSchema } from "../types"; diff --git a/front/src/views/Distributions/DistrosDashboardView/components/DistributionList.tsx b/front/src/views/Distributions/DistrosDashboardView/components/DistributionList.tsx index a927f6c8c..e4de2885e 100644 --- a/front/src/views/Distributions/DistrosDashboardView/components/DistributionList.tsx +++ b/front/src/views/Distributions/DistrosDashboardView/components/DistributionList.tsx @@ -12,7 +12,6 @@ import { import { isFuture, isPast, isToday } from "date-fns"; import _ from "lodash"; import { NavLink } from "react-router-dom"; -import { DistributionEventState } from "types/generated/graphql"; import { useGetUrlForResourceHelpers } from "hooks/hooks"; import DistributionEventTimeRangeDisplay from "views/Distributions/components/DistributionEventTimeRangeDisplay"; import { DistributionEventDetails } from "views/Distributions/types"; diff --git a/front/src/views/Distributions/DistrosDashboardView/components/DistroEventsCalendar/DistroEventsCalendarContainer.stories.tsx b/front/src/views/Distributions/DistrosDashboardView/components/DistroEventsCalendar/DistroEventsCalendarContainer.stories.tsx index e7acf20df..0fc50d4e7 100644 --- a/front/src/views/Distributions/DistrosDashboardView/components/DistroEventsCalendar/DistroEventsCalendarContainer.stories.tsx +++ b/front/src/views/Distributions/DistrosDashboardView/components/DistroEventsCalendar/DistroEventsCalendarContainer.stories.tsx @@ -1,6 +1,5 @@ import { Meta, StoryFn } from "@storybook/react"; import { addDays, addHours } from "date-fns"; -import { DistributionEventState } from "types/generated/graphql"; import DistroEventsCalendarContainer from "./DistroEventsCalendarContainer"; export default { diff --git a/front/src/views/Distributions/DistrosDashboardView/components/DistroEventsStatistics.tsx b/front/src/views/Distributions/DistrosDashboardView/components/DistroEventsStatistics.tsx index 4bd286013..5e42dc51f 100644 --- a/front/src/views/Distributions/DistrosDashboardView/components/DistroEventsStatistics.tsx +++ b/front/src/views/Distributions/DistrosDashboardView/components/DistroEventsStatistics.tsx @@ -15,10 +15,6 @@ import { } from "@chakra-ui/react"; import { format } from "date-fns"; import { ReactNode } from "react"; -import { - DownloadDistributionEventsStatisticsQuery, - DownloadDistributionEventsStatisticsQueryVariables, -} from "types/generated/graphql"; import { useGetUrlForResourceHelpers } from "hooks/hooks"; import { VictoryPie } from "victory"; @@ -118,30 +114,25 @@ const DistroEventsStatistics = () => { ]; const downloadCsvExport = (baseId: string) => { - apolloClient - .query< - DownloadDistributionEventsStatisticsQuery, - DownloadDistributionEventsStatisticsQueryVariables - >({ query: DOWNLOAD_STATIC_DATA, variables: { baseId } }) - .then((result) => { - const csvContent = - "data:text/csv;charset=utf-8," + - exportCsvColumns.join(",") + - "\n" + - result.data.base?.distributionEventsStatistics - .map((e) => exportCsvColumns.map((c) => e[c]).join(",")) - .join("\n"); + apolloClient.query({ query: DOWNLOAD_STATIC_DATA, variables: { baseId } }).then((result) => { + const csvContent = + "data:text/csv;charset=utf-8," + + exportCsvColumns.join(",") + + "\n" + + result.data.base?.distributionEventsStatistics + .map((e) => exportCsvColumns.map((c) => e[c]).join(",")) + .join("\n"); - const dateStr = format(new Date(), "MM-dd-yyyy-HH-mm-ss"); - const filename = `boxtribute_base_${baseId}_distributions_export_${dateStr}.csv`; - const encodedUri = encodeURI(csvContent); - const link = document.createElement("a"); - link.setAttribute("href", encodedUri); - link.setAttribute("download", filename); - document.body.appendChild(link); + const dateStr = format(new Date(), "MM-dd-yyyy-HH-mm-ss"); + const filename = `boxtribute_base_${baseId}_distributions_export_${dateStr}.csv`; + const encodedUri = encodeURI(csvContent); + const link = document.createElement("a"); + link.setAttribute("href", encodedUri); + link.setAttribute("download", filename); + document.body.appendChild(link); - link.click(); - }); + link.click(); + }); }; return ( diff --git a/front/src/views/Distributions/baseData.ts b/front/src/views/Distributions/baseData.ts index 6afba7ccd..af44187dc 100644 --- a/front/src/views/Distributions/baseData.ts +++ b/front/src/views/Distributions/baseData.ts @@ -1,4 +1,4 @@ -import { DistributionEventState } from "../../types/generated/graphql"; + export const distroEventStateHumanReadableLabels = new Map([ [DistributionEventState.Planning, "Planning"], diff --git a/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPacking.stories.tsx b/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPacking.stories.tsx index 5a9f88682..d58320a56 100644 --- a/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPacking.stories.tsx +++ b/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPacking.stories.tsx @@ -1,5 +1,4 @@ import { StoryFn, Meta } from "@storybook/react"; -import { ProductGender } from "types/generated/graphql"; import AddItemsToPackingList, { ProductDataForPackingList } from "./AddItemsToPackingList"; const clothingCategory = { diff --git a/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPackingList.tsx b/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPackingList.tsx index 98d0efb4b..2bb3ab42d 100644 --- a/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPackingList.tsx +++ b/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPackingList.tsx @@ -15,7 +15,6 @@ import { } from "@chakra-ui/react"; import _ from "lodash"; import { useContext, useState } from "react"; -import { ProductGender } from "types/generated/graphql"; import { DistroEventDetailsForPlanningStateContext } from "views/Distributions/DistroEventView/components/State1Planning/DistroEventDetailsForPlanningStateContainer"; import { IPackingListEntry } from "views/Distributions/types"; diff --git a/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPackingListContainer.tsx b/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPackingListContainer.tsx index ff4cb8642..3a5f9fb5a 100644 --- a/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPackingListContainer.tsx +++ b/front/src/views/Distributions/components/AddItemsToPackingList/AddItemsToPackingListContainer.tsx @@ -1,11 +1,6 @@ import { useQuery } from "@apollo/client"; import APILoadingIndicator from "components/APILoadingIndicator"; import { useParams } from "react-router-dom"; -import { - AllProductsForPackingListQuery, - AllProductsForPackingListQueryVariables, - ProductGender, -} from "types/generated/graphql"; import { ALL_PRODUCTS_FOR_PACKING_LIST } from "views/Distributions/queries"; import { IPackingListEntry, Product } from "views/Distributions/types"; import AddItemsToPackingList, { ProductDataForPackingList } from "./AddItemsToPackingList"; diff --git a/front/src/views/Distributions/components/DistributionStateProgressBar.tsx b/front/src/views/Distributions/components/DistributionStateProgressBar.tsx index 73d0bdd74..e76e0e434 100644 --- a/front/src/views/Distributions/components/DistributionStateProgressBar.tsx +++ b/front/src/views/Distributions/components/DistributionStateProgressBar.tsx @@ -1,6 +1,5 @@ import { Box, HStack, Link, Text } from "@chakra-ui/react"; import React from "react"; -import { DistributionEventState } from "types/generated/graphql"; enum SimplifiedDistributionEventState { Planning = "Planning", @@ -32,34 +31,35 @@ const mapRealStatesToSimplifiedStates = (state: DistributionEventState) => { } }; -export const resolveSimplifiedDistroEventStateHumanReadableLabelsAndDistroEventState = (state: SimplifiedDistributionEventState): { +export const resolveSimplifiedDistroEventStateHumanReadableLabelsAndDistroEventState = ( + state: SimplifiedDistributionEventState, +): { label: string; distributionEventState: DistributionEventState; -} => - { - switch(state) { - case SimplifiedDistributionEventState.Planning: - return { - label: "Planning", - distributionEventState: DistributionEventState.Planning, - }; - case SimplifiedDistributionEventState.Packing: - return { - label: "Packing", - distributionEventState: DistributionEventState.Packing, - } - case SimplifiedDistributionEventState.OnDistro: - return { - label: "On Distribution", - distributionEventState: DistributionEventState.OnDistro, - } - case SimplifiedDistributionEventState.Returned: - return { - label: "Returned", - distributionEventState: DistributionEventState.ReturnedFromDistribution, - } - } +} => { + switch (state) { + case SimplifiedDistributionEventState.Planning: + return { + label: "Planning", + distributionEventState: DistributionEventState.Planning, + }; + case SimplifiedDistributionEventState.Packing: + return { + label: "Packing", + distributionEventState: DistributionEventState.Packing, + }; + case SimplifiedDistributionEventState.OnDistro: + return { + label: "On Distribution", + distributionEventState: DistributionEventState.OnDistro, + }; + case SimplifiedDistributionEventState.Returned: + return { + label: "Returned", + distributionEventState: DistributionEventState.ReturnedFromDistribution, + }; } +}; const DistributionStateProgressBar = ({ activeState, @@ -70,31 +70,36 @@ const DistributionStateProgressBar = ({ }) => { const simplifiedActiveState = mapRealStatesToSimplifiedStates(activeState); - const joinedPlanningStates = - simplifiedDistroEventStateOrder.map((state, i) => { - const isActiveState = state === simplifiedActiveState; - const humanReadbaleStateAndDistroEventState = resolveSimplifiedDistroEventStateHumanReadableLabelsAndDistroEventState(state); - if (isActiveState) { - return ( - - {i + 1}. {humanReadbaleStateAndDistroEventState.label} - - ); - } else { - const text = ( - - {i + 1}. {humanReadbaleStateAndDistroEventState.label} - - ); - return simplifiedActiveState !== SimplifiedDistributionEventState.Returned ? ( - onMoveToStage(humanReadbaleStateAndDistroEventState.distributionEventState)}> - {text} - - ) : ( - text - ); - } - }); + const joinedPlanningStates = simplifiedDistroEventStateOrder.map((state, i) => { + const isActiveState = state === simplifiedActiveState; + const humanReadbaleStateAndDistroEventState = + resolveSimplifiedDistroEventStateHumanReadableLabelsAndDistroEventState(state); + if (isActiveState) { + return ( + + {i + 1}. {humanReadbaleStateAndDistroEventState.label} + + ); + } else { + const text = ( + + {i + 1}. {humanReadbaleStateAndDistroEventState.label} + + ); + return simplifiedActiveState !== SimplifiedDistributionEventState.Returned ? ( + + onMoveToStage(humanReadbaleStateAndDistroEventState.distributionEventState) + } + > + {text} + + ) : ( + text + ); + } + }); // .reduce((prev, curr) => [prev, , curr]); return ( diff --git a/front/src/views/Distributions/helpers.ts b/front/src/views/Distributions/helpers.ts index 3e6c80e29..c702341c8 100644 --- a/front/src/views/Distributions/helpers.ts +++ b/front/src/views/Distributions/helpers.ts @@ -1,4 +1,4 @@ -import { DistributionEventState } from "types/generated/graphql"; + export const getNextState = (state: DistributionEventState) => { switch (state) { diff --git a/front/src/views/Distributions/types.ts b/front/src/views/Distributions/types.ts index 040149fea..427f215f4 100644 --- a/front/src/views/Distributions/types.ts +++ b/front/src/views/Distributions/types.ts @@ -1,4 +1,6 @@ -import { DistributionEventState, ProductGender } from "types/generated/graphql"; + +import { DistributionEventState } from "types/generated/graphql"; +import { ProductGender } from "types/query-types"; import { z } from "zod"; // export const DistributionEventStateSchema = z.enum(["Planning", "Packing", "OnDistro", "Returned", "Completed"]); diff --git a/front/src/views/QrReader/QrReaderMultiBox.test.tsx b/front/src/views/QrReader/QrReaderMultiBox.test.tsx index dfdc2196d..ecc3e4f79 100644 --- a/front/src/views/QrReader/QrReaderMultiBox.test.tsx +++ b/front/src/views/QrReader/QrReaderMultiBox.test.tsx @@ -10,7 +10,6 @@ import { GET_BOX_LABEL_IDENTIFIER_BY_QR_CODE, MULTI_BOX_ACTION_OPTIONS_FOR_LOCATIONS_TAGS_AND_SHIPMENTS_QUERY, } from "queries/queries"; -import { BoxState } from "types/generated/graphql"; import { cache } from "queries/cache"; import { locations } from "mocks/locations"; import { mockedCreateToast, mockedTriggerError } from "tests/setupTests"; diff --git a/front/src/views/QrReader/QrReaderMultiBoxAssignTags.test.tsx b/front/src/views/QrReader/QrReaderMultiBoxAssignTags.test.tsx index eea32bea1..57d118856 100644 --- a/front/src/views/QrReader/QrReaderMultiBoxAssignTags.test.tsx +++ b/front/src/views/QrReader/QrReaderMultiBoxAssignTags.test.tsx @@ -10,7 +10,6 @@ import { GET_BOX_LABEL_IDENTIFIER_BY_QR_CODE, MULTI_BOX_ACTION_OPTIONS_FOR_LOCATIONS_TAGS_AND_SHIPMENTS_QUERY, } from "queries/queries"; -import { BoxState, ShipmentState } from "types/generated/graphql"; import { cache } from "queries/cache"; import { generateMockShipmentMinimal } from "mocks/shipments"; import { selectOptionInSelectField } from "tests/helpers"; diff --git a/front/src/views/QrReader/QrReaderMultiBoxAssignToShipment.test.tsx b/front/src/views/QrReader/QrReaderMultiBoxAssignToShipment.test.tsx index c930a0399..bdfff115c 100644 --- a/front/src/views/QrReader/QrReaderMultiBoxAssignToShipment.test.tsx +++ b/front/src/views/QrReader/QrReaderMultiBoxAssignToShipment.test.tsx @@ -10,7 +10,6 @@ import { GET_BOX_LABEL_IDENTIFIER_BY_QR_CODE, MULTI_BOX_ACTION_OPTIONS_FOR_LOCATIONS_TAGS_AND_SHIPMENTS_QUERY, } from "queries/queries"; -import { BoxState, ShipmentState } from "types/generated/graphql"; import { cache } from "queries/cache"; import { generateMockShipment, generateMockShipmentMinimal } from "mocks/shipments"; import { ASSIGN_BOXES_TO_SHIPMENT } from "hooks/useAssignBoxesToShipment"; diff --git a/front/src/views/QrReader/QrReaderMultiBoxMoveBox.test.tsx b/front/src/views/QrReader/QrReaderMultiBoxMoveBox.test.tsx index 844af22b0..dcc2b8506 100644 --- a/front/src/views/QrReader/QrReaderMultiBoxMoveBox.test.tsx +++ b/front/src/views/QrReader/QrReaderMultiBoxMoveBox.test.tsx @@ -10,7 +10,6 @@ import { GET_BOX_LABEL_IDENTIFIER_BY_QR_CODE, MULTI_BOX_ACTION_OPTIONS_FOR_LOCATIONS_TAGS_AND_SHIPMENTS_QUERY, } from "queries/queries"; -import { BoxState, ShipmentState } from "types/generated/graphql"; import { cache } from "queries/cache"; import { generateMockShipmentMinimal } from "mocks/shipments"; import { selectOptionInSelectField } from "tests/helpers"; diff --git a/front/src/views/QrReader/components/ResolveHash.test.tsx b/front/src/views/QrReader/components/ResolveHash.test.tsx index f7fbca904..5cd12efb6 100644 --- a/front/src/views/QrReader/components/ResolveHash.test.tsx +++ b/front/src/views/QrReader/components/ResolveHash.test.tsx @@ -6,7 +6,6 @@ import { mockImplementationOfQrReader } from "mocks/components"; import { mockAuthenticatedUser } from "mocks/hooks"; import { cache } from "queries/cache"; import { GET_BOX_LABEL_IDENTIFIER_BY_QR_CODE } from "queries/queries"; -import { BoxState } from "types/generated/graphql"; import { render, screen, waitFor } from "tests/test-utils"; import { mockedTriggerError } from "tests/setupTests"; import ResolveHash from "./ResolveHash"; diff --git a/front/src/views/Transfers/CreateShipment/CreateShipmentView.test.tsx b/front/src/views/Transfers/CreateShipment/CreateShipmentView.test.tsx index a2105f982..e5d85beae 100644 --- a/front/src/views/Transfers/CreateShipment/CreateShipmentView.test.tsx +++ b/front/src/views/Transfers/CreateShipment/CreateShipmentView.test.tsx @@ -5,7 +5,6 @@ import { acceptedTransferAgreement } from "mocks/transferAgreements"; import { userEvent } from "@testing-library/user-event"; import { assertOptionsInSelectField, selectOptionInSelectField } from "tests/helpers"; import { base1, base2 } from "mocks/bases"; -import { ShipmentState } from "types/generated/graphql"; import { generateMockShipment } from "mocks/shipments"; import { cache } from "queries/cache"; import { graphql } from "gql.tada"; diff --git a/front/src/views/Transfers/CreateShipment/CreateShipmentView.tsx b/front/src/views/Transfers/CreateShipment/CreateShipmentView.tsx index 76c9cf3f9..d8f7d8839 100644 --- a/front/src/views/Transfers/CreateShipment/CreateShipmentView.tsx +++ b/front/src/views/Transfers/CreateShipment/CreateShipmentView.tsx @@ -81,40 +81,37 @@ function CreateShipmentView() { const { baseId } = useBaseIdParam(); // Query Data for the Form - const allAcceptedTransferAgreements = useQuery( - ALL_ACCEPTED_TRANSFER_AGREEMENTS_QUERY, - { - variables: { - baseId, - }, + const allAcceptedTransferAgreements = useQuery(ALL_ACCEPTED_TRANSFER_AGREEMENTS_QUERY, { + variables: { + baseId, }, - ); + }); // Mutation after form submission - const [createShipmentMutation, createShipmentMutationState] = useMutation< - CreateShipmentMutation, - CreateShipmentMutationVariables - >(CREATE_SHIPMENT_MUTATION, { - update(cache, { data: returnedShipment }) { - if (returnedShipment?.createShipment) { - cache.modify({ - fields: { - shipments(existingShipments = []) { - const newShipmentRef = cache.writeFragment({ - data: returnedShipment.createShipment, - fragment: graphql(` - fragment NewShipment on Shipment { - id - } - `), - }); - return existingShipments.concat(newShipmentRef); + const [createShipmentMutation, createShipmentMutationState] = useMutation( + CREATE_SHIPMENT_MUTATION, + { + update(cache, { data: returnedShipment }) { + if (returnedShipment?.createShipment) { + cache.modify({ + fields: { + shipments(existingShipments = []) { + const newShipmentRef = cache.writeFragment({ + data: returnedShipment.createShipment, + fragment: graphql(` + fragment NewShipment on Shipment { + id + } + `), + }); + return existingShipments.concat(newShipmentRef); + }, }, - }, - }); - } + }); + } + }, }, - }); + ); // Prep data for Form const currentBase = allAcceptedTransferAgreements?.data?.base; @@ -129,9 +126,9 @@ function CreateShipmentView() { error: allBasesOfCurrentOrgError, data: AllBasesOfCurrentOrg, }, - ] = useLazyQuery(ALL_BASES_OF_CURRENT_ORG_QUERY, { + ] = useLazyQuery(ALL_BASES_OF_CURRENT_ORG_QUERY, { variables: { - orgId: currentOrganisationId, + orgId: currentOrganisationId || "0", }, }); @@ -148,13 +145,13 @@ function CreateShipmentView() { (agreement) => agreement.sourceOrganisation.id === currentOrganisationId || (agreement.targetOrganisation.id === currentOrganisationId && - agreement.type === TransferAgreementType.Bidirectional), + agreement.type === "Bidirectional"), ) .map((agreement) => { // transform the agreement data to organisation base data if ( agreement.targetOrganisation.id === currentOrganisationId && - agreement.type === TransferAgreementType.Bidirectional + agreement.type === "Bidirectional" ) { return { id: agreement.sourceOrganisation.id, diff --git a/front/src/views/Transfers/CreateTransferAgreement/CreateTransferAgreementView.test.tsx b/front/src/views/Transfers/CreateTransferAgreement/CreateTransferAgreementView.test.tsx index 83acc2f92..3378df10c 100644 --- a/front/src/views/Transfers/CreateTransferAgreement/CreateTransferAgreementView.test.tsx +++ b/front/src/views/Transfers/CreateTransferAgreement/CreateTransferAgreementView.test.tsx @@ -3,7 +3,6 @@ import { screen, render, cleanup, fireEvent, waitFor } from "tests/test-utils"; import { userEvent } from "@testing-library/user-event"; import { organisation1, organisations } from "mocks/organisations"; import { assertOptionsInSelectField, selectOptionInSelectField } from "tests/helpers"; -import { TransferAgreementType } from "types/generated/graphql"; import { addDays } from "date-fns"; import { base1 } from "mocks/bases"; import { mockedCreateToast, mockedTriggerError } from "tests/setupTests"; diff --git a/front/src/views/Transfers/CreateTransferAgreement/CreateTransferAgreementView.tsx b/front/src/views/Transfers/CreateTransferAgreement/CreateTransferAgreementView.tsx index 2641c4a28..f74a4ec64 100644 --- a/front/src/views/Transfers/CreateTransferAgreement/CreateTransferAgreementView.tsx +++ b/front/src/views/Transfers/CreateTransferAgreement/CreateTransferAgreementView.tsx @@ -7,12 +7,6 @@ import { useNotification } from "hooks/useNotification"; import APILoadingIndicator from "components/APILoadingIndicator"; import { useNavigate } from "react-router-dom"; import { TRANSFER_AGREEMENT_FIELDS_FRAGMENT } from "queries/fragments"; -import { - AllOrganisationsAndBasesQuery, - CreateTransferAgreementMutation, - CreateTransferAgreementMutationVariables, - TransferAgreementType, -} from "types/generated/graphql"; import { GlobalPreferencesContext } from "providers/GlobalPreferencesProvider"; import { MobileBreadcrumbButton } from "components/BreadcrumbNavigation"; import CreateTransferAgreement, { diff --git a/front/src/views/Transfers/ShipmentView/ShipmentView.test.tsx b/front/src/views/Transfers/ShipmentView/ShipmentView.test.tsx index 80308980d..5b1e68ff7 100644 --- a/front/src/views/Transfers/ShipmentView/ShipmentView.test.tsx +++ b/front/src/views/Transfers/ShipmentView/ShipmentView.test.tsx @@ -3,7 +3,6 @@ import { screen, render, waitFor } from "tests/test-utils"; import { organisation1 } from "mocks/organisations"; import { generateMockShipment, generateMockShipmentWithCustomDetails } from "mocks/shipments"; import { generateMockBox } from "mocks/boxes"; -import { BoxState, ShipmentState } from "types/generated/graphql"; import { userEvent } from "@testing-library/user-event"; import { FakeGraphQLError, mockMatchMediaQuery } from "mocks/functions"; import { generateMockShipmentDetail } from "mocks/shipmentDetail"; diff --git a/front/src/views/Transfers/ShipmentView/ShipmentView.tsx b/front/src/views/Transfers/ShipmentView/ShipmentView.tsx index 707604c75..3f0ffda99 100644 --- a/front/src/views/Transfers/ShipmentView/ShipmentView.tsx +++ b/front/src/views/Transfers/ShipmentView/ShipmentView.tsx @@ -16,27 +16,6 @@ import { import _ from "lodash"; import { useCallback, useContext, useEffect, useState } from "react"; import { useParams } from "react-router-dom"; -import { - CancelShipmentMutation, - CancelShipmentMutationVariables, - LostShipmentMutation, - LostShipmentMutationVariables, - SendShipmentMutation, - SendShipmentMutationVariables, - Shipment, - ShipmentByIdQuery, - ShipmentByIdQueryVariables, - ShipmentDetail, - ShipmentState, - StartReceivingShipmentMutation, - StartReceivingShipmentMutationVariables, - RemoveBoxFromShipmentMutation, - RemoveBoxFromShipmentMutationVariables, - UpdateShipmentWhenReceivingMutation, - UpdateShipmentWhenReceivingMutationVariables, - BoxState, - User, -} from "types/generated/graphql"; import { useErrorHandling } from "hooks/useErrorHandling"; import { useNotification } from "hooks/useNotification"; import { SHIPMENT_FIELDS_FRAGMENT } from "queries/fragments"; @@ -54,6 +33,7 @@ import ShipmentActionButtons from "./components/ShipmentActionButtons"; import ShipmentReceivingContent from "./components/ShipmentReceivingContent"; import ShipmentReceivingCard from "./components/ShipmentReceivingCard"; import { useLoadAndSetGlobalPreferences } from "hooks/useLoadAndSetGlobalPreferences"; +import { ShipmentDetail, ShipmentState, User } from "types/query-types"; enum ShipmentActionEvent { ShipmentStarted = "Shipment Started", @@ -158,16 +138,13 @@ function ShipmentView() { const shipmentId = useParams<{ id: string }>().id!; // fetch shipment data - const { loading, error, data } = useQuery( - SHIPMENT_BY_ID_QUERY, - { - variables: { - id: shipmentId, - }, - // returns cache first, but syncs with server in background - fetchPolicy: "cache-and-network", + const { loading, error, data } = useQuery(SHIPMENT_BY_ID_QUERY, { + variables: { + id: shipmentId, }, - ); + // returns cache first, but syncs with server in background + fetchPolicy: "cache-and-network", + }); useEffect(() => { setShipmentState(data?.shipment?.state || undefined); @@ -177,34 +154,17 @@ function ShipmentView() { }, [data]); // Mutations for shipment actions - const [updateShipmentWhenPreparing, updateShipmentWhenPreparingStatus] = useMutation< - RemoveBoxFromShipmentMutation, - RemoveBoxFromShipmentMutationVariables - >(REMOVE_BOX_FROM_SHIPMENT); - - const [cancelShipment, cancelShipmentStatus] = useMutation< - CancelShipmentMutation, - CancelShipmentMutationVariables - >(CANCEL_SHIPMENT); - - const [lostShipment, lostShipmentStatus] = useMutation< - LostShipmentMutation, - LostShipmentMutationVariables - >(LOST_SHIPMENT); - - const [sendShipment, sendShipmentStatus] = useMutation< - SendShipmentMutation, - SendShipmentMutationVariables - >(SEND_SHIPMENT); - - const [startReceivingShipment, startReceivingShipmentStatus] = useMutation< - StartReceivingShipmentMutation, - StartReceivingShipmentMutationVariables - >(START_RECEIVING_SHIPMENT); - const [updateShipmentWhenReceiving, updateShipmentWhenReceivingStatus] = useMutation< - UpdateShipmentWhenReceivingMutation, - UpdateShipmentWhenReceivingMutationVariables - >(UPDATE_SHIPMENT_WHEN_RECEIVING); + const [updateShipmentWhenPreparing, updateShipmentWhenPreparingStatus] = + useMutation(REMOVE_BOX_FROM_SHIPMENT); + + const [cancelShipment, cancelShipmentStatus] = useMutation(CANCEL_SHIPMENT); + const [lostShipment, lostShipmentStatus] = useMutation(LOST_SHIPMENT); + const [sendShipment, sendShipmentStatus] = useMutation(SEND_SHIPMENT); + const [startReceivingShipment, startReceivingShipmentStatus] = + useMutation(START_RECEIVING_SHIPMENT); + const [updateShipmentWhenReceiving, updateShipmentWhenReceivingStatus] = useMutation( + UPDATE_SHIPMENT_WHEN_RECEIVING, + ); // shipment actions in the modal const handleShipment = useCallback( @@ -276,7 +236,7 @@ function ShipmentView() { const onRemainingBoxesUndelivered = useCallback(() => { const lostBoxLabelIdentifiers = data?.shipment?.details - .filter((shipmentDetail) => shipmentDetail.box.state === BoxState.Receiving) + .filter((shipmentDetail) => shipmentDetail.box.state === "Receiving") .map((shipmentDetail) => shipmentDetail.box.labelIdentifier) as string[]; updateShipmentWhenReceiving({ @@ -383,7 +343,7 @@ function ShipmentView() { lostShipmentStatus.loading; // transform shipment data for UI - const shipmentData = data?.shipment! as Shipment; + const shipmentData = data?.shipment!; const shipmentContents = (data?.shipment?.details.filter((item) => item.removedOn === null) ?? []) as ShipmentDetail[]; @@ -412,7 +372,7 @@ function ShipmentView() { }; const generateShipmentHistory = ( - entry: Partial>, + entry: Partial }>>, ): ITimelineEntry[] => { const shipmentHistory: ITimelineEntry[] = []; @@ -432,23 +392,23 @@ function ShipmentView() { const shipmentLogs: ITimelineEntry[] = generateShipmentHistory({ [ShipmentActionEvent.ShipmentStarted]: { createdOn: shipmentData?.startedOn, - createdBy: shipmentData?.startedBy! as User, + createdBy: shipmentData?.startedBy!, }, [ShipmentActionEvent.ShipmentCanceled]: { - createdOn: shipmentData?.canceledOn, - createdBy: shipmentData?.canceledBy! as User, + createdOn: shipmentData?.canceledOn || "", + createdBy: shipmentData?.canceledBy!, }, [ShipmentActionEvent.ShipmentSent]: { - createdOn: shipmentData?.sentOn, - createdBy: shipmentData?.sentBy! as User, + createdOn: shipmentData?.sentOn || "", + createdBy: shipmentData?.sentBy!, }, [ShipmentActionEvent.ShipmentStartReceiving]: { - createdOn: shipmentData?.receivingStartedOn, - createdBy: shipmentData?.receivingStartedBy! as User, + createdOn: shipmentData?.receivingStartedOn || "", + createdBy: shipmentData?.receivingStartedBy!, }, [ShipmentActionEvent.ShipmentCompleted]: { - createdOn: shipmentData?.completedOn, - createdBy: shipmentData?.completedBy! as User, + createdOn: shipmentData?.completedOn || "", + createdBy: shipmentData?.completedBy!, }, }); @@ -530,19 +490,19 @@ function ShipmentView() { (b) => b.id === data?.shipment?.sourceBase?.id, ) !== "undefined"; - if (ShipmentState.Preparing === shipmentState && isSender) { + if ("Preparing" === shipmentState && isSender) { canUpdateShipment = true; canCancelShipment = true; shipmentTitle = Prepare Shipment; - } else if (ShipmentState.Sent === shipmentState && isSender) { + } else if ("Sent" === shipmentState && isSender) { canLooseShipment = true; - } else if (ShipmentState.Sent === shipmentState && !isSender) { + } else if ("Sent" === shipmentState && !isSender) { canLooseShipment = true; - } else if (ShipmentState.Receiving === shipmentState && !isSender) { + } else if ("Receiving" === shipmentState && !isSender) { canLooseShipment = true; shipmentTitle = Receiving Shipment; - } else if (ShipmentState.Preparing === shipmentState && !isSender) { + } else if ("Preparing" === shipmentState && !isSender) { canCancelShipment = true; } @@ -581,19 +541,19 @@ function ShipmentView() { onRemove={onMinusClick} onCancel={openShipmentOverlay} onLost={openShipmentOverlay} - shipment={data?.shipment! as Shipment} + shipment={data?.shipment!} /> ); } let shipmentViewComponents; - if (shipmentState === ShipmentState.Receiving && !isSender) { + if (shipmentState === "Receiving" && !isSender) { shipmentViewComponents = ( <> Receiving Shipment - + @@ -217,7 +217,7 @@ function ShipmentCard({ /> )} - {shipment.state === ShipmentState.Completed && totalLostBoxes > 0 && ( + {shipment.state === "Completed" && totalLostBoxes > 0 && ( diff --git a/front/src/views/Transfers/ShipmentView/components/ShipmentColoredStatus.tsx b/front/src/views/Transfers/ShipmentView/components/ShipmentColoredStatus.tsx index 264ade28e..00afd7dbe 100644 --- a/front/src/views/Transfers/ShipmentView/components/ShipmentColoredStatus.tsx +++ b/front/src/views/Transfers/ShipmentView/components/ShipmentColoredStatus.tsx @@ -1,5 +1,4 @@ import { Box, Wrap, WrapItem } from "@chakra-ui/react"; -import { ShipmentState } from "types/generated/graphql"; export interface IShipmentColoredStatusProps { state: ShipmentState | undefined | null; diff --git a/front/src/views/Transfers/ShipmentView/components/ShipmentContent.tsx b/front/src/views/Transfers/ShipmentView/components/ShipmentContent.tsx index f52ba31bd..aa9a7b3a5 100644 --- a/front/src/views/Transfers/ShipmentView/components/ShipmentContent.tsx +++ b/front/src/views/Transfers/ShipmentView/components/ShipmentContent.tsx @@ -12,7 +12,6 @@ import { } from "@chakra-ui/react"; import _ from "lodash"; import { useCallback, useMemo } from "react"; -import { Product, Box as BoxType, BoxState, ShipmentState } from "types/generated/graphql"; import { CellProps } from "react-table"; import { AiFillMinusCircle } from "react-icons/ai"; import ShipmentTable from "./ShipmentTable"; diff --git a/front/src/views/Transfers/ShipmentView/components/ShipmentOverlay.tsx b/front/src/views/Transfers/ShipmentView/components/ShipmentOverlay.tsx index 2e8f0bac6..66d4ed8ec 100644 --- a/front/src/views/Transfers/ShipmentView/components/ShipmentOverlay.tsx +++ b/front/src/views/Transfers/ShipmentView/components/ShipmentOverlay.tsx @@ -1,7 +1,6 @@ import { VStack, Text, chakra, HStack, Wrap } from "@chakra-ui/react"; import { AreYouSureDialog } from "components/AreYouSure"; import { AiFillWarning } from "react-icons/ai"; -import { BoxState, ShipmentState } from "types/generated/graphql"; export interface IShipmentOverlayData { id: string; diff --git a/front/src/views/Transfers/ShipmentView/components/ShipmentReceivingCard.tsx b/front/src/views/Transfers/ShipmentView/components/ShipmentReceivingCard.tsx index a7450b799..01736f6fe 100644 --- a/front/src/views/Transfers/ShipmentView/components/ShipmentReceivingCard.tsx +++ b/front/src/views/Transfers/ShipmentView/components/ShipmentReceivingCard.tsx @@ -1,6 +1,5 @@ import { Flex, Box, Spacer, Heading, Wrap, WrapItem, VStack, Center } from "@chakra-ui/react"; import { BoxIcon } from "components/Icon/Transfer/BoxIcon"; -import { Shipment } from "types/generated/graphql"; export interface IShipmentReceivingCardProps { shipment: Shipment; diff --git a/front/src/views/Transfers/ShipmentView/components/ShipmentReceivingContent.tsx b/front/src/views/Transfers/ShipmentView/components/ShipmentReceivingContent.tsx index b1902aa68..96839217b 100644 --- a/front/src/views/Transfers/ShipmentView/components/ShipmentReceivingContent.tsx +++ b/front/src/views/Transfers/ShipmentView/components/ShipmentReceivingContent.tsx @@ -1,6 +1,5 @@ import _ from "lodash"; import { useMemo } from "react"; -import { BoxState, ShipmentDetail } from "types/generated/graphql"; import ShipmentReceivingTable from "./ShipmentReceivingTable"; interface IShipmentReceivingContentProps { diff --git a/front/src/views/Transfers/ShipmentView/components/ShipmentTabs.tsx b/front/src/views/Transfers/ShipmentView/components/ShipmentTabs.tsx index b4d78b96f..2b53ffead 100644 --- a/front/src/views/Transfers/ShipmentView/components/ShipmentTabs.tsx +++ b/front/src/views/Transfers/ShipmentView/components/ShipmentTabs.tsx @@ -1,7 +1,6 @@ import { TabList, TabPanels, Tabs, TabPanel, Tab, Center } from "@chakra-ui/react"; import ShipmentHistory, { IGroupedRecordEntry } from "components/Timeline/Timeline"; import _ from "lodash"; -import { Box, ShipmentDetail, ShipmentState, User } from "types/generated/graphql"; import ShipmentContent, { IShipmentContent } from "./ShipmentContent"; export enum ShipmentActionEvent { diff --git a/front/src/views/Transfers/ShipmentsOverview/ShipmentsOverview.test.tsx b/front/src/views/Transfers/ShipmentsOverview/ShipmentsOverview.test.tsx index 6c1a6d82f..8c0a6acae 100644 --- a/front/src/views/Transfers/ShipmentsOverview/ShipmentsOverview.test.tsx +++ b/front/src/views/Transfers/ShipmentsOverview/ShipmentsOverview.test.tsx @@ -2,7 +2,6 @@ import { it, expect } from "vitest"; import { screen, render } from "tests/test-utils"; import { mockGraphQLError, mockNetworkError } from "mocks/functions"; import { generateMockShipment } from "mocks/shipments"; -import { ShipmentState } from "types/generated/graphql"; import { ALL_SHIPMENTS_QUERY } from "queries/queries"; import ShipmentsOverviewView from "./ShipmentsOverviewView"; diff --git a/front/src/views/Transfers/ShipmentsOverview/ShipmentsOverviewView.tsx b/front/src/views/Transfers/ShipmentsOverview/ShipmentsOverviewView.tsx index 5068ccd92..bd20fa3c8 100644 --- a/front/src/views/Transfers/ShipmentsOverview/ShipmentsOverviewView.tsx +++ b/front/src/views/Transfers/ShipmentsOverview/ShipmentsOverviewView.tsx @@ -4,7 +4,6 @@ import { Alert, AlertIcon, Button, Heading, Stack } from "@chakra-ui/react"; import { Link, useLocation } from "react-router-dom"; import { GlobalPreferencesContext } from "providers/GlobalPreferencesProvider"; import { ALL_SHIPMENTS_QUERY } from "queries/queries"; -import { ShipmentsQuery } from "types/generated/graphql"; import { AddIcon } from "@chakra-ui/icons"; import { TableSkeleton } from "components/Skeletons"; import { FilteringSortingTable } from "components/Table/Table"; diff --git a/front/src/views/Transfers/ShipmentsOverview/components/TableCells.tsx b/front/src/views/Transfers/ShipmentsOverview/components/TableCells.tsx index db5481605..86d7a48e3 100644 --- a/front/src/views/Transfers/ShipmentsOverview/components/TableCells.tsx +++ b/front/src/views/Transfers/ShipmentsOverview/components/TableCells.tsx @@ -3,7 +3,6 @@ import { BidirectionalIcon } from "components/Icon/Transfer/BidirectionalIcon"; import { ReceivingIcon } from "components/Icon/Transfer/ReceivingIcon"; import { SendingIcon } from "components/Icon/Transfer/SendingIcon"; import { CellProps } from "react-table"; -import { ShipmentState } from "types/generated/graphql"; export function DirectionCell({ value }: CellProps) { if (value === "To") { diff --git a/front/src/views/Transfers/TransferAgreementOverview/TransferAgreementOverview.test.tsx b/front/src/views/Transfers/TransferAgreementOverview/TransferAgreementOverview.test.tsx index 5397d2e73..7778e68b1 100644 --- a/front/src/views/Transfers/TransferAgreementOverview/TransferAgreementOverview.test.tsx +++ b/front/src/views/Transfers/TransferAgreementOverview/TransferAgreementOverview.test.tsx @@ -3,7 +3,6 @@ import { userEvent } from "@testing-library/user-event"; import { screen, render, waitFor } from "tests/test-utils"; import { generateMockTransferAgreement } from "mocks/transferAgreements"; import { mockGraphQLError, mockNetworkError } from "mocks/functions"; -import { TransferAgreementState, TransferAgreementType } from "types/generated/graphql"; import { mockedCreateToast, mockedTriggerError } from "tests/setupTests"; import TransferAgreementOverviewView, { ACCEPT_TRANSFER_AGREEMENT, diff --git a/front/src/views/Transfers/TransferAgreementOverview/TransferAgreementOverviewView.tsx b/front/src/views/Transfers/TransferAgreementOverview/TransferAgreementOverviewView.tsx index 1168650da..d5897b721 100644 --- a/front/src/views/Transfers/TransferAgreementOverview/TransferAgreementOverviewView.tsx +++ b/front/src/views/Transfers/TransferAgreementOverview/TransferAgreementOverviewView.tsx @@ -24,11 +24,12 @@ import TransferAgreementsOverlay from "./components/TransferAgreementOverlay"; import { ALL_ACCEPTED_TRANSFER_AGREEMENTS_QUERY } from "../CreateShipment/CreateShipmentView"; import { useBaseIdParam } from "hooks/useBaseIdParam"; import { useLoadAndSetGlobalPreferences } from "hooks/useLoadAndSetGlobalPreferences"; -import { introspection_types } from "../../../../../generated/graphql-env"; +import { TransferAgreements } from "types/query-types"; export interface IAcceptedTransferAgreement { - transferAgreements: introspection_types["TransferAgreement"][]; + transferAgreements: TransferAgreements; } + export const ALL_TRANSFER_AGREEMENTS_QUERY = graphql( ` query TransferAgreements { diff --git a/front/src/views/Transfers/TransferAgreementOverview/components/TableCells.tsx b/front/src/views/Transfers/TransferAgreementOverview/components/TableCells.tsx index 535d6f450..786258ed2 100644 --- a/front/src/views/Transfers/TransferAgreementOverview/components/TableCells.tsx +++ b/front/src/views/Transfers/TransferAgreementOverview/components/TableCells.tsx @@ -4,7 +4,6 @@ import { ReceivingIcon } from "components/Icon/Transfer/ReceivingIcon"; import { SendingIcon } from "components/Icon/Transfer/SendingIcon"; import { Link as RouterLink } from "react-router-dom"; import { CellProps } from "react-table"; -import { TransferAgreementState } from "types/generated/graphql"; export enum CanAcceptTransferAgreementState { CanAccept = "CanAccept", diff --git a/front/src/views/Transfers/TransferAgreementOverview/components/TransferAgreementOverlay.tsx b/front/src/views/Transfers/TransferAgreementOverview/components/TransferAgreementOverlay.tsx index 96488e64d..65c1cfea1 100644 --- a/front/src/views/Transfers/TransferAgreementOverview/components/TransferAgreementOverlay.tsx +++ b/front/src/views/Transfers/TransferAgreementOverview/components/TransferAgreementOverlay.tsx @@ -1,7 +1,6 @@ import { CheckIcon, RepeatIcon, SmallCloseIcon } from "@chakra-ui/icons"; import { VStack, Text, chakra } from "@chakra-ui/react"; import { useNavigate } from "react-router-dom"; -import { TransferAgreementState } from "types/generated/graphql"; import { AreYouSureDialog } from "components/AreYouSure"; import { CanAcceptTransferAgreementState } from "./TableCells"; diff --git a/shared-components/statviz/components/filter/GenderProductFilter.tsx b/shared-components/statviz/components/filter/GenderProductFilter.tsx index 678244be9..fd68b3ff2 100644 --- a/shared-components/statviz/components/filter/GenderProductFilter.tsx +++ b/shared-components/statviz/components/filter/GenderProductFilter.tsx @@ -2,7 +2,6 @@ import { useReactiveVar } from "@apollo/client"; import { Wrap, WrapItem } from "@chakra-ui/react"; import MultiSelectFilter from "./MultiSelectFilter"; import { IFilterValue } from "./ValueFilter"; -import { ProductDimensionInfo, ProductGender } from "../../../types/generated/graphql"; import useMultiSelectFilter from "../../hooks/useMultiSelectFilter"; import { IProductFilterValue, productFilterValuesVar } from "../../state/filter"; diff --git a/shared-components/statviz/components/filter/LocationFilter.tsx b/shared-components/statviz/components/filter/LocationFilter.tsx index 575fd5ec9..672e927f2 100644 --- a/shared-components/statviz/components/filter/LocationFilter.tsx +++ b/shared-components/statviz/components/filter/LocationFilter.tsx @@ -2,7 +2,6 @@ import { useReactiveVar } from "@apollo/client"; import useMultiSelectFilter from "../../hooks/useMultiSelectFilter"; import { ITargetFilterValue, targetFilterValuesVar } from "../../state/filter"; import MultiSelectFilter from "./MultiSelectFilter"; -import { TargetDimensionInfo } from "../../../types/generated/graphql"; export const targetFilterId = "loc"; diff --git a/shared-components/statviz/components/filter/TagFilter.tsx b/shared-components/statviz/components/filter/TagFilter.tsx index 447d66dd7..4ef5efcba 100644 --- a/shared-components/statviz/components/filter/TagFilter.tsx +++ b/shared-components/statviz/components/filter/TagFilter.tsx @@ -1,7 +1,6 @@ import { Box } from "@chakra-ui/react"; import { useReactiveVar } from "@apollo/client"; import MultiSelectFilter from "./MultiSelectFilter"; -import { TagDimensionInfo } from "../../../types/generated/graphql"; import useMultiSelectFilter from "../../hooks/useMultiSelectFilter"; import { ITagFilterValue, tagFilterValuesVar } from "../../state/filter"; diff --git a/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxes.tsx b/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxes.tsx index 24b2a6c99..434c5a6c7 100644 --- a/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxes.tsx +++ b/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxes.tsx @@ -16,7 +16,6 @@ import { BoxesOrItemsCount } from "../../../dashboard/ItemsAndBoxes"; import VisHeader from "../../VisHeader"; import NoDataCard from "../../NoDataCard"; import getOnExport from "../../../utils/chartExport"; -import { CreatedBoxesData, CreatedBoxesResult } from "../../../../types/generated/graphql"; import CreatedBoxesGrouping, { createdBoxesGroupingOptions, createdBoxesUrlId, diff --git a/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesCharts.tsx b/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesCharts.tsx index 7ade1d644..566e404f3 100644 --- a/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesCharts.tsx +++ b/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesCharts.tsx @@ -1,5 +1,4 @@ import { Wrap, WrapItem, Box } from "@chakra-ui/react"; -import { CreatedBoxesData } from "../../../../types/generated/graphql"; import CreatedBoxes from "./CreatedBoxes"; import TopCreatedProducts from "./TopCreatedProducts"; import { BoxesOrItems } from "../../filter/BoxesOrItemsSelect"; diff --git a/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesDataContainer.tsx b/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesDataContainer.tsx index 8d4c74996..1e14f41a9 100644 --- a/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesDataContainer.tsx +++ b/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesDataContainer.tsx @@ -3,9 +3,9 @@ import { useQuery } from "@apollo/client"; import { useParams } from "react-router-dom"; import ErrorCard, { predefinedErrors } from "../../ErrorCard"; import CreatedBoxesFilterContainer from "./CreatedBoxesFilterContainer"; -import { gql } from "../../../../types/generated"; +import { graphql } from "../../../../../graphql"; -const CREATED_BOXES_QUERY = gql(` +const CREATED_BOXES_QUERY = graphql(` query createdBoxes($baseId: Int!) { createdBoxes(baseId: $baseId) { facts { diff --git a/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesFilterContainer.tsx b/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesFilterContainer.tsx index 527752290..c0ef15eba 100644 --- a/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesFilterContainer.tsx +++ b/shared-components/statviz/components/visualizations/createdBoxes/CreatedBoxesFilterContainer.tsx @@ -1,7 +1,6 @@ import { useEffect, useMemo } from "react"; import { TidyFn, distinct, filter, tidy } from "@tidyjs/tidy"; import { useReactiveVar } from "@apollo/client"; -import { CreatedBoxesData, CreatedBoxesResult } from "../../../../types/generated/graphql"; import CreatedBoxesCharts from "./CreatedBoxesCharts"; import { filterListByInterval } from "../../../../utils/helpers"; import useTimerange from "../../../hooks/useTimerange"; diff --git a/shared-components/statviz/components/visualizations/createdBoxes/TopCreatedProducts.tsx b/shared-components/statviz/components/visualizations/createdBoxes/TopCreatedProducts.tsx index 6c61fcc71..4862f94f4 100644 --- a/shared-components/statviz/components/visualizations/createdBoxes/TopCreatedProducts.tsx +++ b/shared-components/statviz/components/visualizations/createdBoxes/TopCreatedProducts.tsx @@ -2,11 +2,6 @@ import { Card, CardBody } from "@chakra-ui/react"; import { useMemo } from "react"; import { arrange, desc, groupBy, innerJoin, map, sum, summarize, tidy } from "@tidyjs/tidy"; import BarChart from "../../nivo/BarChart"; -import { - CreatedBoxesData, - CreatedBoxesResult, - ProductDimensionInfo, -} from "../../../../types/generated/graphql"; import VisHeader from "../../VisHeader"; import getOnExport from "../../../utils/chartExport"; import NoDataCard from "../../NoDataCard"; diff --git a/shared-components/statviz/components/visualizations/demographic/DemographicCharts.tsx b/shared-components/statviz/components/visualizations/demographic/DemographicCharts.tsx index 550a61c0b..5d0b1ae97 100644 --- a/shared-components/statviz/components/visualizations/demographic/DemographicCharts.tsx +++ b/shared-components/statviz/components/visualizations/demographic/DemographicCharts.tsx @@ -1,4 +1,3 @@ -import { BeneficiaryDemographicsData } from "../../../../types/generated/graphql"; import DemographicPyramid from "./DemographicPyramid"; interface IDemographicChartProps { diff --git a/shared-components/statviz/components/visualizations/demographic/DemographicFilterContainer.tsx b/shared-components/statviz/components/visualizations/demographic/DemographicFilterContainer.tsx index d694af25c..6cc6b40df 100644 --- a/shared-components/statviz/components/visualizations/demographic/DemographicFilterContainer.tsx +++ b/shared-components/statviz/components/visualizations/demographic/DemographicFilterContainer.tsx @@ -1,10 +1,6 @@ import { useReactiveVar } from "@apollo/client"; import { useEffect, useMemo } from "react"; import { TidyFn, distinct, filter, tidy } from "@tidyjs/tidy"; -import { - BeneficiaryDemographicsData, - BeneficiaryDemographicsResult, -} from "../../../../types/generated/graphql"; import DemographicCharts from "./DemographicCharts"; import { tagFilterId, tagToFilterValue } from "../../filter/TagFilter"; import useMultiSelectFilter from "../../../hooks/useMultiSelectFilter"; diff --git a/shared-components/statviz/components/visualizations/demographic/DemographicPyramid.tsx b/shared-components/statviz/components/visualizations/demographic/DemographicPyramid.tsx index df562959d..e08c5c81c 100644 --- a/shared-components/statviz/components/visualizations/demographic/DemographicPyramid.tsx +++ b/shared-components/statviz/components/visualizations/demographic/DemographicPyramid.tsx @@ -3,11 +3,6 @@ import { range } from "lodash"; import { filter, sum, summarize, tidy, groupBy, map } from "@tidyjs/tidy"; import { useMemo } from "react"; import BarChartCenterAxis from "../../custom-graphs/BarChartCenterAxis"; -import { - BeneficiaryDemographicsData, - BeneficiaryDemographicsResult, - HumanGender, -} from "../../../../types/generated/graphql"; import VisHeader from "../../VisHeader"; import getOnExport from "../../../utils/chartExport"; import NoDataCard from "../../NoDataCard"; diff --git a/shared-components/statviz/components/visualizations/movedBoxes/BoxFlowSankey.tsx b/shared-components/statviz/components/visualizations/movedBoxes/BoxFlowSankey.tsx index 2f5d94995..9961c252a 100644 --- a/shared-components/statviz/components/visualizations/movedBoxes/BoxFlowSankey.tsx +++ b/shared-components/statviz/components/visualizations/movedBoxes/BoxFlowSankey.tsx @@ -4,11 +4,6 @@ import { sample } from "lodash"; import VisHeader from "../../VisHeader"; import SankeyChart, { ISankeyData } from "../../nivo/SankeyChart"; import getOnExport from "../../../utils/chartExport"; -import { - MovedBoxesData, - MovedBoxesResult, - TargetDimensionInfo, -} from "../../../../types/generated/graphql"; import { BoxesOrItemsCount } from "../../../dashboard/ItemsAndBoxes"; import NoDataCard from "../../NoDataCard"; import Targetfilter from "../../filter/LocationFilter"; diff --git a/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesCharts.tsx b/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesCharts.tsx index 3bba7d2a4..fc4173230 100644 --- a/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesCharts.tsx +++ b/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesCharts.tsx @@ -1,6 +1,5 @@ import { Wrap, WrapItem } from "@chakra-ui/react"; import BoxFlowSankey from "./BoxFlowSankey"; -import { MovedBoxesData } from "../../../../types/generated/graphql"; import { BoxesOrItems } from "../../filter/BoxesOrItemsSelect"; interface IMovedBoxesChartsProps { diff --git a/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesDataContainer.tsx b/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesDataContainer.tsx index 4d7e7d258..895aab16b 100644 --- a/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesDataContainer.tsx +++ b/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesDataContainer.tsx @@ -1,12 +1,11 @@ import { useQuery } from "@apollo/client"; import { useParams } from "react-router-dom"; import { Box, Spinner } from "@chakra-ui/react"; -import { gql } from "../../../../types/generated"; -import { MovedBoxesData, QueryMovedBoxesArgs } from "../../../../types/generated/graphql"; import MovedBoxesFilterContainer from "./MovedBoxesFilterContainer"; import ErrorCard, { predefinedErrors } from "../../ErrorCard"; +import { graphql } from "../../../../../graphql"; -export const MOVED_BOXES_QUERY = gql(` +export const MOVED_BOXES_QUERY = graphql(` query movedBoxes($baseId: Int!) { movedBoxes(baseId: $baseId) { facts { diff --git a/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesFilterContainer.tsx b/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesFilterContainer.tsx index 268b61f25..cd936228c 100644 --- a/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesFilterContainer.tsx +++ b/shared-components/statviz/components/visualizations/movedBoxes/MovedBoxesFilterContainer.tsx @@ -2,7 +2,6 @@ import { useEffect, useMemo } from "react"; import { useReactiveVar } from "@apollo/client"; import { TidyFn, filter, tidy } from "@tidyjs/tidy"; import useTimerange from "../../../hooks/useTimerange"; -import { MovedBoxesData, MovedBoxesResult } from "../../../../types/generated/graphql"; import { filterListByInterval } from "../../../../utils/helpers"; import MovedBoxesCharts from "./MovedBoxesCharts"; import useValueFilter from "../../../hooks/useValueFilter"; diff --git a/shared-components/statviz/components/visualizations/stock/StockCharts.tsx b/shared-components/statviz/components/visualizations/stock/StockCharts.tsx index d3bb1578a..4160796c6 100644 --- a/shared-components/statviz/components/visualizations/stock/StockCharts.tsx +++ b/shared-components/statviz/components/visualizations/stock/StockCharts.tsx @@ -1,5 +1,4 @@ import { Wrap, WrapItem } from "@chakra-ui/react"; -import { StockOverviewData } from "../../../../types/generated/graphql"; import StockOverviewPie from "./StockOverviewPie"; import { BoxesOrItemsCount } from "../../../dashboard/ItemsAndBoxes"; diff --git a/shared-components/statviz/components/visualizations/stock/StockDataContainer.tsx b/shared-components/statviz/components/visualizations/stock/StockDataContainer.tsx index 0557bdb91..0d2d3d0d5 100644 --- a/shared-components/statviz/components/visualizations/stock/StockDataContainer.tsx +++ b/shared-components/statviz/components/visualizations/stock/StockDataContainer.tsx @@ -3,42 +3,46 @@ import { Box, Spinner } from "@chakra-ui/react"; import { useParams } from "react-router-dom"; import StockDataFilter from "./StockDataFilter"; import ErrorCard, { predefinedErrors } from "../../ErrorCard"; -import { gql } from "../../../../types/generated"; +import { graphql } from "../../../../../graphql"; +import { TAG_FRAGMENT } from "../../../queries/fragments"; -export const STOCK_QUERY = gql(` - query stockOverview($baseId: Int!) { - stockOverview(baseId: $baseId) { - facts { - productName - categoryId - gender - boxesCount - itemsCount - sizeId - tagIds - boxState - locationId - } - dimensions { - category { - id - name - } - size { - id - name +export const STOCK_QUERY = graphql( + ` + query stockOverview($baseId: Int!) { + stockOverview(baseId: $baseId) { + facts { + productName + categoryId + gender + boxesCount + itemsCount + sizeId + tagIds + boxState + locationId } - tag { - ...TagFragment - } - location { - id - name + dimensions { + category { + id + name + } + size { + id + name + } + tag { + ...TagFragment + } + location { + id + name + } } } } - } -`); + `, + [TAG_FRAGMENT], +); export default function StockDataContainer() { const { baseId } = useParams();