From cdfffe588e1d981677e800fa13cf7e666991e85b Mon Sep 17 00:00:00 2001 From: eman-bfloat Date: Wed, 16 Oct 2024 17:28:18 +0300 Subject: [PATCH 1/9] feat: fix docker builds for client app --- apps/client/next.config.js | 1 + apps/client/package.json | 26 +- apps/client/src/pages/account/index.tsx | 4 +- apps/client/src/pages/checkout/index.tsx | 268 --------------------- apps/client/src/pages/orders/[orderId].tsx | 4 +- apps/client/types.d.ts | 11 + turbo.json | 4 +- 7 files changed, 43 insertions(+), 275 deletions(-) delete mode 100644 apps/client/src/pages/checkout/index.tsx create mode 100644 apps/client/types.d.ts diff --git a/apps/client/next.config.js b/apps/client/next.config.js index 5cba8eae..8582905a 100644 --- a/apps/client/next.config.js +++ b/apps/client/next.config.js @@ -16,6 +16,7 @@ const nextConfig = { }, ], }, + output: "standalone" }; module.exports = nextConfig; diff --git a/apps/client/package.json b/apps/client/package.json index db40ba68..75b5b4b8 100644 --- a/apps/client/package.json +++ b/apps/client/package.json @@ -8,17 +8,41 @@ "start": "next start" }, "dependencies": { + "@apollo/client": "^3.8.1", + "@apollo/react-hooks": "^4.0.0", + "@formkit/auto-animate": "^0.7.0", + "@hookform/resolvers": "^3.3.0", + "@react-google-maps/api": "^2.19.2", "@sahil/configs": "*", "@sahil/features": "*", "@sahil/lib": "*", + "@types/jsonwebtoken": "^9.0.5", + "apollo-link-ws": "^1.0.20", + "autoprefixer": "10.4.15", "daisyui": "^4.12.2", + "date-fns": "^2.30.0", + "eslint": "8.47.0", + "eslint-config-custom": "*", "eslint-config-next": "^14.2.3", + "graphql": "^16.8.0", + "graphql-ws": "^5.14.0", + "jsonwebtoken": "^9.0.2", "next": "^14.2.3", "next-auth": "^4.24.7", "next-auth-hasura-adapter": "^2.0.0", + "postcss": "8.4.28", "react": "^18.3.1", "react-dom": "^18.3.1", - "ui": "*" + "react-hook-form": "^7.45.4", + "react-hot-toast": "^2.4.1", + "react-icons": "^4.12.0", + "subscriptions-transport-ws": "^0.11.0", + "swr": "^2.2.1", + "tailwindcss": "3.3.3", + "tsconfig": "*", + "ui": "*", + "zod": "3.21.4", + "zustand": "^4.4.1" }, "devDependencies": { "@types/node": "^20", diff --git a/apps/client/src/pages/account/index.tsx b/apps/client/src/pages/account/index.tsx index f4384f68..bc629dec 100644 --- a/apps/client/src/pages/account/index.tsx +++ b/apps/client/src/pages/account/index.tsx @@ -1,9 +1,9 @@ import { BusinessProfileOverview, BusinessOrderHistory, -} from "@sahil/features/Businesses"; +} from "@sahil/features/businesses"; // import { useGetAccountBalance, useGetMomoAccountInfo } from "@/hooks/accounts"; -import { useFetchBusinessByPK } from "@/hooks/businesses"; +import { useFetchBusinessByPK } from "@sahil/lib/hooks/businesses"; import { Card, JoinGrid } from "ui"; import { useState } from "react"; import { diff --git a/apps/client/src/pages/checkout/index.tsx b/apps/client/src/pages/checkout/index.tsx deleted file mode 100644 index bcececcf..00000000 --- a/apps/client/src/pages/checkout/index.tsx +++ /dev/null @@ -1,268 +0,0 @@ -import { FC } from "react"; -import { useFetchProducts } from "@sahil/lib/hooks/products"; -import { Card, QuantityInput } from "ui"; -import { formatCost } from "@sahil/lib"; -import { useOrderItemsStore } from "@sahil/lib/hooks/formStores/useOrderItemsStore"; -import { formatCurrency } from "@sahil/lib"; -import Image from "next/image"; -import { useRouter } from "next/router"; -import { - HiOutlineShoppingCart, - HiOutlineReceiptPercent, -} from "react-icons/hi2"; -import { - useInitBusinessOrder, - useOrderValidSubscription, - usePlaceBusinessOrder, -} from "@/hooks/orders"; -import { Key, useEffect, useState } from "react"; -import { Order_Item } from "@sahil/lib/graphql/__generated__/graphql"; - -export const OrderItem = ({ - price, - quantity, - title, - mainImage, -}: { - price: number; - quantity: number; - title: string; - mainImage?: string; -}) => { - return ( -
-
- Movie -
-
-
-
-

{title}

-
-
- -
-
-

- {formatCurrency(price)} -

