Skip to content

Commit

Permalink
Merge branch 'develop' into test-cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel-Melon authored Feb 9, 2024
2 parents 4bddded + 84f276f commit b5ece5c
Show file tree
Hide file tree
Showing 107 changed files with 3,029 additions and 23,861 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn format
# yarn format
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.17.0
v20.10.0
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Sahil facilitates the establishment of a robust supply chain by enabling busines
1. Product Availability and User Specifications: The app uses the user's order details, including the quantity and type of items, to search for suppliers that match the requested products.
2. Priority for Suppliers with Full Order Fulfillment: The algorithm gives priority to suppliers who can fulfill the entire order, ensuring maximum efficiency in the supply chain.
3. Two-step Matching Process:
- First Priority: Suppliers who can fulfill the entire order are given the highest priority.
- Second Priority: If no single supplier can fulfill the entire order, the algorithm considers suppliers who can provide partial quantities.
- First Priority: Suppliers who can fulfill the entire order are given the highest priority.
- Second Priority: If no single supplier can fulfill the entire order, the algorithm considers suppliers who can provide partial quantities.

### Implementation Details

Expand Down
3 changes: 0 additions & 3 deletions apps/agent/.eslintrc.json

This file was deleted.

9 changes: 1 addition & 8 deletions apps/agent/next.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
transpilePackages: ['@sahil/lib', 'ui', '@sahil/configs', "@sahil/features"],
output: "standalone",
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
transpilePackages: ['@sahil/lib', 'ui', '@sahil/configs', "@sahil/features", "tsconfig", "eslint-config-custom"],
images: {
remotePatterns: [
{
Expand Down
6 changes: 4 additions & 2 deletions apps/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"prepare": "husky install"
"start": "next start"
},
"dependencies": {
"@apollo/client": "^3.8.1",
Expand All @@ -17,11 +16,13 @@
"@sahil/configs": "*",
"@sahil/features": "*",
"@sahil/lib": "*",
"@types/jsonwebtoken": "^9.0.5",
"apollo-link-ws": "^1.0.20",
"autoprefixer": "10.4.15",
"daisyui": "3.5.1",
"date-fns": "^2.30.0",
"eslint": "8.47.0",
"eslint-config-custom": "*",
"eslint-config-next": "13.4.16",
"graphql": "^16.8.0",
"graphql-ws": "^5.14.0",
Expand All @@ -37,6 +38,7 @@
"subscriptions-transport-ws": "^0.11.0",
"swr": "^2.2.1",
"tailwindcss": "3.3.3",
"tsconfig": "*",
"ui": "*",
"zod": "3.21.4",
"zustand": "^4.4.1"
Expand Down
6 changes: 4 additions & 2 deletions apps/agent/src/Layout/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { ReactChild } from "react";
import logo from "../../public/logo.png";
import { useRouter } from "next/router";
import { signOut } from "next-auth/react";
import { signOut, useSession } from "next-auth/react";
import { Navbar } from "ui";
type LayoutProps = {
children: ReactChild | ReactChild[];
Expand Down Expand Up @@ -38,6 +38,8 @@ const links = [

export default function Layout({ children, ...props }: LayoutProps) {
const router = useRouter();
const { data: session } = useSession();

const onSignOut = async () => {
await signOut();
router.push("/auth/signin");
Expand All @@ -50,7 +52,7 @@ export default function Layout({ children, ...props }: LayoutProps) {
header="Sahil Agent"
onSignOut={onSignOut}
/>
<main className="min-h-screen p-2 bg-gray-50">{children}</main>
<main className="min-h-screen p-4 bg-gray-50">{children}</main>
</>
);
}
9 changes: 0 additions & 9 deletions apps/agent/src/hooks/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ export const useFetchOrderByPK = (id: string) => {
return { error, data: data?.orders_by_pk, loading };
};

export const useFetchOrderDeliveriesByPK = (id) => {
const { error, data, loading } = useQuery(FETCH_ORDER_DELIVERIES, {
variables: {
orderId: id,
},
});
return { error, data: data?.delivery, loading };
};

export const usePlaceBusinessOrder = () => {
const [placeOrder, { data, loading, error }] = useMutation(INSERT_NEW_ORDER);

Expand Down
2 changes: 1 addition & 1 deletion apps/agent/src/hooks/useOrderItemsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const useOrderItemsStore = create<OrderItemsStore>((set) => ({
}),
products: [],
setProducts: (products: any) => {
const mappedProducts = products?.map((product) => ({
const mappedProducts = products?.map((product: any) => ({
...product,
isInCart: false,
}));
Expand Down
6 changes: 3 additions & 3 deletions apps/agent/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { SessionProvider } from "next-auth/react";
import Layout from "@/Layout/layout";
import { createApolloClient } from "@sahil/lib/graphql";

const graphqlUri = process.env.NEXT_PUBLIC_HASURA_GRAPHQL_ENDPOINT;
const ws = process.env.NEXT_PUBLIC_HASURA_GRAPHQL_WS;
const graphqlUri = process.env.NEXT_PUBLIC_HASURA_GRAPHQL_ENDPOINT as string;
const ws = process.env.NEXT_PUBLIC_HASURA_GRAPHQL_WS as string;

const httpOptions = {
headers: {
Expand All @@ -18,7 +18,7 @@ const httpOptions = {
const client = createApolloClient({
uri: graphqlUri,
httpOptions,
ws: ws as string,
ws: ws,
});

export default function App({
Expand Down
2 changes: 1 addition & 1 deletion apps/agent/src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function Document() {
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Sen&display=swap"
href="https://fonts.googleapis.com/css2?family=Sen&family=Plus+Jakarta+Sans&display=swap"
rel="stylesheet"
/>
</Head>
Expand Down
82 changes: 4 additions & 78 deletions apps/agent/src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,7 @@
import NextAuth from "next-auth";
import GithubProvider from "next-auth/providers/github";
import jwt from "jsonwebtoken";
import initNextAuth from "@sahil/features/auth/lib/auth";

export default NextAuth({
providers: [
GithubProvider({
clientId: process.env.NEXT_PUBLIC_GITHUB_ID,
clientSecret: process.env.NEXT_PUBLIC_GITHUB_SECRET,
}),
],
secret: process.env.SECRET,
jwt: {
// A secret to use for key generation (you should set this explicitly)
secret: process.env.SECRET,
encode: async ({ secret, token, maxAge }: any) => {
const claims = {
sub: token?.sub.toString(),
name: token?.name,
email: token?.email,
iat: Date.now() / 1000,
exp: Math.floor(Date.now() / 1000) + 24 * 60 * 60,
"https://hasura.io/jwt/claims": {
"x-hasura-allowed-roles": ["user"],
"x-hasura-default-role": "user",
"x-hasura-role": "user",
"x-hasura-user-id": token.id,
},
};
const options = initNextAuth();

const encodedToken = jwt.sign(claims, secret, { algorithm: "HS256" });
return encodedToken;
},
decode: async ({ secret, token, maxAge }: any) => {
const decodedToken = jwt.verify(token, secret, { algorithms: ["HS256"] });
return decodedToken;
},
},
pages: {
signIn: "/auth/signin", // Displays signin buttons
signOut: "/auth/signout", // Displays form with sign out button
error: "/auth/error", // Error code passed in query string as ?error=
verifyRequest: "/auth/verify-request", // Used for check email page
newUser: "/auth/new", // If set, new users will be directed here on first sign in
},
callbacks: {
async session({ session, token }) {
console.log("token", token);
console.log("session", session);
const encodedToken = jwt.sign(token, process.env.SECRET, {
algorithm: "HS256",
});
// @ts-ignore
session.token = encodedToken;
// @ts-ignore
session.id = token.id;
return session;
},
async jwt({ token, user, profile, account, isNewUser }) {
console.log("user", user);
console.log("token", token);
const isAuthenticated = user ? true : false;
if (isAuthenticated) {
token.id = user.id;
}
return Promise.resolve(token);
},
async signIn({ user, account, profile, email, credentials }) {
console.log("user", user);
console.log("account", account);
return true;
},
},

// Events are useful for logging
// https://next-auth.js.org/configuration/events
events: {},

// Enable debug messages in the console if you are having problems
debug: true,
});
// @ts-ignore
export default NextAuth(options);
13 changes: 0 additions & 13 deletions apps/agent/src/pages/api/hello.ts

This file was deleted.

54 changes: 10 additions & 44 deletions apps/agent/src/pages/auth/signin.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// @ts-ignore
import { useEffect } from "react";
import type { NextPage } from "next";
import { getProviders, signIn, useSession } from "next-auth/react";
import { getProviders, useSession } from "next-auth/react";
import { useRouter } from "next/router";
import { Card } from "ui";
import { LoginCard } from "@sahil/features/auth/LoginCard";

const SignInPage: NextPage = ({ providers }: any) => {
const { data: session } = useSession();
Expand All @@ -17,48 +16,15 @@ const SignInPage: NextPage = ({ providers }: any) => {

return (
<div className="p-4 space-y-2">
<h1 className="text-2xl">Welcome to Sahil</h1>
<Card>
<div className="flex gap-4">
<input
type="text"
placeholder="Enter your email"
className="input input-sm input-bordered w-full max-w-xs"
/>
<input
type="password"
placeholder="Enter your email"
className="input input-sm input-bordered w-full max-w-xs"
/>
<button className="btn btn-sm btn-primary">Sign In</button>
<div className="flex items-center justify-center">
<div className="space-y-4">
<h1 className="text-center text-2xl">Welcome Back</h1>
<LoginCard providers={providers} />
<div>
<p className="text-center">Don&apos;t have an account?</p>
</div>
</div>
<div className="divider">Or</div>
{providers &&
Object.values(providers).map((provider) => {
return (
<div
// @ts-ignore
key={provider?.name}
>
<div>
<button
className="btn btn-sm"
onClick={() => {
// @ts-ignore
signIn(provider?.id);
}}
>
Sign in with{" "}
{
// @ts-ignore
provider?.name
}
</button>
</div>
</div>
);
})}
</Card>
</div>
</div>
);
};
Expand Down
4 changes: 2 additions & 2 deletions apps/agent/src/pages/businesses/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import { ListBusinesses } from "@sahil/features/Businesses/ListBusinesses";
import { ListBusinesses } from "@sahil/features/businesses/ListBusinesses";
import { useRouter } from "next/router";
import { Card, Stats, Stat } from "ui";
import { HiPlus, HiOutlineDocumentMagnifyingGlass } from "react-icons/hi2";
Expand Down Expand Up @@ -49,7 +49,7 @@ export default function Business() {
</Card>
<h3 className="text-md">Overview</h3>
<Stats stats={stats} />
{/* <ListBusinesses /> */}
<ListBusinesses />
</section>
);
}
2 changes: 1 addition & 1 deletion apps/agent/src/pages/couriers/[courierId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function CourierPage() {
<div className="divider divider-horizontal"></div>
<div className="space-y-4 grow">
<CourierStats />
<LatestDeliveries courierId={courierId} />
<LatestDeliveries courierId={courierId as string} />
<VehicleInfo />
<ZoneInformation />
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/agent/src/pages/suppliers/[supplierId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function SupplierPage() {
<SupplierProducts
productsCount={supplier?.products_aggregate.aggregate.count}
/>
<SupplierOrderHistory supplierId={supplierId} />
<SupplierOrderHistory supplierId={supplierId as string} />
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions apps/agent/src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ body {
font-family: "Sen", sans-serif;
/* rest css code also here */
}

h1, h2, h3, h4, h5, h6 {
font-family: "Plus Jakarta Sans", sans-serif;
}
1 change: 1 addition & 0 deletions apps/agent/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const extendedConfig: Config = {
...baseConfig.theme?.extend,
},
},
// @ts-expect-error
plugins: [...baseConfig.plugins, require("daisyui")],
daisyui: {
themes: [
Expand Down
Empty file.
Empty file.
Empty file added apps/api/src/auth/router.ts
Empty file.
Empty file added apps/api/src/auth/worker.ts
Empty file.
Loading

0 comments on commit b5ece5c

Please sign in to comment.