-
-
- ); -}; - -export const OrderItems = ({ items }: { items: any }) => { - console.log(items); - const { totalItems, totalCost } = items?.reduce( - ( - totals: { totalItems: any; totalCost: number }, - product: { quantity: number; price: number } - ) => ({ - totalItems: totals.totalItems + product.quantity, - totalCost: totals.totalCost + product.price * product.quantity, - }), - { - totalItems: 0, - totalCost: 0, - } - ); - - return ( - <> - - - - - ); -}; - -function calculateTotal(arr: Order_Item[]) { - // Initialize total items and total price - let totalItems = 0; - let totalPrice = 0; - - // Iterate through the array - for (const item of arr) { - // Add quantity to total items - totalItems += item.quantity; - - // Calculate subtotal for the current item - const subtotal = item.price * item.quantity; - - // Add subtotal to total price - totalPrice += subtotal; - } - - // Return an object with total items and total price - return { - totalItems, - totalPrice, - }; -} - -export default function CheckoutPage() { - const { - initOrder, - loading: initLoading, - error: initError, - } = useInitBusinessOrder(); - const { orderItems } = useOrderItemsStore((state) => state); - // @ts-ignore - const { totalItems, totalPrice } = calculateTotal(orderItems); - const [actionId, setActionId] = useState(); - const router = useRouter(); - - const onConfirmOrder = async () => { - const orderItemsForInsert = orderItems.map((item) => ({ - productId: item.productId, - quantity: item.quantity, - price: item.price, - })); - - const object = { - order_items: { data: orderItemsForInsert }, - //ToDo: User Auth user id instead of hard-coded value - customerId: "e87924e8-69e4-4171-bd89-0c8963e03d08", - }; - - try { - const result = await initOrder({ - variables: { - object, - }, - }); - console.log(result); - setActionId(result.data.insertBusinessOrder); - } catch (error) { - console.error(error); - } - }; - - return ( -
-
-
- -
-
-
- -
-
-

Items

-

{totalItems} items

-
-
-

Total

-

{formatCurrency(totalPrice)}

-
-
-
- -
- -
- -
- brand -
-
-
-
-
- ); -} - -const ProcessOrderRequest = ({ - actionId, -}: { - actionId: string | undefined; -}) => { - const { - placeOrder, - loading: orderLoading, - error: orderError, - } = usePlaceBusinessOrder(); - const { data, loading, error } = useOrderValidSubscription(actionId!); - const [placeOrderResult, setPlaceOrderResult] = useState(); - - useEffect(() => { - const addOrderToDB = async () => { - if (data && data.insertBusinessOrder && data.insertBusinessOrder.output) { - try { - const order = removeTypename(data.insertBusinessOrder.output.order); - console.log("Order to be placed:", order); - const result = await placeOrder({ - variables: { - object: order, - }, - }); - setPlaceOrderResult(result); - } catch (err) { - console.error("Error placing order:", err); - } - } - }; - - addOrderToDB(); - }, [data, placeOrder]); - - if (error) return

An error occurred while placing order

; - if (loading) return

Processing order...

; - - if (placeOrderResult) { - return

Order successfully placed

; - } - - return <>; -}; - -const removeTypename = (value: any): any => { - if (value === null || value === undefined || typeof value !== "object") { - return value; - } - if (Array.isArray(value)) { - return value.map((v) => removeTypename(v)); - } - type GenericObject = { [key: string]: any }; - - const newValue: GenericObject = {}; - for (const key in value) { - if (key !== "__typename") { - newValue[key] = removeTypename(value[key]); - } - } - return newValue; -}; diff --git a/apps/client/src/pages/orders/[orderId].tsx b/apps/client/src/pages/orders/[orderId].tsx index 123937d4..b3c671d0 100644 --- a/apps/client/src/pages/orders/[orderId].tsx +++ b/apps/client/src/pages/orders/[orderId].tsx @@ -8,7 +8,7 @@ import { } from "@sahil/features/Orders"; import { Tabs } from "ui"; -import { useFetchOrderByPK } from "@/hooks/orders"; +import { useFetchOrderByPK } from "@sahil/lib/hooks/orders"; import { useRouter } from "next/router"; export default function OrderPage() { @@ -26,7 +26,7 @@ export default function OrderPage() {
- + {true ? ( <> diff --git a/apps/client/types.d.ts b/apps/client/types.d.ts new file mode 100644 index 00000000..46cd38d3 --- /dev/null +++ b/apps/client/types.d.ts @@ -0,0 +1,11 @@ +// https://github.com/nextauthjs/next-auth/discussions/536#discussioncomment-1932922 +import NextAuth, { DefaultSession } from "next-auth"; + +declare module "next-auth" { + interface Session { + user: { + id: string; + address: string; + } & DefaultSession["user"]; + } +} diff --git a/turbo.json b/turbo.json index 255461b8..31937712 100644 --- a/turbo.json +++ b/turbo.json @@ -1,5 +1,5 @@ { - "globalDotEnv": [".env"], + "globalEnv": [".env"], "$schema": "https://turbo.build/schema.json", "globalDependencies": ["**/.env.*local", ".env.development", ".env.production"], "remoteCache": { @@ -30,4 +30,4 @@ "persistent": true } } -} +} \ No newline at end of file From b81b23e8371eab3377a1114a59947b13f1f20409 Mon Sep 17 00:00:00 2001 From: eman-bfloat Date: Wed, 16 Oct 2024 17:32:29 +0300 Subject: [PATCH 2/9] feat: add type defs to courier and admin --- apps/admin/next.config.js | 1 + apps/admin/types.d.ts | 11 +++++++++++ apps/courier/next.config.mjs | 8 +++++++- apps/courier/types.d.ts | 11 +++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 apps/admin/types.d.ts create mode 100644 apps/courier/types.d.ts diff --git a/apps/admin/next.config.js b/apps/admin/next.config.js index 5cba8eae..8582905a 100644 --- a/apps/admin/next.config.js +++ b/apps/admin/next.config.js @@ -16,6 +16,7 @@ const nextConfig = { }, ], }, + output: "standalone" }; module.exports = nextConfig; diff --git a/apps/admin/types.d.ts b/apps/admin/types.d.ts new file mode 100644 index 00000000..46cd38d3 --- /dev/null +++ b/apps/admin/types.d.ts @@ -0,0 +1,11 @@ +// https://github.com/nextauthjs/next-auth/discussions/536#discussioncomment-1932922 +import NextAuth, { DefaultSession } from "next-auth"; + +declare module "next-auth" { + interface Session { + user: { + id: string; + address: string; + } & DefaultSession["user"]; + } +} diff --git a/apps/courier/next.config.mjs b/apps/courier/next.config.mjs index 3be6379d..8582905a 100644 --- a/apps/courier/next.config.mjs +++ b/apps/courier/next.config.mjs @@ -9,8 +9,14 @@ const nextConfig = { hostname: 'res.cloudinary.com', port: '', }, + { + protocol: 'https', + hostname: 'https://lh3.googleusercontent.com', + port: '', + }, ], }, + output: "standalone" }; -export default nextConfig; +module.exports = nextConfig; diff --git a/apps/courier/types.d.ts b/apps/courier/types.d.ts new file mode 100644 index 00000000..46cd38d3 --- /dev/null +++ b/apps/courier/types.d.ts @@ -0,0 +1,11 @@ +// https://github.com/nextauthjs/next-auth/discussions/536#discussioncomment-1932922 +import NextAuth, { DefaultSession } from "next-auth"; + +declare module "next-auth" { + interface Session { + user: { + id: string; + address: string; + } & DefaultSession["user"]; + } +} From 65533887ca1492b824a3c937857c0e89baec3bf6 Mon Sep 17 00:00:00 2001 From: eman-bfloat Date: Wed, 16 Oct 2024 17:38:55 +0300 Subject: [PATCH 3/9] feat: add admin and courier dockerfiles --- docker-compose.yml | 36 +++++++++++++++++++-- infra/docker/Dockerfile.admin | 56 +++++++++++++++++++++++++++++++++ infra/docker/Dockerfile.courier | 56 +++++++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 infra/docker/Dockerfile.admin create mode 100644 infra/docker/Dockerfile.courier diff --git a/docker-compose.yml b/docker-compose.yml index 72da5f0a..940bc066 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -65,6 +65,36 @@ services: - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_DATABASE=${POSTGRES_DATABASE} + # ADMIN + sahil-admin: + container_name: sahil-admin + build: + context: . + dockerfile: ./infra/docker/Dockerfile.admin + image: sahil-admin + restart: always + ports: + - '3003:3000' + environment: + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DATABASE=${POSTGRES_DATABASE} + + # COURIER + sahil-courier: + container_name: sahil-courier + build: + context: . + dockerfile: ./infra/docker/Dockerfile.courier + image: sahil-courier + restart: always + ports: + - '3004:3000' + environment: + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DATABASE=${POSTGRES_DATABASE} + #### LOCAL DEV ENVIRONMENTS #### # HASURA ENGINE @@ -115,9 +145,9 @@ services: retries: 5 start_period: 5s - # API - sahil-api-local-dev: - container_name: sahil-redis-postgres + # Redis + sahil-redis: + container_name: sahil-redis image: redis:6.0-alpine restart: always environment: diff --git a/infra/docker/Dockerfile.admin b/infra/docker/Dockerfile.admin new file mode 100644 index 00000000..aaa97a8d --- /dev/null +++ b/infra/docker/Dockerfile.admin @@ -0,0 +1,56 @@ +ARG NODE_VERSION=18.17.0 + +FROM node:${NODE_VERSION}-alpine As base + +FROM base AS builder +RUN apk add --no-cache libc6-compat +RUN apk update +# Set working directory +WORKDIR /app +RUN yarn global add turbo +COPY . . +RUN turbo prune client --docker + +# Add lockfile and package.json's of isolated subworkspace +FROM base AS installer +RUN apk add --no-cache libc6-compat +RUN apk update +WORKDIR /app + +# Install the dependencies +COPY .gitignore .gitignore +COPY --from=builder /app/out/json/ . +COPY --from=builder /app/out/yarn.lock ./yarn.lock +RUN yarn install --network-timeout 100000 + +# Build the project +COPY --from=builder /app/out/full/ . +COPY turbo.json turbo.json + +# Remote caching +# ARG TURBO_TEAM +# ENV TURBO_TEAM=$TURBO_TEAM + +# ARG TURBO_TOKEN +# ENV TURBO_TOKEN=$TURBO_TOKEN + +# || true +RUN yarn turbo build --filter=admin... + +FROM base AS runner +WORKDIR /app + +# Don't run production as root +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs +USER nextjs + +COPY --from=installer /app/apps/admin/next.config.js . +COPY --from=installer /app/apps/admin/package.json . + +# Reduce image size +COPY --from=installer --chown=nextjs:nodejs /app/apps/admin/.next/standalone ./ +COPY --from=installer --chown=nextjs:nodejs /app/apps/admin/.next/static ./apps/admin/.next/static +COPY --from=installer --chown=nextjs:nodejs /app/apps/admin/public ./apps/admin/public + +CMD node apps/admin/server.js \ No newline at end of file diff --git a/infra/docker/Dockerfile.courier b/infra/docker/Dockerfile.courier new file mode 100644 index 00000000..554c282a --- /dev/null +++ b/infra/docker/Dockerfile.courier @@ -0,0 +1,56 @@ +ARG NODE_VERSION=18.17.0 + +FROM node:${NODE_VERSION}-alpine As base + +FROM base AS builder +RUN apk add --no-cache libc6-compat +RUN apk update +# Set working directory +WORKDIR /app +RUN yarn global add turbo +COPY . . +RUN turbo prune courier --docker + +# Add lockfile and package.json's of isolated subworkspace +FROM base AS installer +RUN apk add --no-cache libc6-compat +RUN apk update +WORKDIR /app + +# Install the dependencies +COPY .gitignore .gitignore +COPY --from=builder /app/out/json/ . +COPY --from=builder /app/out/yarn.lock ./yarn.lock +RUN yarn install --network-timeout 100000 + +# Build the project +COPY --from=builder /app/out/full/ . +COPY turbo.json turbo.json + +# Remote caching +# ARG TURBO_TEAM +# ENV TURBO_TEAM=$TURBO_TEAM + +# ARG TURBO_TOKEN +# ENV TURBO_TOKEN=$TURBO_TOKEN + +# || true +RUN yarn turbo build --filter=courier... + +FROM base AS runner +WORKDIR /app + +# Don't run production as root +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs +USER nextjs + +COPY --from=installer /app/apps/courier/next.config.js . +COPY --from=installer /app/apps/courier/package.json . + +# Reduce image size +COPY --from=installer --chown=nextjs:nodejs /app/apps/courier/.next/standalone ./ +COPY --from=installer --chown=nextjs:nodejs /app/apps/courier/.next/static ./apps/courier/.next/static +COPY --from=installer --chown=nextjs:nodejs /app/apps/courier/public ./apps/courier/public + +CMD node apps/courier/server.js \ No newline at end of file From 75091ad6490612f1f9ca1a16842ebf23eaf318ad Mon Sep 17 00:00:00 2001 From: eman-bfloat Date: Wed, 16 Oct 2024 17:41:25 +0300 Subject: [PATCH 4/9] feat: validate environment variables using zod --- apps/admin/src/config.ts | 48 +++++++++++++++++++++++++++++++ apps/agent/src/Layout/layout.tsx | 3 +- apps/agent/src/config.ts | 48 +++++++++++++++++++++++++++++++ apps/client/src/config.ts | 48 +++++++++++++++++++++++++++++++ apps/courier/src/config.ts | 48 +++++++++++++++++++++++++++++++ packages/ui/components/Navbar.tsx | 35 +++++++++++++++++++++- 6 files changed, 227 insertions(+), 3 deletions(-) create mode 100644 apps/admin/src/config.ts create mode 100644 apps/agent/src/config.ts create mode 100644 apps/client/src/config.ts create mode 100644 apps/courier/src/config.ts diff --git a/apps/admin/src/config.ts b/apps/admin/src/config.ts new file mode 100644 index 00000000..7931068f --- /dev/null +++ b/apps/admin/src/config.ts @@ -0,0 +1,48 @@ +import { z } from 'zod'; + +const envSchema = z.object({ + // Server + SERVER_URL: z.string().url(), + + // Hasura + HASURA_GRAPHQL_CORS_DOMAIN: z.string(), + NEXT_PUBLIC_HASURA_GRAPHQL_ENDPOINT: z.string().url(), + NEXT_PUBLIC_HASURA_GRAPHQL_ADMIN_SECRET: z.string(), + NEXT_PUBLIC_HASURA_GRAPHQL_WS: z.string().url(), + + // Auth + SECRET: z.string(), + NEXTAUTH_SECRET: z.string(), + NEXT_PUBLIC_NEXTAUTH_URL: z.string().url(), + + // APIs + NEXT_PUBLIC_GITHUB_SECRET: z.string(), + NEXT_PUBLIC_GITHUB_ID: z.string(), + NEXT_PUBLIC_GOOGLE_SECRET: z.string(), + NEXT_PUBLIC_GOOGLE_API_KEY: z.string().optional(), + NEXT_PUBLIC_GOOGLE_ID: z.string(), + + // Database + POSTGRES_USER: z.string(), + POSTGRES_PASSWORD: z.string(), + POSTGRES_DATABASE: z.string(), + + // App URLs + ADMIN_URL: z.string().url(), + AGENT_URL: z.string().url(), + CLIENT_URL: z.string().url(), + COURIER_URL: z.string().url(), + API_URL: z.string().url(), + + // Email + EMAIL_SERVER_USER: z.string(), + EMAIL_SERVER_PASSWORD: z.string(), + EMAIL_SERVER_HOST: z.string(), + EMAIL_SERVER_PORT: z.string(), + EMAIL_FROM: z.string().email(), + EMAIL_SERVER: z.string(), +}); + +const env = envSchema.parse(process.env); + +export default env; diff --git a/apps/agent/src/Layout/layout.tsx b/apps/agent/src/Layout/layout.tsx index e3a53c71..c6141f7e 100644 --- a/apps/agent/src/Layout/layout.tsx +++ b/apps/agent/src/Layout/layout.tsx @@ -46,8 +46,7 @@ export default function Layout({ children, ...props }: LayoutProps) { }; return ( <> - {session?.user && ( - +<<<<<<< Updated upstream
  • Quick Menu:

  • @@ -139,9 +140,41 @@ const Right = ({
  • -
  • From ea1760abfea8688b776086f96962ae512290931d Mon Sep 17 00:00:00 2001 From: eman-bfloat Date: Sat, 19 Oct 2024 13:51:05 +0300 Subject: [PATCH 5/9] fix: admin and courier build errors --- apps/admin/next.config.js | 7 +- apps/admin/package.json | 29 +- .../{next.config.mjs => next.config.js} | 7 +- apps/courier/package.json | 26 +- .../src/pages/deliveries/[deliveryId].tsx | 12 +- .../src/pages/requests/[requestId].tsx | 5 - infra/docker/Dockerfile.admin | 2 +- packages/features/Users/ListUsers.tsx | 23 +- packages/features/Users/UserOverview.tsx | 8 +- packages/lib/graphql/__generated__/gql.ts | 54 +- packages/lib/graphql/__generated__/graphql.ts | 1056 ++++++++++++++++- packages/lib/graphql/queries/deliveries.ts | 1 + packages/lib/hooks/couriers.tsx | 4 +- packages/lib/hooks/deliveries.tsx | 16 +- packages/lib/hooks/orders.tsx | 12 +- packages/lib/hooks/products.ts | 8 +- packages/lib/hooks/users.tsx | 11 + packages/ui/components/Navbar.tsx | 35 +- yarn.lock | 6 +- 19 files changed, 1181 insertions(+), 141 deletions(-) rename apps/courier/{next.config.mjs => next.config.js} (72%) diff --git a/apps/admin/next.config.js b/apps/admin/next.config.js index 8582905a..84d0e949 100644 --- a/apps/admin/next.config.js +++ b/apps/admin/next.config.js @@ -1,7 +1,7 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, - transpilePackages: ['@sahil/lib', 'ui', '@sahil/configs', "@sahil/features"], + transpilePackages: ['@sahil/lib', 'ui', '@sahil/configs', "@sahil/features", "tsconfig", "eslint-config-custom"], images: { remotePatterns: [ { @@ -9,11 +9,6 @@ const nextConfig = { hostname: 'res.cloudinary.com', port: '', }, - { - protocol: 'https', - hostname: 'https://lh3.googleusercontent.com', - port: '', - }, ], }, output: "standalone" diff --git a/apps/admin/package.json b/apps/admin/package.json index 58bacac8..2008def6 100644 --- a/apps/admin/package.json +++ b/apps/admin/package.json @@ -9,16 +9,41 @@ "lint": "next lint" }, "dependencies": { + "@apollo/client": "^3.8.1", + "@apollo/react-hooks": "^4.0.0", + "@formkit/auto-animate": "^0.7.0", + "@hookform/resolvers": "^3.3.0", + "@react-google-maps/api": "^2.19.2", "@sahil/configs": "*", "@sahil/features": "*", "@sahil/lib": "*", + "@types/jsonwebtoken": "^9.0.5", + "apollo-link-ws": "^1.0.20", + "autoprefixer": "10.4.15", "daisyui": "^4.12.2", - "next": "14.2.3", + "date-fns": "^2.30.0", + "eslint": "8.47.0", + "eslint-config-custom": "*", + "eslint-config-next": "^14.2.3", + "graphql": "^16.8.0", + "graphql-ws": "^5.14.0", + "jsonwebtoken": "^9.0.2", + "next": "^14.2.3", "next-auth": "^4.24.7", "next-auth-hasura-adapter": "^2.0.0", + "postcss": "8.4.28", "react": "^18.3.1", "react-dom": "^18.3.1", - "ui": "*" + "react-hook-form": "^7.45.4", + "react-hot-toast": "^2.4.1", + "react-icons": "^4.12.0", + "subscriptions-transport-ws": "^0.11.0", + "swr": "^2.2.1", + "tailwindcss": "3.3.3", + "tsconfig": "*", + "ui": "*", + "zod": "3.21.4", + "zustand": "^4.4.1" }, "devDependencies": { "@types/node": "^20", diff --git a/apps/courier/next.config.mjs b/apps/courier/next.config.js similarity index 72% rename from apps/courier/next.config.mjs rename to apps/courier/next.config.js index 8582905a..84d0e949 100644 --- a/apps/courier/next.config.mjs +++ b/apps/courier/next.config.js @@ -1,7 +1,7 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, - transpilePackages: ['@sahil/lib', 'ui', '@sahil/configs', "@sahil/features"], + transpilePackages: ['@sahil/lib', 'ui', '@sahil/configs', "@sahil/features", "tsconfig", "eslint-config-custom"], images: { remotePatterns: [ { @@ -9,11 +9,6 @@ const nextConfig = { hostname: 'res.cloudinary.com', port: '', }, - { - protocol: 'https', - hostname: 'https://lh3.googleusercontent.com', - port: '', - }, ], }, output: "standalone" diff --git a/apps/courier/package.json b/apps/courier/package.json index 9d6c5eab..64594538 100644 --- a/apps/courier/package.json +++ b/apps/courier/package.json @@ -8,17 +8,41 @@ "start": "next start" }, "dependencies": { + "@apollo/client": "^3.8.1", + "@apollo/react-hooks": "^4.0.0", + "@formkit/auto-animate": "^0.7.0", + "@hookform/resolvers": "^3.3.0", + "@react-google-maps/api": "^2.19.2", "@sahil/configs": "*", "@sahil/features": "*", "@sahil/lib": "*", + "@types/jsonwebtoken": "^9.0.5", + "apollo-link-ws": "^1.0.20", + "autoprefixer": "10.4.15", "daisyui": "^4.12.2", + "date-fns": "^2.30.0", + "eslint": "8.47.0", + "eslint-config-custom": "*", "eslint-config-next": "^14.2.3", + "graphql": "^16.8.0", + "graphql-ws": "^5.14.0", + "jsonwebtoken": "^9.0.2", "next": "^14.2.3", "next-auth": "^4.24.7", "next-auth-hasura-adapter": "^2.0.0", + "postcss": "8.4.28", "react": "^18.3.1", "react-dom": "^18.3.1", - "ui": "*" + "react-hook-form": "^7.45.4", + "react-hot-toast": "^2.4.1", + "react-icons": "^4.12.0", + "subscriptions-transport-ws": "^0.11.0", + "swr": "^2.2.1", + "tailwindcss": "3.3.3", + "tsconfig": "*", + "ui": "*", + "zod": "3.21.4", + "zustand": "^4.4.1" }, "devDependencies": { "@types/node": "^20", diff --git a/apps/courier/src/pages/deliveries/[deliveryId].tsx b/apps/courier/src/pages/deliveries/[deliveryId].tsx index 19450373..fd965532 100644 --- a/apps/courier/src/pages/deliveries/[deliveryId].tsx +++ b/apps/courier/src/pages/deliveries/[deliveryId].tsx @@ -102,17 +102,17 @@ export default function DeliveryPage() { { icon: , label: "Payment Method", - value: delivery?.payment_method || "N/A", + value: "N/A", }, { icon: , label: "Client", - value: delivery?.client?.name || "N/A", + value: "N/A", }, { icon: , label: "Status", - value: delivery?.status || "N/A", + value: "N/A", }, ]; @@ -151,14 +151,16 @@ export default function DeliveryPage() { Navigate Independently - {delivery.status === 'pending' && ( + {/* { + + delivery.status === 'pending' && ( - )} + )} */} , - label: "Client", - value: deliveryRequest?.business?.name as string, - }, ]; const isSingleOrder = deliveryRequest.delivery_request_orders.length === 1; diff --git a/infra/docker/Dockerfile.admin b/infra/docker/Dockerfile.admin index aaa97a8d..127c2480 100644 --- a/infra/docker/Dockerfile.admin +++ b/infra/docker/Dockerfile.admin @@ -9,7 +9,7 @@ RUN apk update WORKDIR /app RUN yarn global add turbo COPY . . -RUN turbo prune client --docker +RUN turbo prune admin --docker # Add lockfile and package.json's of isolated subworkspace FROM base AS installer diff --git a/packages/features/Users/ListUsers.tsx b/packages/features/Users/ListUsers.tsx index 1cdc2026..0f145951 100644 --- a/packages/features/Users/ListUsers.tsx +++ b/packages/features/Users/ListUsers.tsx @@ -1,30 +1,17 @@ import { UserOverview } from "./UserOverview"; import { UsersToolbar } from "./UsersToolbar"; +import { useFetchUsers} from "@sahil/lib/hooks/users"; -const users = [ - { - id: 1, - name: "John Doe", - avatar: "https://avatars.dicebear.com/api/initials/JD.svg", - }, - { - id: 2, - name: "John Doe", - avatar: "https://avatars.dicebear.com/api/initials/JD.svg", - }, - { - id: 3, - name: "John Doe", - avatar: "https://avatars.dicebear.com/api/initials/JD.svg", - }, -]; export const ListUsers = () => { + const { data: users, loading, error } = useFetchUsers(); + if (loading) return
    Loading...
    ; + if (error) return
    Error: {error.message}
    ; return (
    - {users.map((user) => ( + {users?.map((user) => ( ))}
    diff --git a/packages/features/Users/UserOverview.tsx b/packages/features/Users/UserOverview.tsx index d9b167bc..ba924626 100644 --- a/packages/features/Users/UserOverview.tsx +++ b/packages/features/Users/UserOverview.tsx @@ -3,17 +3,11 @@ import { Avatar, Card } from "ui"; import { Users } from "@sahil/lib/graphql/__generated__/graphql"; import Link from "next/link"; -type Props = { - user: Users; -} & { - avatar?: string; -}; -export const UserOverview: FC = ({ user }) => { +export const UserOverview = ({ user }: any) => { return (
    - {user?.avatar && }

    {user.name}

    diff --git a/packages/lib/graphql/__generated__/gql.ts b/packages/lib/graphql/__generated__/gql.ts index 26cd0151..a94a725d 100644 --- a/packages/lib/graphql/__generated__/gql.ts +++ b/packages/lib/graphql/__generated__/gql.ts @@ -60,19 +60,19 @@ const documents = { types.GetCouriersByPkDocument, "\n fragment DeliveryFields on delivery {\n id\n created_at\n }\n": types.DeliveryFieldsFragmentDoc, - "\n fragment DeliveryRequestFields on delivery_request {\n id\n created_at\n }\n": + "\n fragment DeliveryRequestFields on delivery_request {\n id\n created_at\n delivery_method\n status\n courierId\n created_at\n updated_at\n }\n": types.DeliveryRequestFieldsFragmentDoc, - "\n \n query getDeliveries {\n delivery {\n ...DeliveryFields\n }\n delivery_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n": + "\n \n query getDeliveries {\n delivery {\n ...DeliveryFields\n order {\n customerId\n created_at\n order_items {\n product {\n created_at\n description\n discount\n name\n price\n quantity\n inStock\n }\n }\n }\n }\n delivery_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n": types.GetDeliveriesDocument, - "\n \n query getDeliveryByPK($id: uuid!) {\n delivery(where: {id: {_eq: $id}}) {\n ...DeliveryFields\n }\n }\n": + "\n \n query getDeliveryByPK($id: uuid!) {\n delivery(where: { id: { _eq: $id } }) {\n ...DeliveryFields\n order {\n customerId\n created_at\n status\n order_items {\n product {\n created_at\n description\n discount\n name\n price\n quantity\n inStock\n }\n }\n }\n }\n }\n": types.GetDeliveryByPkDocument, - "\n \n query getDeliveriesByCourier($courier_id: uuid!) {\n delivery(where: {courierId: {_eq: $courier_id}}) {\n ...DeliveryFields\n }\n }\n": + "\n \n query getDeliveriesByCourier($courier_id: uuid!) {\n delivery(where: { courierId: { _eq: $courier_id } }) {\n ...DeliveryFields\n order {\n customerId\n created_at\n order_items {\n product {\n created_at\n description\n discount\n name\n price\n quantity\n inStock\n }\n }\n }\n }\n }\n": types.GetDeliveriesByCourierDocument, - "\n \n query getDeliveryRequests {\n delivery_request {\n ...DeliveryRequestFields\n }\n delivery_request_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n": + "\n \n query getDeliveryRequests {\n delivery_request {\n ...DeliveryRequestFields\n delivery_request_orders {\n id\n order_id\n order {\n id\n order_items {\n id\n product {\n id\n description\n discount\n inStock\n mainImage\n name\n quantity\n price\n }\n }\n }\n }\n }\n delivery_request_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n": types.GetDeliveryRequestsDocument, - "\n \n query getDeliveryRequestByPK($id: uuid!) {\n delivery_request(where: {id: {_eq: $id}}) {\n ...DeliveryRequestFields\n }\n }\n": + "\n \n query getDeliveryRequestByPK($id: uuid!) {\n delivery_request(where: { id: { _eq: $id } }) {\n ...DeliveryRequestFields\n delivery_request_orders {\n id\n order_id\n order {\n id\n order_items {\n id\n product {\n id\n description\n discount\n inStock\n mainImage\n name\n quantity\n price\n }\n }\n }\n }\n }\n }\n": types.GetDeliveryRequestByPkDocument, - "\n \n query getDeliveryRequestByCourier($courier_id: uuid!) {\n delivery_request(where: {courierId: {_eq: $courier_id}}) {\n ...DeliveryRequestFields\n }\n }\n": + "\n \n query getDeliveryRequestByCourier($courier_id: uuid!) {\n delivery_request(where: { courierId: { _eq: $courier_id } }) {\n ...DeliveryRequestFields\n }\n }\n": types.GetDeliveryRequestByCourierDocument, "\n query fetchSahilZones {\n locations {\n id\n }\n }\n": types.FetchSahilZonesDocument, @@ -88,7 +88,7 @@ const documents = { types.AllStatusHistoriesFragmentDoc, "\n \n \n \n query getOrders {\n orders {\n ...OrderCoreFields\n ...LatestStatusHistory\n business {\n ...OrderBusinessFields\n }\n }\n orders_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n": types.GetOrdersDocument, - "\n \n \n \n query getOrderByPK($id: uuid!) {\n orders_by_pk(id: $id) {\n ...OrderCoreFields\n ...OrderItemsAggregate\n ...AllStatusHistories\n order_items {\n id\n product {\n id\n name\n quantity\n price\n }\n }\n agent {\n name\n }\n }\n }\n": + "\n \n \n \n \n query getOrderByPK($id: uuid!) {\n orders_by_pk(id: $id) {\n ...OrderCoreFields\n ...OrderItemsAggregate\n ...AllStatusHistories\n business {\n ...OrderBusinessFields\n }\n order_items {\n id\n product {\n id\n name\n quantity\n price\n }\n }\n agent {\n name\n }\n }\n }\n": types.GetOrderByPkDocument, "\n query getOrderDeliveries($orderId: uuid!) {\n delivery {\n status\n id\n created_at\n courierId\n }\n }\n": types.GetOrderDeliveriesDocument, @@ -138,7 +138,7 @@ const documents = { types.ZoneFieldsFragmentDoc, "\n \n query GetZones {\n zones {\n ...ZoneFields\n }\n }\n": types.GetZonesDocument, - "\n \n query GetZonesById($id: uuid!) {\n zones(where: { id: {_eq: $id } }) {\n ...ZoneFields\n }\n }\n": + "\n \n query GetZonesById($id: uuid!) {\n zones(where: { id: { _eq: $id } }) {\n ...ZoneFields\n }\n }\n": types.GetZonesByIdDocument, }; @@ -304,44 +304,44 @@ export function gql( * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: "\n fragment DeliveryRequestFields on delivery_request {\n id\n created_at\n }\n" -): (typeof documents)["\n fragment DeliveryRequestFields on delivery_request {\n id\n created_at\n }\n"]; + source: "\n fragment DeliveryRequestFields on delivery_request {\n id\n created_at\n delivery_method\n status\n courierId\n created_at\n updated_at\n }\n" +): (typeof documents)["\n fragment DeliveryRequestFields on delivery_request {\n id\n created_at\n delivery_method\n status\n courierId\n created_at\n updated_at\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: "\n \n query getDeliveries {\n delivery {\n ...DeliveryFields\n }\n delivery_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n" -): (typeof documents)["\n \n query getDeliveries {\n delivery {\n ...DeliveryFields\n }\n delivery_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n"]; + source: "\n \n query getDeliveries {\n delivery {\n ...DeliveryFields\n order {\n customerId\n created_at\n order_items {\n product {\n created_at\n description\n discount\n name\n price\n quantity\n inStock\n }\n }\n }\n }\n delivery_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n" +): (typeof documents)["\n \n query getDeliveries {\n delivery {\n ...DeliveryFields\n order {\n customerId\n created_at\n order_items {\n product {\n created_at\n description\n discount\n name\n price\n quantity\n inStock\n }\n }\n }\n }\n delivery_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: "\n \n query getDeliveryByPK($id: uuid!) {\n delivery(where: {id: {_eq: $id}}) {\n ...DeliveryFields\n }\n }\n" -): (typeof documents)["\n \n query getDeliveryByPK($id: uuid!) {\n delivery(where: {id: {_eq: $id}}) {\n ...DeliveryFields\n }\n }\n"]; + source: "\n \n query getDeliveryByPK($id: uuid!) {\n delivery(where: { id: { _eq: $id } }) {\n ...DeliveryFields\n order {\n customerId\n created_at\n status\n order_items {\n product {\n created_at\n description\n discount\n name\n price\n quantity\n inStock\n }\n }\n }\n }\n }\n" +): (typeof documents)["\n \n query getDeliveryByPK($id: uuid!) {\n delivery(where: { id: { _eq: $id } }) {\n ...DeliveryFields\n order {\n customerId\n created_at\n status\n order_items {\n product {\n created_at\n description\n discount\n name\n price\n quantity\n inStock\n }\n }\n }\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: "\n \n query getDeliveriesByCourier($courier_id: uuid!) {\n delivery(where: {courierId: {_eq: $courier_id}}) {\n ...DeliveryFields\n }\n }\n" -): (typeof documents)["\n \n query getDeliveriesByCourier($courier_id: uuid!) {\n delivery(where: {courierId: {_eq: $courier_id}}) {\n ...DeliveryFields\n }\n }\n"]; + source: "\n \n query getDeliveriesByCourier($courier_id: uuid!) {\n delivery(where: { courierId: { _eq: $courier_id } }) {\n ...DeliveryFields\n order {\n customerId\n created_at\n order_items {\n product {\n created_at\n description\n discount\n name\n price\n quantity\n inStock\n }\n }\n }\n }\n }\n" +): (typeof documents)["\n \n query getDeliveriesByCourier($courier_id: uuid!) {\n delivery(where: { courierId: { _eq: $courier_id } }) {\n ...DeliveryFields\n order {\n customerId\n created_at\n order_items {\n product {\n created_at\n description\n discount\n name\n price\n quantity\n inStock\n }\n }\n }\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: "\n \n query getDeliveryRequests {\n delivery_request {\n ...DeliveryRequestFields\n }\n delivery_request_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n" -): (typeof documents)["\n \n query getDeliveryRequests {\n delivery_request {\n ...DeliveryRequestFields\n }\n delivery_request_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n"]; + source: "\n \n query getDeliveryRequests {\n delivery_request {\n ...DeliveryRequestFields\n delivery_request_orders {\n id\n order_id\n order {\n id\n order_items {\n id\n product {\n id\n description\n discount\n inStock\n mainImage\n name\n quantity\n price\n }\n }\n }\n }\n }\n delivery_request_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n" +): (typeof documents)["\n \n query getDeliveryRequests {\n delivery_request {\n ...DeliveryRequestFields\n delivery_request_orders {\n id\n order_id\n order {\n id\n order_items {\n id\n product {\n id\n description\n discount\n inStock\n mainImage\n name\n quantity\n price\n }\n }\n }\n }\n }\n delivery_request_aggregate {\n aggregate {\n count(columns: id, distinct: true)\n }\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: "\n \n query getDeliveryRequestByPK($id: uuid!) {\n delivery_request(where: {id: {_eq: $id}}) {\n ...DeliveryRequestFields\n }\n }\n" -): (typeof documents)["\n \n query getDeliveryRequestByPK($id: uuid!) {\n delivery_request(where: {id: {_eq: $id}}) {\n ...DeliveryRequestFields\n }\n }\n"]; + source: "\n \n query getDeliveryRequestByPK($id: uuid!) {\n delivery_request(where: { id: { _eq: $id } }) {\n ...DeliveryRequestFields\n delivery_request_orders {\n id\n order_id\n order {\n id\n order_items {\n id\n product {\n id\n description\n discount\n inStock\n mainImage\n name\n quantity\n price\n }\n }\n }\n }\n }\n }\n" +): (typeof documents)["\n \n query getDeliveryRequestByPK($id: uuid!) {\n delivery_request(where: { id: { _eq: $id } }) {\n ...DeliveryRequestFields\n delivery_request_orders {\n id\n order_id\n order {\n id\n order_items {\n id\n product {\n id\n description\n discount\n inStock\n mainImage\n name\n quantity\n price\n }\n }\n }\n }\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: "\n \n query getDeliveryRequestByCourier($courier_id: uuid!) {\n delivery_request(where: {courierId: {_eq: $courier_id}}) {\n ...DeliveryRequestFields\n }\n }\n" -): (typeof documents)["\n \n query getDeliveryRequestByCourier($courier_id: uuid!) {\n delivery_request(where: {courierId: {_eq: $courier_id}}) {\n ...DeliveryRequestFields\n }\n }\n"]; + source: "\n \n query getDeliveryRequestByCourier($courier_id: uuid!) {\n delivery_request(where: { courierId: { _eq: $courier_id } }) {\n ...DeliveryRequestFields\n }\n }\n" +): (typeof documents)["\n \n query getDeliveryRequestByCourier($courier_id: uuid!) {\n delivery_request(where: { courierId: { _eq: $courier_id } }) {\n ...DeliveryRequestFields\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ @@ -388,8 +388,8 @@ export function gql( * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: "\n \n \n \n query getOrderByPK($id: uuid!) {\n orders_by_pk(id: $id) {\n ...OrderCoreFields\n ...OrderItemsAggregate\n ...AllStatusHistories\n order_items {\n id\n product {\n id\n name\n quantity\n price\n }\n }\n agent {\n name\n }\n }\n }\n" -): (typeof documents)["\n \n \n \n query getOrderByPK($id: uuid!) {\n orders_by_pk(id: $id) {\n ...OrderCoreFields\n ...OrderItemsAggregate\n ...AllStatusHistories\n order_items {\n id\n product {\n id\n name\n quantity\n price\n }\n }\n agent {\n name\n }\n }\n }\n"]; + source: "\n \n \n \n \n query getOrderByPK($id: uuid!) {\n orders_by_pk(id: $id) {\n ...OrderCoreFields\n ...OrderItemsAggregate\n ...AllStatusHistories\n business {\n ...OrderBusinessFields\n }\n order_items {\n id\n product {\n id\n name\n quantity\n price\n }\n }\n agent {\n name\n }\n }\n }\n" +): (typeof documents)["\n \n \n \n \n query getOrderByPK($id: uuid!) {\n orders_by_pk(id: $id) {\n ...OrderCoreFields\n ...OrderItemsAggregate\n ...AllStatusHistories\n business {\n ...OrderBusinessFields\n }\n order_items {\n id\n product {\n id\n name\n quantity\n price\n }\n }\n agent {\n name\n }\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ @@ -538,8 +538,8 @@ export function gql( * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: "\n \n query GetZonesById($id: uuid!) {\n zones(where: { id: {_eq: $id } }) {\n ...ZoneFields\n }\n }\n" -): (typeof documents)["\n \n query GetZonesById($id: uuid!) {\n zones(where: { id: {_eq: $id } }) {\n ...ZoneFields\n }\n }\n"]; + source: "\n \n query GetZonesById($id: uuid!) {\n zones(where: { id: { _eq: $id } }) {\n ...ZoneFields\n }\n }\n" +): (typeof documents)["\n \n query GetZonesById($id: uuid!) {\n zones(where: { id: { _eq: $id } }) {\n ...ZoneFields\n }\n }\n"]; export function gql(source: string) { return (documents as any)[source] ?? {}; diff --git a/packages/lib/graphql/__generated__/graphql.ts b/packages/lib/graphql/__generated__/graphql.ts index 73e1d81f..b93b3b71 100644 --- a/packages/lib/graphql/__generated__/graphql.ts +++ b/packages/lib/graphql/__generated__/graphql.ts @@ -36,6 +36,29 @@ export type Scalars = { uuid: { input: any; output: any }; }; +export type AccountBalanceResponse = { + __typename?: "AccountBalanceResponse"; + availableBalance?: Maybe; + currency?: Maybe; +}; + +export type Address = { + __typename?: "Address"; + location?: Maybe; + placeId?: Maybe; + types?: Maybe>>; +}; + +export type BasicUserInfoResponse = { + __typename?: "BasicUserInfoResponse"; + birthdate?: Maybe; + family_name?: Maybe; + gender?: Maybe; + given_name?: Maybe; + locale?: Maybe; + status?: Maybe; +}; + /** Boolean expression to compare columns of type "Boolean". All fields are combined with logical 'AND'. */ export type Boolean_Array_Comparison_Exp = { /** is the array contained in the given array value */ @@ -66,6 +89,37 @@ export type Boolean_Comparison_Exp = { _nin?: InputMaybe>; }; +export type CreateAccessTokenResponse = { + __typename?: "CreateAccessTokenResponse"; + expires_in?: Maybe; + token?: Maybe; +}; + +export type DirectionLeg = { + __typename?: "DirectionLeg"; + distance?: Maybe; + duration?: Maybe; +}; + +export type DirectionRoute = { + __typename?: "DirectionRoute"; + legs?: Maybe>>; + name?: Maybe; +}; + +export type Directions = { + __typename?: "Directions"; + endLocation?: Maybe; + routes?: Maybe; + startLocation?: Maybe; +}; + +export type GeoCoords = { + __typename?: "GeoCoords"; + lat?: Maybe; + lng?: Maybe; +}; + /** Boolean expression to compare columns of type "Int". All fields are combined with logical 'AND'. */ export type Int_Comparison_Exp = { _eq?: InputMaybe; @@ -79,6 +133,25 @@ export type Int_Comparison_Exp = { _nin?: InputMaybe>; }; +export type LegDistance = { + __typename?: "LegDistance"; + text?: Maybe; + value?: Maybe; +}; + +export type LegDuration = { + __typename?: "LegDuration"; + text?: Maybe; + value?: Maybe; +}; + +export type LocationByCoords = { + __typename?: "LocationByCoords"; + location?: Maybe; + placeId?: Maybe; + types?: Maybe>>; +}; + export type OrderStatusHistoryOutput = { __typename?: "OrderStatusHistoryOutput"; created_at: Scalars["timestamptz"]["output"]; @@ -87,6 +160,66 @@ export type OrderStatusHistoryOutput = { status: Scalars["String"]["output"]; }; +export type PayerInput = { + partyId: Scalars["String"]["input"]; + partyIdType: Scalars["String"]["input"]; +}; + +export type PaymentStatusResponse = { + __typename?: "PaymentStatusResponse"; + financialTransactionId?: Maybe; + reason?: Maybe; + referenceId?: Maybe; + status?: Maybe; +}; + +export type Places = { + __typename?: "Places"; + address?: Maybe; + lat?: Maybe; + lng?: Maybe; + location?: Maybe; + name?: Maybe; +}; + +export type PreApprovalStatusResponse = { + __typename?: "PreApprovalStatusResponse"; + expirationDateTime?: Maybe; + payer?: Maybe; + payerCurrency?: Maybe; + payerMessage?: Maybe; + reason?: Maybe; + status?: Maybe; +}; + +export type RequestToPayInput = { + amount: Scalars["Float"]["input"]; + currency?: InputMaybe; + externalId: Scalars["String"]["input"]; + payeeNote?: InputMaybe; + payer: PayerInput; + payerMessage?: InputMaybe; +}; + +export type RequestToPayResponse = { + __typename?: "RequestToPayResponse"; + message?: Maybe; + status?: Maybe; +}; + +export type RequestToPayTransactionStatusResponse = { + __typename?: "RequestToPayTransactionStatusResponse"; + amount?: Maybe; + currency?: Maybe; + externalId?: Maybe; + financialTransactionId?: Maybe; + payeeNote?: Maybe; + payer?: Maybe; + payerMessage?: Maybe; + reason?: Maybe; + status?: Maybe; +}; + /** Boolean expression to compare columns of type "String". All fields are combined with logical 'AND'. */ export type String_Comparison_Exp = { _eq?: InputMaybe; @@ -120,6 +253,34 @@ export type String_Comparison_Exp = { _similar?: InputMaybe; }; +export type UserInfoWithConsentResponse = { + __typename?: "UserInfoWithConsentResponse"; + active?: Maybe; + address?: Maybe; + birthdate?: Maybe; + city_of_birth?: Maybe; + country_of_birth?: Maybe; + credit_score?: Maybe; + email?: Maybe; + email_verified?: Maybe; + employer_name?: Maybe; + family_name?: Maybe; + gender?: Maybe; + given_name?: Maybe; + identification_type?: Maybe; + identification_value?: Maybe; + locale?: Maybe; + middle_name?: Maybe; + name?: Maybe; + occupation?: Maybe; + phone_number?: Maybe; + phone_number_verified?: Maybe; + region_of_birth?: Maybe; + status?: Maybe; + sub?: Maybe; + updated_at?: Maybe; +}; + /** columns and relationships of "accounts" */ export type Accounts = { __typename?: "accounts"; @@ -3391,6 +3552,10 @@ export type Delivery_Request = { courierId?: Maybe; created_at: Scalars["timestamptz"]["output"]; delivery_method?: Maybe; + /** An array relationship */ + delivery_request_orders: Array; + /** An aggregate relationship */ + delivery_request_orders_aggregate: Delivery_Request_Orders_Aggregate; id: Scalars["uuid"]["output"]; /** An object relationship */ request_status?: Maybe; @@ -3398,6 +3563,24 @@ export type Delivery_Request = { updated_at?: Maybe; }; +/** columns and relationships of "delivery_request" */ +export type Delivery_RequestDelivery_Request_OrdersArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + +/** columns and relationships of "delivery_request" */ +export type Delivery_RequestDelivery_Request_Orders_AggregateArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + /** aggregated selection of "delivery_request" */ export type Delivery_Request_Aggregate = { __typename?: "delivery_request_aggregate"; @@ -3405,6 +3588,17 @@ export type Delivery_Request_Aggregate = { nodes: Array; }; +export type Delivery_Request_Aggregate_Bool_Exp = { + count?: InputMaybe; +}; + +export type Delivery_Request_Aggregate_Bool_Exp_Count = { + arguments?: InputMaybe>; + distinct?: InputMaybe; + filter?: InputMaybe; + predicate: Int_Comparison_Exp; +}; + /** aggregate fields of "delivery_request" */ export type Delivery_Request_Aggregate_Fields = { __typename?: "delivery_request_aggregate_fields"; @@ -3419,6 +3613,20 @@ export type Delivery_Request_Aggregate_FieldsCountArgs = { distinct?: InputMaybe; }; +/** order by aggregate values of table "delivery_request" */ +export type Delivery_Request_Aggregate_Order_By = { + count?: InputMaybe; + max?: InputMaybe; + min?: InputMaybe; +}; + +/** input type for inserting array relation for remote table "delivery_request" */ +export type Delivery_Request_Arr_Rel_Insert_Input = { + data: Array; + /** upsert condition */ + on_conflict?: InputMaybe; +}; + /** Boolean expression to filter rows from the table "delivery_request". All fields are combined with a logical 'AND'. */ export type Delivery_Request_Bool_Exp = { _and?: InputMaybe>; @@ -3427,6 +3635,8 @@ export type Delivery_Request_Bool_Exp = { courierId?: InputMaybe; created_at?: InputMaybe; delivery_method?: InputMaybe; + delivery_request_orders?: InputMaybe; + delivery_request_orders_aggregate?: InputMaybe; id?: InputMaybe; request_status?: InputMaybe; status?: InputMaybe; @@ -3444,6 +3654,7 @@ export type Delivery_Request_Insert_Input = { courierId?: InputMaybe; created_at?: InputMaybe; delivery_method?: InputMaybe; + delivery_request_orders?: InputMaybe; id?: InputMaybe; request_status?: InputMaybe; status?: InputMaybe; @@ -3460,6 +3671,15 @@ export type Delivery_Request_Max_Fields = { updated_at?: Maybe; }; +/** order by max() on columns of table "delivery_request" */ +export type Delivery_Request_Max_Order_By = { + courierId?: InputMaybe; + created_at?: InputMaybe; + delivery_method?: InputMaybe; + id?: InputMaybe; + updated_at?: InputMaybe; +}; + /** aggregate min on columns */ export type Delivery_Request_Min_Fields = { __typename?: "delivery_request_min_fields"; @@ -3470,6 +3690,15 @@ export type Delivery_Request_Min_Fields = { updated_at?: Maybe; }; +/** order by min() on columns of table "delivery_request" */ +export type Delivery_Request_Min_Order_By = { + courierId?: InputMaybe; + created_at?: InputMaybe; + delivery_method?: InputMaybe; + id?: InputMaybe; + updated_at?: InputMaybe; +}; + /** response of any mutation on the table "delivery_request" */ export type Delivery_Request_Mutation_Response = { __typename?: "delivery_request_mutation_response"; @@ -3479,6 +3708,13 @@ export type Delivery_Request_Mutation_Response = { returning: Array; }; +/** input type for inserting object relation for remote table "delivery_request" */ +export type Delivery_Request_Obj_Rel_Insert_Input = { + data: Delivery_Request_Insert_Input; + /** upsert condition */ + on_conflict?: InputMaybe; +}; + /** on_conflict condition type for table "delivery_request" */ export type Delivery_Request_On_Conflict = { constraint: Delivery_Request_Constraint; @@ -3491,6 +3727,7 @@ export type Delivery_Request_Order_By = { courierId?: InputMaybe; created_at?: InputMaybe; delivery_method?: InputMaybe; + delivery_request_orders_aggregate?: InputMaybe; id?: InputMaybe; request_status?: InputMaybe; status?: InputMaybe; @@ -3501,8 +3738,12 @@ export type Delivery_Request_Order_By = { export type Delivery_Request_Orders = { __typename?: "delivery_request_orders"; created_at: Scalars["timestamptz"]["output"]; + /** An object relationship */ + delivery_request: Delivery_Request; delivery_request_id: Scalars["uuid"]["output"]; id: Scalars["uuid"]["output"]; + /** An object relationship */ + order: Orders; order_id: Scalars["uuid"]["output"]; }; @@ -3513,6 +3754,17 @@ export type Delivery_Request_Orders_Aggregate = { nodes: Array; }; +export type Delivery_Request_Orders_Aggregate_Bool_Exp = { + count?: InputMaybe; +}; + +export type Delivery_Request_Orders_Aggregate_Bool_Exp_Count = { + arguments?: InputMaybe>; + distinct?: InputMaybe; + filter?: InputMaybe; + predicate: Int_Comparison_Exp; +}; + /** aggregate fields of "delivery_request_orders" */ export type Delivery_Request_Orders_Aggregate_Fields = { __typename?: "delivery_request_orders_aggregate_fields"; @@ -3527,14 +3779,30 @@ export type Delivery_Request_Orders_Aggregate_FieldsCountArgs = { distinct?: InputMaybe; }; +/** order by aggregate values of table "delivery_request_orders" */ +export type Delivery_Request_Orders_Aggregate_Order_By = { + count?: InputMaybe; + max?: InputMaybe; + min?: InputMaybe; +}; + +/** input type for inserting array relation for remote table "delivery_request_orders" */ +export type Delivery_Request_Orders_Arr_Rel_Insert_Input = { + data: Array; + /** upsert condition */ + on_conflict?: InputMaybe; +}; + /** Boolean expression to filter rows from the table "delivery_request_orders". All fields are combined with a logical 'AND'. */ export type Delivery_Request_Orders_Bool_Exp = { _and?: InputMaybe>; _not?: InputMaybe; _or?: InputMaybe>; created_at?: InputMaybe; + delivery_request?: InputMaybe; delivery_request_id?: InputMaybe; id?: InputMaybe; + order?: InputMaybe; order_id?: InputMaybe; }; @@ -3547,8 +3815,10 @@ export enum Delivery_Request_Orders_Constraint { /** input type for inserting data into table "delivery_request_orders" */ export type Delivery_Request_Orders_Insert_Input = { created_at?: InputMaybe; + delivery_request?: InputMaybe; delivery_request_id?: InputMaybe; id?: InputMaybe; + order?: InputMaybe; order_id?: InputMaybe; }; @@ -3561,6 +3831,14 @@ export type Delivery_Request_Orders_Max_Fields = { order_id?: Maybe; }; +/** order by max() on columns of table "delivery_request_orders" */ +export type Delivery_Request_Orders_Max_Order_By = { + created_at?: InputMaybe; + delivery_request_id?: InputMaybe; + id?: InputMaybe; + order_id?: InputMaybe; +}; + /** aggregate min on columns */ export type Delivery_Request_Orders_Min_Fields = { __typename?: "delivery_request_orders_min_fields"; @@ -3570,6 +3848,14 @@ export type Delivery_Request_Orders_Min_Fields = { order_id?: Maybe; }; +/** order by min() on columns of table "delivery_request_orders" */ +export type Delivery_Request_Orders_Min_Order_By = { + created_at?: InputMaybe; + delivery_request_id?: InputMaybe; + id?: InputMaybe; + order_id?: InputMaybe; +}; + /** response of any mutation on the table "delivery_request_orders" */ export type Delivery_Request_Orders_Mutation_Response = { __typename?: "delivery_request_orders_mutation_response"; @@ -3589,8 +3875,10 @@ export type Delivery_Request_Orders_On_Conflict = { /** Ordering options when selecting data from "delivery_request_orders". */ export type Delivery_Request_Orders_Order_By = { created_at?: InputMaybe; + delivery_request?: InputMaybe; delivery_request_id?: InputMaybe; id?: InputMaybe; + order?: InputMaybe; order_id?: InputMaybe; }; @@ -3688,9 +3976,31 @@ export type Delivery_Request_Set_Input = { /** columns and relationships of "delivery_request_status" */ export type Delivery_Request_Status = { __typename?: "delivery_request_status"; + /** An array relationship */ + delivery_requests: Array; + /** An aggregate relationship */ + delivery_requests_aggregate: Delivery_Request_Aggregate; status: Scalars["String"]["output"]; }; +/** columns and relationships of "delivery_request_status" */ +export type Delivery_Request_StatusDelivery_RequestsArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + +/** columns and relationships of "delivery_request_status" */ +export type Delivery_Request_StatusDelivery_Requests_AggregateArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + /** aggregated selection of "delivery_request_status" */ export type Delivery_Request_Status_Aggregate = { __typename?: "delivery_request_status_aggregate"; @@ -3717,6 +4027,8 @@ export type Delivery_Request_Status_Bool_Exp = { _and?: InputMaybe>; _not?: InputMaybe; _or?: InputMaybe>; + delivery_requests?: InputMaybe; + delivery_requests_aggregate?: InputMaybe; status?: InputMaybe; }; @@ -3744,6 +4056,7 @@ export type Delivery_Request_Status_Enum_Comparison_Exp = { /** input type for inserting data into table "delivery_request_status" */ export type Delivery_Request_Status_Insert_Input = { + delivery_requests?: InputMaybe; status?: InputMaybe; }; @@ -3784,6 +4097,7 @@ export type Delivery_Request_Status_On_Conflict = { /** Ordering options when selecting data from "delivery_request_status". */ export type Delivery_Request_Status_Order_By = { + delivery_requests_aggregate?: InputMaybe; status?: InputMaybe; }; @@ -4745,6 +5059,7 @@ export type Mutation_Root = { __typename?: "mutation_root"; /** add_order_status_history */ add_order_status_history?: Maybe; + createAccessToken?: Maybe; /** delete data from the table: "accounts" */ delete_accounts?: Maybe; /** delete single row from the table: "accounts" */ @@ -5095,6 +5410,7 @@ export type Mutation_Root = { insert_zones?: Maybe; /** insert a single row into the table: "zones" */ insert_zones_one?: Maybe; + requestToPay?: Maybe; /** update data of the table: "accounts" */ update_accounts?: Maybe; /** update single row of the table: "accounts" */ @@ -6374,6 +6690,11 @@ export type Mutation_RootInsert_Zones_OneArgs = { on_conflict?: InputMaybe; }; +/** mutation root */ +export type Mutation_RootRequestToPayArgs = { + object?: InputMaybe; +}; + /** mutation root */ export type Mutation_RootUpdate_AccountsArgs = { _inc?: InputMaybe; @@ -7841,12 +8162,34 @@ export type Order_Preference_Updates = { export type Order_Status = { __typename?: "order_status"; /** An array relationship */ + order_status_histories: Array; + /** An aggregate relationship */ + order_status_histories_aggregate: Order_Status_History_Aggregate; + /** An array relationship */ orders: Array; /** An aggregate relationship */ orders_aggregate: Orders_Aggregate; status: Scalars["String"]["output"]; }; +/** columns and relationships of "order_status" */ +export type Order_StatusOrder_Status_HistoriesArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + +/** columns and relationships of "order_status" */ +export type Order_StatusOrder_Status_Histories_AggregateArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + /** columns and relationships of "order_status" */ export type Order_StatusOrdersArgs = { distinct_on?: InputMaybe>; @@ -7891,6 +8234,8 @@ export type Order_Status_Bool_Exp = { _and?: InputMaybe>; _not?: InputMaybe; _or?: InputMaybe>; + order_status_histories?: InputMaybe; + order_status_histories_aggregate?: InputMaybe; orders?: InputMaybe; orders_aggregate?: InputMaybe; status?: InputMaybe; @@ -7925,7 +8270,11 @@ export type Order_Status_History = { __typename?: "order_status_history"; created_at: Scalars["timestamptz"]["output"]; id: Scalars["uuid"]["output"]; + /** An object relationship */ + order: Orders; order_id: Scalars["uuid"]["output"]; + /** An object relationship */ + order_status: Order_Status; status: Order_Status_Enum; }; @@ -7982,7 +8331,9 @@ export type Order_Status_History_Bool_Exp = { _or?: InputMaybe>; created_at?: InputMaybe; id?: InputMaybe; + order?: InputMaybe; order_id?: InputMaybe; + order_status?: InputMaybe; status?: InputMaybe; }; @@ -7996,7 +8347,9 @@ export enum Order_Status_History_Constraint { export type Order_Status_History_Insert_Input = { created_at?: InputMaybe; id?: InputMaybe; + order?: InputMaybe; order_id?: InputMaybe; + order_status?: InputMaybe; status?: InputMaybe; }; @@ -8050,7 +8403,9 @@ export type Order_Status_History_On_Conflict = { export type Order_Status_History_Order_By = { created_at?: InputMaybe; id?: InputMaybe; + order?: InputMaybe; order_id?: InputMaybe; + order_status?: InputMaybe; status?: InputMaybe; }; @@ -8116,6 +8471,7 @@ export type Order_Status_History_Updates = { /** input type for inserting data into table "order_status" */ export type Order_Status_Insert_Input = { + order_status_histories?: InputMaybe; orders?: InputMaybe; status?: InputMaybe; }; @@ -8141,6 +8497,13 @@ export type Order_Status_Mutation_Response = { returning: Array; }; +/** input type for inserting object relation for remote table "order_status" */ +export type Order_Status_Obj_Rel_Insert_Input = { + data: Order_Status_Insert_Input; + /** upsert condition */ + on_conflict?: InputMaybe; +}; + /** on_conflict condition type for table "order_status" */ export type Order_Status_On_Conflict = { constraint: Order_Status_Constraint; @@ -8150,6 +8513,7 @@ export type Order_Status_On_Conflict = { /** Ordering options when selecting data from "order_status". */ export type Order_Status_Order_By = { + order_status_histories_aggregate?: InputMaybe; orders_aggregate?: InputMaybe; status?: InputMaybe; }; @@ -8417,6 +8781,10 @@ export type Orders = { deliveries: Array; /** An aggregate relationship */ deliveries_aggregate: Delivery_Aggregate; + /** An array relationship */ + delivery_request_orders: Array; + /** An aggregate relationship */ + delivery_request_orders_aggregate: Delivery_Request_Orders_Aggregate; destination?: Maybe; fulfillment_type?: Maybe; id: Scalars["uuid"]["output"]; @@ -8427,6 +8795,8 @@ export type Orders = { order_items: Array; /** An aggregate relationship */ order_items_aggregate: Order_Item_Aggregate; + /** An object relationship */ + order_status?: Maybe; /** An array relationship */ order_suppliers: Array; /** An aggregate relationship */ @@ -8458,6 +8828,24 @@ export type OrdersDeliveries_AggregateArgs = { where?: InputMaybe; }; +/** columns and relationships of "orders" */ +export type OrdersDelivery_Request_OrdersArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + +/** columns and relationships of "orders" */ +export type OrdersDelivery_Request_Orders_AggregateArgs = { + distinct_on?: InputMaybe>; + limit?: InputMaybe; + offset?: InputMaybe; + order_by?: InputMaybe>; + where?: InputMaybe; +}; + /** columns and relationships of "orders" */ export type OrdersOrder_ItemsArgs = { distinct_on?: InputMaybe>; @@ -8569,6 +8957,8 @@ export type Orders_Bool_Exp = { customerId?: InputMaybe; deliveries?: InputMaybe; deliveries_aggregate?: InputMaybe; + delivery_request_orders?: InputMaybe; + delivery_request_orders_aggregate?: InputMaybe; destination?: InputMaybe; fulfillment_type?: InputMaybe; id?: InputMaybe; @@ -8576,6 +8966,7 @@ export type Orders_Bool_Exp = { order_fulfillment_type?: InputMaybe; order_items?: InputMaybe; order_items_aggregate?: InputMaybe; + order_status?: InputMaybe; order_suppliers?: InputMaybe; order_suppliers_aggregate?: InputMaybe; origin?: InputMaybe; @@ -8598,12 +8989,14 @@ export type Orders_Insert_Input = { created_at?: InputMaybe; customerId?: InputMaybe; deliveries?: InputMaybe; + delivery_request_orders?: InputMaybe; destination?: InputMaybe; fulfillment_type?: InputMaybe; id?: InputMaybe; orderId?: InputMaybe; order_fulfillment_type?: InputMaybe; order_items?: InputMaybe; + order_status?: InputMaybe; order_suppliers?: InputMaybe; origin?: InputMaybe; processedBy?: InputMaybe; @@ -8687,12 +9080,14 @@ export type Orders_Order_By = { created_at?: InputMaybe; customerId?: InputMaybe; deliveries_aggregate?: InputMaybe; + delivery_request_orders_aggregate?: InputMaybe; destination?: InputMaybe; fulfillment_type?: InputMaybe; id?: InputMaybe; orderId?: InputMaybe; order_fulfillment_type?: InputMaybe; order_items_aggregate?: InputMaybe; + order_status?: InputMaybe; order_suppliers_aggregate?: InputMaybe; origin?: InputMaybe; processedBy?: InputMaybe; @@ -9281,12 +9676,14 @@ export type Products_Variance_Order_By = { export type Query_Root = { __typename?: "query_root"; + accountBalance?: Maybe; /** An array relationship */ accounts: Array; /** An aggregate relationship */ accounts_aggregate: Accounts_Aggregate; /** fetch data from the table: "accounts" using primary key columns */ accounts_by_pk?: Maybe; + address?: Maybe
    ; /** An array relationship */ addresses: Array; /** An aggregate relationship */ @@ -9305,6 +9702,7 @@ export type Query_Root = { agent_type_aggregate: Agent_Type_Aggregate; /** fetch data from the table: "agent_type" using primary key columns */ agent_type_by_pk?: Maybe; + basicUserInfo?: Maybe; /** fetch data from the table: "business" */ business: Array; /** fetch aggregated fields from the table: "business" */ @@ -9329,6 +9727,7 @@ export type Query_Root = { contact_details_aggregate: Contact_Details_Aggregate; /** fetch data from the table: "contact_details" using primary key columns */ contact_details_by_pk?: Maybe; + coords?: Maybe; /** An array relationship */ courier_rides: Array; /** An aggregate relationship */ @@ -9365,9 +9764,9 @@ export type Query_Root = { delivery_request_aggregate: Delivery_Request_Aggregate; /** fetch data from the table: "delivery_request" using primary key columns */ delivery_request_by_pk?: Maybe; - /** fetch data from the table: "delivery_request_orders" */ + /** An array relationship */ delivery_request_orders: Array; - /** fetch aggregated fields from the table: "delivery_request_orders" */ + /** An aggregate relationship */ delivery_request_orders_aggregate: Delivery_Request_Orders_Aggregate; /** fetch data from the table: "delivery_request_orders" using primary key columns */ delivery_request_orders_by_pk?: Maybe; @@ -9383,6 +9782,7 @@ export type Query_Root = { delivery_status_aggregate: Delivery_Status_Aggregate; /** fetch data from the table: "delivery_status" using primary key columns */ delivery_status_by_pk?: Maybe; + directions?: Maybe; /** fetch data from the table: "geography_columns" */ geography_columns: Array; /** fetch aggregated fields from the table: "geography_columns" */ @@ -9439,6 +9839,9 @@ export type Query_Root = { orders_aggregate: Orders_Aggregate; /** fetch data from the table: "orders" using primary key columns */ orders_by_pk?: Maybe; + paymentStatus?: Maybe; + places?: Maybe>>; + preApprovalStatus?: Maybe; /** An array relationship */ products: Array; /** An aggregate relationship */ @@ -9457,6 +9860,7 @@ export type Query_Root = { reports_aggregate: Reports_Aggregate; /** fetch data from the table: "reports" using primary key columns */ reports_by_pk?: Maybe; + requestToPayTransactionStatus?: Maybe; /** fetch data from the table: "ride_status" */ ride_status: Array; /** fetch aggregated fields from the table: "ride_status" */ @@ -9505,6 +9909,7 @@ export type Query_Root = { suppliers_categories_aggregate: Suppliers_Categories_Aggregate; /** fetch data from the table: "suppliers_categories" using primary key columns */ suppliers_categories_by_pk?: Maybe; + userInfoWithConsent?: Maybe; /** An array relationship */ user_invites: Array; /** An aggregate relationship */ @@ -9569,6 +9974,11 @@ export type Query_RootAccounts_By_PkArgs = { id: Scalars["uuid"]["input"]; }; +export type Query_RootAddressArgs = { + lat: Scalars["Float"]["input"]; + lng: Scalars["Float"]["input"]; +}; + export type Query_RootAddressesArgs = { distinct_on?: InputMaybe>; limit?: InputMaybe; @@ -9629,6 +10039,10 @@ export type Query_RootAgent_Type_By_PkArgs = { type: Scalars["String"]["input"]; }; +export type Query_RootBasicUserInfoArgs = { + accountHolderMSISDN: Scalars["String"]["input"]; +}; + export type Query_RootBusinessArgs = { distinct_on?: InputMaybe>; limit?: InputMaybe; @@ -9709,6 +10123,10 @@ export type Query_RootContact_Details_By_PkArgs = { id: Scalars["uuid"]["input"]; }; +export type Query_RootCoordsArgs = { + address: Scalars["String"]["input"]; +}; + export type Query_RootCourier_RidesArgs = { distinct_on?: InputMaybe>; limit?: InputMaybe; @@ -9889,6 +10307,11 @@ export type Query_RootDelivery_Status_By_PkArgs = { status: Scalars["String"]["input"]; }; +export type Query_RootDirectionsArgs = { + destination: Scalars["String"]["input"]; + origin: Scalars["String"]["input"]; +}; + export type Query_RootGeography_ColumnsArgs = { distinct_on?: InputMaybe>; limit?: InputMaybe; @@ -10081,6 +10504,19 @@ export type Query_RootOrders_By_PkArgs = { id: Scalars["uuid"]["input"]; }; +export type Query_RootPaymentStatusArgs = { + referenceId: Scalars["String"]["input"]; +}; + +export type Query_RootPlacesArgs = { + lat: Scalars["Float"]["input"]; + lng: Scalars["Float"]["input"]; +}; + +export type Query_RootPreApprovalStatusArgs = { + referenceId: Scalars["String"]["input"]; +}; + export type Query_RootProductsArgs = { distinct_on?: InputMaybe>; limit?: InputMaybe; @@ -10141,6 +10577,10 @@ export type Query_RootReports_By_PkArgs = { id: Scalars["uuid"]["input"]; }; +export type Query_RootRequestToPayTransactionStatusArgs = { + referenceId: Scalars["String"]["input"]; +}; + export type Query_RootRide_StatusArgs = { distinct_on?: InputMaybe>; limit?: InputMaybe; @@ -11634,9 +12074,9 @@ export type Subscription_Root = { delivery_request_aggregate: Delivery_Request_Aggregate; /** fetch data from the table: "delivery_request" using primary key columns */ delivery_request_by_pk?: Maybe; - /** fetch data from the table: "delivery_request_orders" */ + /** An array relationship */ delivery_request_orders: Array; - /** fetch aggregated fields from the table: "delivery_request_orders" */ + /** An aggregate relationship */ delivery_request_orders_aggregate: Delivery_Request_Orders_Aggregate; /** fetch data from the table: "delivery_request_orders" using primary key columns */ delivery_request_orders_by_pk?: Maybe; @@ -16045,13 +16485,39 @@ export type DeliveryRequestFieldsFragment = { __typename?: "delivery_request"; id: any; created_at: any; + delivery_method?: string | null; + status?: Delivery_Request_Status_Enum | null; + courierId?: any | null; + updated_at?: any | null; }; export type GetDeliveriesQueryVariables = Exact<{ [key: string]: never }>; export type GetDeliveriesQuery = { __typename?: "query_root"; - delivery: Array<{ __typename?: "delivery"; id: any; created_at: any }>; + delivery: Array<{ + __typename?: "delivery"; + id: any; + created_at: any; + order: { + __typename?: "orders"; + customerId?: any | null; + created_at: any; + order_items: Array<{ + __typename?: "order_item"; + product: { + __typename?: "products"; + created_at: any; + description?: string | null; + discount?: number | null; + name?: string | null; + price?: number | null; + quantity: number; + inStock: boolean; + }; + }>; + }; + }>; delivery_aggregate: { __typename?: "delivery_aggregate"; aggregate?: { @@ -16067,7 +16533,30 @@ export type GetDeliveryByPkQueryVariables = Exact<{ export type GetDeliveryByPkQuery = { __typename?: "query_root"; - delivery: Array<{ __typename?: "delivery"; id: any; created_at: any }>; + delivery: Array<{ + __typename?: "delivery"; + id: any; + created_at: any; + order: { + __typename?: "orders"; + customerId?: any | null; + created_at: any; + status?: Order_Status_Enum | null; + order_items: Array<{ + __typename?: "order_item"; + product: { + __typename?: "products"; + created_at: any; + description?: string | null; + discount?: number | null; + name?: string | null; + price?: number | null; + quantity: number; + inStock: boolean; + }; + }>; + }; + }>; }; export type GetDeliveriesByCourierQueryVariables = Exact<{ @@ -16076,17 +16565,67 @@ export type GetDeliveriesByCourierQueryVariables = Exact<{ export type GetDeliveriesByCourierQuery = { __typename?: "query_root"; - delivery: Array<{ __typename?: "delivery"; id: any; created_at: any }>; -}; - -export type GetDeliveryRequestsQueryVariables = Exact<{ [key: string]: never }>; - -export type GetDeliveryRequestsQuery = { - __typename?: "query_root"; - delivery_request: Array<{ + delivery: Array<{ + __typename?: "delivery"; + id: any; + created_at: any; + order: { + __typename?: "orders"; + customerId?: any | null; + created_at: any; + order_items: Array<{ + __typename?: "order_item"; + product: { + __typename?: "products"; + created_at: any; + description?: string | null; + discount?: number | null; + name?: string | null; + price?: number | null; + quantity: number; + inStock: boolean; + }; + }>; + }; + }>; +}; + +export type GetDeliveryRequestsQueryVariables = Exact<{ [key: string]: never }>; + +export type GetDeliveryRequestsQuery = { + __typename?: "query_root"; + delivery_request: Array<{ __typename?: "delivery_request"; id: any; created_at: any; + delivery_method?: string | null; + status?: Delivery_Request_Status_Enum | null; + courierId?: any | null; + updated_at?: any | null; + delivery_request_orders: Array<{ + __typename?: "delivery_request_orders"; + id: any; + order_id: any; + order: { + __typename?: "orders"; + id: any; + order_items: Array<{ + __typename?: "order_item"; + id: any; + product: { + __typename?: "products"; + id: any; + description?: string | null; + discount?: number | null; + inStock: boolean; + mainImage?: string | null; + name?: string | null; + quantity: number; + price?: number | null; + }; + }>; + }; + }>; }>; delivery_request_aggregate: { __typename?: "delivery_request_aggregate"; @@ -16107,6 +16646,34 @@ export type GetDeliveryRequestByPkQuery = { __typename?: "delivery_request"; id: any; created_at: any; + delivery_method?: string | null; + status?: Delivery_Request_Status_Enum | null; + courierId?: any | null; + updated_at?: any | null; + delivery_request_orders: Array<{ + __typename?: "delivery_request_orders"; + id: any; + order_id: any; + order: { + __typename?: "orders"; + id: any; + order_items: Array<{ + __typename?: "order_item"; + id: any; + product: { + __typename?: "products"; + id: any; + description?: string | null; + discount?: number | null; + inStock: boolean; + mainImage?: string | null; + name?: string | null; + quantity: number; + price?: number | null; + }; + }>; + }; + }>; }>; }; @@ -16120,6 +16687,10 @@ export type GetDeliveryRequestByCourierQuery = { __typename?: "delivery_request"; id: any; created_at: any; + delivery_method?: string | null; + status?: Delivery_Request_Status_Enum | null; + courierId?: any | null; + updated_at?: any | null; }>; }; @@ -16225,6 +16796,13 @@ export type GetOrderByPkQuery = { customerId?: any | null; origin?: string | null; status?: Order_Status_Enum | null; + business?: { + __typename?: "business"; + id: any; + contactName?: string | null; + phoneNumber?: string | null; + name?: string | null; + } | null; order_items: Array<{ __typename?: "order_item"; id: any; @@ -16823,6 +17401,11 @@ export const DeliveryRequestFieldsFragmentDoc = { selections: [ { kind: "Field", name: { kind: "Name", value: "id" } }, { kind: "Field", name: { kind: "Name", value: "created_at" } }, + { kind: "Field", name: { kind: "Name", value: "delivery_method" } }, + { kind: "Field", name: { kind: "Name", value: "status" } }, + { kind: "Field", name: { kind: "Name", value: "courierId" } }, + { kind: "Field", name: { kind: "Name", value: "created_at" } }, + { kind: "Field", name: { kind: "Name", value: "updated_at" } }, ], }, }, @@ -18871,6 +19454,72 @@ export const GetDeliveriesDocument = { kind: "FragmentSpread", name: { kind: "Name", value: "DeliveryFields" }, }, + { + kind: "Field", + name: { kind: "Name", value: "order" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "customerId" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "created_at" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "order_items" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "product" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "created_at" }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "description", + }, + }, + { + kind: "Field", + name: { kind: "Name", value: "discount" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "name" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "price" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "quantity" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "inStock" }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, ], }, }, @@ -18986,6 +19635,76 @@ export const GetDeliveryByPkDocument = { kind: "FragmentSpread", name: { kind: "Name", value: "DeliveryFields" }, }, + { + kind: "Field", + name: { kind: "Name", value: "order" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "customerId" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "created_at" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "status" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "order_items" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "product" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "created_at" }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "description", + }, + }, + { + kind: "Field", + name: { kind: "Name", value: "discount" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "name" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "price" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "quantity" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "inStock" }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, ], }, }, @@ -19073,6 +19792,72 @@ export const GetDeliveriesByCourierDocument = { kind: "FragmentSpread", name: { kind: "Name", value: "DeliveryFields" }, }, + { + kind: "Field", + name: { kind: "Name", value: "order" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "customerId" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "created_at" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "order_items" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "product" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "created_at" }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "description", + }, + }, + { + kind: "Field", + name: { kind: "Name", value: "discount" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "name" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "price" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "quantity" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "inStock" }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, ], }, }, @@ -19119,6 +19904,105 @@ export const GetDeliveryRequestsDocument = { kind: "FragmentSpread", name: { kind: "Name", value: "DeliveryRequestFields" }, }, + { + kind: "Field", + name: { kind: "Name", value: "delivery_request_orders" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { kind: "Field", name: { kind: "Name", value: "id" } }, + { + kind: "Field", + name: { kind: "Name", value: "order_id" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "order" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "order_items" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "product" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "description", + }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "discount", + }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "inStock", + }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "mainImage", + }, + }, + { + kind: "Field", + name: { kind: "Name", value: "name" }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "quantity", + }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "price", + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, ], }, }, @@ -19171,6 +20055,11 @@ export const GetDeliveryRequestsDocument = { selections: [ { kind: "Field", name: { kind: "Name", value: "id" } }, { kind: "Field", name: { kind: "Name", value: "created_at" } }, + { kind: "Field", name: { kind: "Name", value: "delivery_method" } }, + { kind: "Field", name: { kind: "Name", value: "status" } }, + { kind: "Field", name: { kind: "Name", value: "courierId" } }, + { kind: "Field", name: { kind: "Name", value: "created_at" } }, + { kind: "Field", name: { kind: "Name", value: "updated_at" } }, ], }, }, @@ -19237,6 +20126,105 @@ export const GetDeliveryRequestByPkDocument = { kind: "FragmentSpread", name: { kind: "Name", value: "DeliveryRequestFields" }, }, + { + kind: "Field", + name: { kind: "Name", value: "delivery_request_orders" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { kind: "Field", name: { kind: "Name", value: "id" } }, + { + kind: "Field", + name: { kind: "Name", value: "order_id" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "order" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "order_items" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "product" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "id" }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "description", + }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "discount", + }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "inStock", + }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "mainImage", + }, + }, + { + kind: "Field", + name: { kind: "Name", value: "name" }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "quantity", + }, + }, + { + kind: "Field", + name: { + kind: "Name", + value: "price", + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, ], }, }, @@ -19255,6 +20243,11 @@ export const GetDeliveryRequestByPkDocument = { selections: [ { kind: "Field", name: { kind: "Name", value: "id" } }, { kind: "Field", name: { kind: "Name", value: "created_at" } }, + { kind: "Field", name: { kind: "Name", value: "delivery_method" } }, + { kind: "Field", name: { kind: "Name", value: "status" } }, + { kind: "Field", name: { kind: "Name", value: "courierId" } }, + { kind: "Field", name: { kind: "Name", value: "created_at" } }, + { kind: "Field", name: { kind: "Name", value: "updated_at" } }, ], }, }, @@ -19342,6 +20335,11 @@ export const GetDeliveryRequestByCourierDocument = { selections: [ { kind: "Field", name: { kind: "Name", value: "id" } }, { kind: "Field", name: { kind: "Name", value: "created_at" } }, + { kind: "Field", name: { kind: "Name", value: "delivery_method" } }, + { kind: "Field", name: { kind: "Name", value: "status" } }, + { kind: "Field", name: { kind: "Name", value: "courierId" } }, + { kind: "Field", name: { kind: "Name", value: "created_at" } }, + { kind: "Field", name: { kind: "Name", value: "updated_at" } }, ], }, }, @@ -19586,6 +20584,19 @@ export const GetOrderByPkDocument = { kind: "FragmentSpread", name: { kind: "Name", value: "AllStatusHistories" }, }, + { + kind: "Field", + name: { kind: "Name", value: "business" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "FragmentSpread", + name: { kind: "Name", value: "OrderBusinessFields" }, + }, + ], + }, + }, { kind: "Field", name: { kind: "Name", value: "order_items" }, @@ -19728,6 +20739,23 @@ export const GetOrderByPkDocument = { ], }, }, + { + kind: "FragmentDefinition", + name: { kind: "Name", value: "OrderBusinessFields" }, + typeCondition: { + kind: "NamedType", + name: { kind: "Name", value: "business" }, + }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { kind: "Field", name: { kind: "Name", value: "id" } }, + { kind: "Field", name: { kind: "Name", value: "contactName" } }, + { kind: "Field", name: { kind: "Name", value: "phoneNumber" } }, + { kind: "Field", name: { kind: "Name", value: "name" } }, + ], + }, + }, ], } as unknown as DocumentNode; export const GetOrderDeliveriesDocument = { diff --git a/packages/lib/graphql/queries/deliveries.ts b/packages/lib/graphql/queries/deliveries.ts index 3dab7763..136daf3f 100644 --- a/packages/lib/graphql/queries/deliveries.ts +++ b/packages/lib/graphql/queries/deliveries.ts @@ -57,6 +57,7 @@ export const FETCH_DELIVERY_BY_PK = gql` order { customerId created_at + status order_items { product { created_at diff --git a/packages/lib/hooks/couriers.tsx b/packages/lib/hooks/couriers.tsx index 659242c8..a32ddcb2 100644 --- a/packages/lib/hooks/couriers.tsx +++ b/packages/lib/hooks/couriers.tsx @@ -9,6 +9,8 @@ import { import { GetCouriersQuery, GetCouriersQueryVariables, + GetCouriersByPkQuery, + GetCouriersByPkQueryVariables, } from "@sahil/lib/graphql/__generated__/graphql"; export const useFetchCouriers = () => { @@ -25,7 +27,7 @@ export const useFetchCouriers = () => { }; export const useFetchCourierByPK = (id: string) => { - const { error, data, loading } = useQuery(FETCH_COURIER_BY_PK, { + const { error, data, loading } = useQuery(FETCH_COURIER_BY_PK, { variables: { id, }, diff --git a/packages/lib/hooks/deliveries.tsx b/packages/lib/hooks/deliveries.tsx index e417c29a..6f847553 100644 --- a/packages/lib/hooks/deliveries.tsx +++ b/packages/lib/hooks/deliveries.tsx @@ -8,39 +8,41 @@ import { FETCH_DELIVERY_REQUEST_BY_PK, } from "../graphql/queries/deliveries"; +import { GetDeliveriesQuery, GetDeliveriesQueryVariables, GetDeliveryByPkQuery, GetDeliveryByPkQueryVariables, GetDeliveriesByCourierQuery, GetDeliveriesByCourierQueryVariables, GetDeliveryRequestsQuery, GetDeliveryRequestsQueryVariables, GetDeliveryRequestByPkQuery, GetDeliveryRequestByPkQueryVariables, GetDeliveryRequestByCourierQuery, GetDeliveryRequestByCourierQueryVariables } from "../graphql/__generated__/graphql"; + export const useFetchDeliveries = () => { - const { loading, error, data } = useQuery(FETCH_DELIVERIES); + const { loading, error, data } = useQuery(FETCH_DELIVERIES); return { loading, error, data:data?.delivery }; }; export const useFetchDeliveryByPK = (id: string) => { - const { loading, error, data } = useQuery(FETCH_DELIVERY_BY_PK, { + const { loading, error, data } = useQuery(FETCH_DELIVERY_BY_PK, { variables: { id }, }); - return { loading, error, data: data?.delivery }; + return { loading, error, data: data?.delivery[0] }; }; export const useFetchDeliveriesByCourier = (courier_id: string) => { - const { loading, error, data } = useQuery(FETCH_DELIVERIES_BY_COURIER, { + const { loading, error, data } = useQuery(FETCH_DELIVERIES_BY_COURIER, { variables: { courier_id }, }); return { loading, error, data: data?.delivery }; }; export const useFetchDeliveryRequests = () => { - const { loading, error, data } = useQuery(FETCH_DELIVERY_REQUESTS); + const { loading, error, data } = useQuery(FETCH_DELIVERY_REQUESTS); return { loading, error, data: data?.delivery_request }; }; export const useFetchDeliveryRequestByPK = (id: string) => { - const { loading, error, data } = useQuery(FETCH_DELIVERY_REQUEST_BY_PK, { + const { loading, error, data } = useQuery(FETCH_DELIVERY_REQUEST_BY_PK, { variables: { id }, }); return { loading, error, data: data?.delivery_request[0] }; }; export const useFetchDeliveryRequestByCourier = (courier_id: string) => { - const { loading, error, data } = useQuery(FETCH_DELIVERY_REQUEST_BY_COURIER, { + const { loading, error, data } = useQuery(FETCH_DELIVERY_REQUEST_BY_COURIER, { variables: { courier_id }, }); return { loading, error, data: data?.delivery_request[0] }; diff --git a/packages/lib/hooks/orders.tsx b/packages/lib/hooks/orders.tsx index 57486d1e..c44ca9f6 100644 --- a/packages/lib/hooks/orders.tsx +++ b/packages/lib/hooks/orders.tsx @@ -12,6 +12,12 @@ import { import { GetOrdersQuery, GetOrdersQueryVariables, + GetOrderByPkQuery, + GetOrderByPkQueryVariables, + GetOrderDeliveriesQuery, + GetOrderDeliveriesQueryVariables, + GetOrdersStatsQuery, + GetOrdersStatsQueryVariables, } from "@sahil/lib/graphql/__generated__/graphql"; export const useFetchOrders = () => { @@ -28,7 +34,7 @@ export const useFetchOrders = () => { }; export const useFetchOrderByPK = (id: string) => { - const { error, data, loading } = useQuery(FETCH_ORDER_BY_PK, { + const { error, data, loading } = useQuery(FETCH_ORDER_BY_PK, { variables: { id, }, @@ -37,7 +43,7 @@ export const useFetchOrderByPK = (id: string) => { }; export const useFetchOrderDeliveriesByPK = (id: string) => { - const { error, data, loading } = useQuery(FETCH_ORDER_DELIVERIES, { + const { error, data, loading } = useQuery(FETCH_ORDER_DELIVERIES, { variables: { orderId: id, }, @@ -52,7 +58,7 @@ export const usePlaceBusinessOrder = () => { }; export const useGetOrdersStats = () => { - const { data, loading, error } = useQuery(FETCH_ORDERS_STATS); + const { data, loading, error } = useQuery(FETCH_ORDERS_STATS); return { error, ordersCount: data?.orders_aggregate?.aggregate, loading }; }; diff --git a/packages/lib/hooks/products.ts b/packages/lib/hooks/products.ts index 514a3c38..7b6031dd 100644 --- a/packages/lib/hooks/products.ts +++ b/packages/lib/hooks/products.ts @@ -1,6 +1,12 @@ import { useMutation, useQuery } from "@apollo/client"; import { FETCH_PRODUCTS } from "@sahil/lib/graphql"; +// graphql types +import { + GetProductsQuery, + GetProductsQueryVariables, +} from "@sahil/lib/graphql/__generated__/graphql"; + export const useFetchProducts = ({ limit = 10, offset = 0, @@ -8,7 +14,7 @@ export const useFetchProducts = ({ limit?: number; offset: number; }) => { - const { error, data, loading } = useQuery(FETCH_PRODUCTS, { + const { error, data, loading } = useQuery(FETCH_PRODUCTS, { variables: { limit, offset, diff --git a/packages/lib/hooks/users.tsx b/packages/lib/hooks/users.tsx index 85a6eb05..4aaeff73 100644 --- a/packages/lib/hooks/users.tsx +++ b/packages/lib/hooks/users.tsx @@ -1,12 +1,15 @@ import { useMutation, useQuery } from "@apollo/client"; import { GET_LATEST_USER_INVITE, + GET_USERS, INSERT_NEW_INVITE, // INSERT_NEW_USER, } from "@sahil/lib/graphql"; import { GetUserInvitesQuery, + GetUsersQuery, GetUserInvitesQueryVariables, + GetUsersQueryVariables, InsertNewInviteMutation, InsertNewInviteMutationVariables, } from "../graphql/__generated__/graphql"; @@ -33,3 +36,11 @@ export const useFetchUserInvites = () => { >(GET_LATEST_USER_INVITE); return { error, data: data?.user_invites, loading }; }; + +export const useFetchUsers = () => { + const { error, data, loading } = useQuery< + GetUsersQuery, + GetUsersQueryVariables + >(GET_USERS); + return { error, data: data?.users, loading }; +}; diff --git a/packages/ui/components/Navbar.tsx b/packages/ui/components/Navbar.tsx index cf288bd0..f24e3932 100644 --- a/packages/ui/components/Navbar.tsx +++ b/packages/ui/components/Navbar.tsx @@ -119,7 +119,6 @@ const Right = ({ tabIndex={0} className="menu menu-sm dropdown-content mt-3 z-10 p-2 shadow bg-base-100 rounded-box w-52 space-y-2" > -<<<<<<< Updated upstream
  • Quick Menu:

  • @@ -140,41 +139,9 @@ const Right = ({
  • +
  • diff --git a/yarn.lock b/yarn.lock index d4c68e6e..94526747 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4429,7 +4429,7 @@ escodegen@^2.1.0: optionalDependencies: source-map "~0.6.1" -eslint-config-next@14.2.3, eslint-config-next@^14.2.3: +eslint-config-next@^14.2.3: version "14.2.3" resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-14.2.3.tgz#2fb0f7c4eccda530a4b5054438162b2303786d4f" integrity sha512-ZkNztm3Q7hjqvB1rRlOX8P9E/cXRL9ajRcs8jufEtwMfTVYRqnmtnaSu57QqHyBlovMuiB8LEzfLBkh5RYV6Fg== @@ -6763,7 +6763,7 @@ next-auth@^4.24.7: preact-render-to-string "^5.1.19" uuid "^8.3.2" -next@14.2.3, next@^14.2.3: +next@^14.2.3: version "14.2.3" resolved "https://registry.yarnpkg.com/next/-/next-14.2.3.tgz#f117dd5d5f20c307e7b8e4f9c1c97d961008925d" integrity sha512-dowFkFTR8v79NPJO4QsBUtxv0g9BrS/phluVpMAt2ku7H+cbcBJlopXjkWlwxrk/xGqMemr7JkGPGemPrLLX7A== @@ -8590,7 +8590,7 @@ tailwindcss@3.3.3: resolve "^1.22.2" sucrase "^3.32.0" -tailwindcss@^3.3.0, tailwindcss@^3.4.1: +tailwindcss@^3.3.0: version "3.4.1" resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.4.1.tgz#f512ca5d1dd4c9503c7d3d28a968f1ad8f5c839d" integrity sha512-qAYmXRfk3ENzuPBakNK0SRrUDipP8NQnEY6772uDhflcQz5EhRdD7JNZxyrFHVQNCwULPBn6FNPp9brpO7ctcA== From 863211aff2fb14885567052cda16f48b44b16f71 Mon Sep 17 00:00:00 2001 From: eman-bfloat Date: Sat, 19 Oct 2024 14:08:02 +0300 Subject: [PATCH 6/9] feat: update agent navbar --- apps/agent/src/Layout/layout.tsx | 1 + .../Deliveries/ListDeliveryRequests.tsx | 6 ++--- packages/ui/components/List/List.tsx | 25 +++++++++++-------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/apps/agent/src/Layout/layout.tsx b/apps/agent/src/Layout/layout.tsx index c6141f7e..fbd9a357 100644 --- a/apps/agent/src/Layout/layout.tsx +++ b/apps/agent/src/Layout/layout.tsx @@ -46,6 +46,7 @@ export default function Layout({ children, ...props }: LayoutProps) { }; return ( <> + {session?.user && ( { const { loading, error, data: deliveryRequests } = useFetchDeliveryRequests(); - if (loading) return

    Loading...

    ; - if (error) return

    Error :(

    ; + if (error) return ; return (
    ( )} diff --git a/packages/ui/components/List/List.tsx b/packages/ui/components/List/List.tsx index 4f43dcc1..75c23c5c 100644 --- a/packages/ui/components/List/List.tsx +++ b/packages/ui/components/List/List.tsx @@ -3,13 +3,13 @@ import { useAutoAnimate } from "@formkit/auto-animate/react"; import { Card } from "../Card"; import type { ApolloError } from "@apollo/client"; import { ListEmptyState } from "./ListEmptyState"; +import { HiOutlineExclamationCircle } from "react-icons/hi2"; type ListProps = { data?: T[] | null; error?: ApolloError; loading?: boolean; renderItem: (item: T) => JSX.Element; - cols?: number; }; @@ -19,17 +19,23 @@ type ListAsyncResultProps = { }; export const ListErrorState: FC = ({ - heading, - message, + heading = "An error occurred", + message = "We're having trouble loading the data. Please try again later.", }) => ( -

    {message}

    -
    - - +
    + + + +

    {message}

    +
    + + +
    ); + export const ListLoadingState: FC = ({ heading = "Loading Data", message, @@ -51,9 +57,8 @@ export const List = ({ if (error) { return ( ); } From 0660ae6494218afa81423208a381ff3dc123c107 Mon Sep 17 00:00:00 2001 From: eman-bfloat Date: Sat, 19 Oct 2024 14:30:19 +0300 Subject: [PATCH 7/9] feat: typescript fixes --- .vscode/easycode.ignore | 14 ++++++++++++++ apps/agent/src/pages/couriers/[courierId].tsx | 6 +++--- .../components/CourierProfileOverview.tsx | 1 + packages/lib/hooks/couriers.tsx | 1 + packages/lib/hooks/deliveries.tsx | 6 +++--- packages/ui/components/Navbar.tsx | 19 ++++++++++++++++--- 6 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 .vscode/easycode.ignore diff --git a/.vscode/easycode.ignore b/.vscode/easycode.ignore new file mode 100644 index 00000000..7f86f293 --- /dev/null +++ b/.vscode/easycode.ignore @@ -0,0 +1,14 @@ +node_modules/ +dist/ +vendor/ +cache/ +.*/ +*.min.* +*.test.* +*.spec.* +*.bundle.* +*.bundle-min.* +*.log +infra/ +apps/website +apps/client \ No newline at end of file diff --git a/apps/agent/src/pages/couriers/[courierId].tsx b/apps/agent/src/pages/couriers/[courierId].tsx index 3f447c1f..7091d6b8 100644 --- a/apps/agent/src/pages/couriers/[courierId].tsx +++ b/apps/agent/src/pages/couriers/[courierId].tsx @@ -1,4 +1,5 @@ import { CourierProfileOverview } from "@sahil/features/Couriers/components/CourierProfileOverview"; +import { Couriers } from "@sahil/lib/graphql/__generated__/graphql"; import { useRouter } from "next/router"; import { useFetchCourierByPK } from "@sahil/lib/hooks/couriers"; @@ -23,11 +24,11 @@ export default function CourierPage() { return

    Loading...

    ; } + return ( - <>
    - +
    @@ -37,6 +38,5 @@ export default function CourierPage() {
    - ); } diff --git a/packages/features/Couriers/components/CourierProfileOverview.tsx b/packages/features/Couriers/components/CourierProfileOverview.tsx index 54d56495..27166ae2 100644 --- a/packages/features/Couriers/components/CourierProfileOverview.tsx +++ b/packages/features/Couriers/components/CourierProfileOverview.tsx @@ -7,6 +7,7 @@ type Props = { }; export const CourierProfileOverview: FC = ({ courier }) => { + console.log(courier) return (
    {courier?.avatar && } diff --git a/packages/lib/hooks/couriers.tsx b/packages/lib/hooks/couriers.tsx index a32ddcb2..339100bd 100644 --- a/packages/lib/hooks/couriers.tsx +++ b/packages/lib/hooks/couriers.tsx @@ -32,6 +32,7 @@ export const useFetchCourierByPK = (id: string) => { id, }, }); + console.log("data", data); return { error, data: data?.couriers_by_pk, loading }; }; diff --git a/packages/lib/hooks/deliveries.tsx b/packages/lib/hooks/deliveries.tsx index 6f847553..b4fd32e3 100644 --- a/packages/lib/hooks/deliveries.tsx +++ b/packages/lib/hooks/deliveries.tsx @@ -19,7 +19,7 @@ export const useFetchDeliveryByPK = (id: string) => { const { loading, error, data } = useQuery(FETCH_DELIVERY_BY_PK, { variables: { id }, }); - return { loading, error, data: data?.delivery[0] }; + return { loading, error, data: data?.delivery }; }; export const useFetchDeliveriesByCourier = (courier_id: string) => { @@ -38,12 +38,12 @@ export const useFetchDeliveryRequestByPK = (id: string) => { const { loading, error, data } = useQuery(FETCH_DELIVERY_REQUEST_BY_PK, { variables: { id }, }); - return { loading, error, data: data?.delivery_request[0] }; + return { loading, error, data: data?.delivery_request }; }; export const useFetchDeliveryRequestByCourier = (courier_id: string) => { const { loading, error, data } = useQuery(FETCH_DELIVERY_REQUEST_BY_COURIER, { variables: { courier_id }, }); - return { loading, error, data: data?.delivery_request[0] }; + return { loading, error, data: data?.delivery_request }; }; diff --git a/packages/ui/components/Navbar.tsx b/packages/ui/components/Navbar.tsx index f24e3932..492184f2 100644 --- a/packages/ui/components/Navbar.tsx +++ b/packages/ui/components/Navbar.tsx @@ -10,6 +10,7 @@ import { HiOutlineCog6Tooth, HiOutlineBell, } from "react-icons/hi2"; +import { useRouter } from "next/router"; type NavbarLink = { name: string; @@ -33,6 +34,8 @@ export const Navbar: FC = ({ onSignOut, user, }) => { + const router = useRouter(); + return (
    @@ -56,7 +59,9 @@ export const Navbar: FC = ({
  • {icon && } {name} @@ -83,6 +88,8 @@ const Right = ({ onSignOut?: () => void; children?: ReactNode; }) => { + const router = useRouter(); + if (!user) { return (
    @@ -125,7 +132,10 @@ const Right = ({ {links.map(({ name, href, icon }) => { return (
  • - + {name}
  • @@ -133,7 +143,10 @@ const Right = ({ })}
  • - + Settings
  • From 0935b05261af22aa8be86833623f527172995a3d Mon Sep 17 00:00:00 2001 From: eman-bfloat Date: Sat, 19 Oct 2024 14:45:45 +0300 Subject: [PATCH 8/9] fix: navbar errors --- apps/agent/src/pages/_app.tsx | 2 +- apps/agent/types.d.ts | 4 +- .../Orders/CustomProductsCatalogue.tsx | 39 ++++++++++++------- packages/ui/components/Navbar.tsx | 2 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/apps/agent/src/pages/_app.tsx b/apps/agent/src/pages/_app.tsx index ba159c22..0c72f5d0 100644 --- a/apps/agent/src/pages/_app.tsx +++ b/apps/agent/src/pages/_app.tsx @@ -43,7 +43,7 @@ export default function App({
    diff --git a/apps/agent/types.d.ts b/apps/agent/types.d.ts index 46cd38d3..7248a741 100644 --- a/apps/agent/types.d.ts +++ b/apps/agent/types.d.ts @@ -4,8 +4,8 @@ import NextAuth, { DefaultSession } from "next-auth"; declare module "next-auth" { interface Session { user: { - id: string; - address: string; + id?: string; + address?: string; } & DefaultSession["user"]; } } diff --git a/packages/features/Orders/CustomProductsCatalogue.tsx b/packages/features/Orders/CustomProductsCatalogue.tsx index 9eb6be11..3157acbd 100644 --- a/packages/features/Orders/CustomProductsCatalogue.tsx +++ b/packages/features/Orders/CustomProductsCatalogue.tsx @@ -20,16 +20,22 @@ import { export const CustomProductsCatalogue = () => { const [offset, setOffset] = useState(0); - const { data, error, loading, productsCount } = useFetchProducts({ offset }); + const { + data: products, + error, + loading, + productsCount, + } = useFetchProducts({ offset }); - const { addOrderItem, orderItems, setProducts, products } = - useOrderItemsStore((state) => state); + const { addOrderItem, orderItems, setProducts } = useOrderItemsStore( + (state) => state + ); const orderItemsMap = new Map(orderItems.map((item) => [item.id, item])); useEffect(() => { - setProducts(data); - }, [data, setProducts]); + if (products) setProducts(products); + }, [products, setProducts]); if (error) { return ( @@ -91,20 +97,23 @@ export const CustomProductsCatalogue = () => { > - + {productsCount && ( + + )}
    -

    {productsCount.count} Items

    +

    {productsCount?.count} Items