diff --git a/.eslintrc.js b/.eslintrc.js index 463c86901..b44b7f7a4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,10 +1,8 @@ module.exports = { root: true, - // This tells ESLint to load the config from the package `eslint-config-custom` - extends: ["custom"], settings: { next: { - rootDir: ["apps/*"], + rootDir: ["app/"], }, }, }; diff --git a/apps/app/.env.example b/apps/app/.env.example deleted file mode 100644 index cdf30fc72..000000000 --- a/apps/app/.env.example +++ /dev/null @@ -1,11 +0,0 @@ -# Replace with your instance Public IP -# NEXT_PUBLIC_API_BASE_URL = "http://localhost" -NEXT_PUBLIC_EXTRA_IMAGE_DOMAINS= -NEXT_PUBLIC_GOOGLE_CLIENTID="" -NEXT_PUBLIC_GITHUB_APP_NAME="" -NEXT_PUBLIC_GITHUB_ID="" -NEXT_PUBLIC_SENTRY_DSN="" -NEXT_PUBLIC_ENABLE_OAUTH=0 -NEXT_PUBLIC_ENABLE_SENTRY=0 -NEXT_PUBLIC_ENABLE_SESSION_RECORDER=0 -NEXT_PUBLIC_TRACK_EVENTS=0 diff --git a/apps/app/.eslintrc.js b/apps/app/.eslintrc.js deleted file mode 100644 index c8df60750..000000000 --- a/apps/app/.eslintrc.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - root: true, - extends: ["custom"], -}; diff --git a/apps/app/.prettierrc b/apps/app/.prettierrc deleted file mode 100644 index d5cb26e54..000000000 --- a/apps/app/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "printWidth": 100, - "tabWidth": 2, - "trailingComma": "es5" -} diff --git a/apps/app/Dockerfile.dev b/apps/app/Dockerfile.dev deleted file mode 100644 index 7b802634c..000000000 --- a/apps/app/Dockerfile.dev +++ /dev/null @@ -1,12 +0,0 @@ -FROM node:18-alpine -RUN apk add --no-cache libc6-compat -RUN apk update -# Set working directory -WORKDIR /app - - -COPY . . -RUN yarn global add turbo -RUN yarn install -EXPOSE 3000 -CMD ["yarn","dev"] diff --git a/apps/app/Dockerfile.web b/apps/app/Dockerfile.web deleted file mode 100644 index 11bf98bd4..000000000 --- a/apps/app/Dockerfile.web +++ /dev/null @@ -1,51 +0,0 @@ -FROM node:18-alpine 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 --scope=app --docker - -# Add lockfile and package.json's of isolated subworkspace -FROM node:18-alpine AS installer - - -RUN apk add --no-cache libc6-compat -RUN apk update -WORKDIR /app - -# First install the dependencies (as they change less often) -COPY .gitignore .gitignore -COPY --from=builder /app/out/json/ . -COPY --from=builder /app/out/yarn.lock ./yarn.lock -RUN yarn install - -# Build the project -COPY --from=builder /app/out/full/ . -COPY turbo.json turbo.json - -RUN yarn turbo run build --filter=app - -FROM node:18-alpine AS runner -WORKDIR /app - -# Don't run production as root -RUN addgroup --system --gid 1001 plane -RUN adduser --system --uid 1001 captain -USER captain - -COPY --from=installer /app/apps/app/next.config.js . -COPY --from=installer /app/apps/app/package.json . - -# Automatically leverage output traces to reduce image size -# https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=installer --chown=captain:plane /app/apps/app/.next/standalone ./ -# COPY --from=installer --chown=captain:plane /app/apps/app/.next/standalone/node_modules ./apps/app/node_modules -COPY --from=installer --chown=captain:plane /app/apps/app/.next/static ./apps/app/.next/static - -ENV NEXT_TELEMETRY_DISABLED 1 - -EXPOSE 3000 diff --git a/apps/app/components/account/email-code-form.tsx b/apps/app/components/account/email-code-form.tsx deleted file mode 100644 index 389153d60..000000000 --- a/apps/app/components/account/email-code-form.tsx +++ /dev/null @@ -1,199 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { useForm } from "react-hook-form"; -// ui -import { CheckCircleIcon } from "@heroicons/react/20/solid"; -import { Input, PrimaryButton, SecondaryButton } from "components/ui"; -// services -import authenticationService from "services/authentication.service"; -import useToast from "hooks/use-toast"; -import useTimer from "hooks/use-timer"; -// icons - -// types -type EmailCodeFormValues = { - email: string; - key?: string; - token?: string; -}; - -export const EmailCodeForm = ({ onSuccess }: any) => { - const [codeSent, setCodeSent] = useState(false); - const [codeResent, setCodeResent] = useState(false); - const [isCodeResending, setIsCodeResending] = useState(false); - const [errorResendingCode, setErrorResendingCode] = useState(false); - - const { setToastAlert } = useToast(); - const { timer: resendCodeTimer, setTimer: setResendCodeTimer } = useTimer(); - - const { - register, - handleSubmit, - setError, - setValue, - getValues, - formState: { errors, isSubmitting, isValid, isDirty }, - } = useForm({ - defaultValues: { - email: "", - key: "", - token: "", - }, - mode: "onChange", - reValidateMode: "onChange", - }); - - const isResendDisabled = - resendCodeTimer > 0 || isCodeResending || isSubmitting || errorResendingCode; - - const onSubmit = async ({ email }: EmailCodeFormValues) => { - setErrorResendingCode(false); - await authenticationService - .emailCode({ email }) - .then((res) => { - setValue("key", res.key); - setCodeSent(true); - }) - .catch((err) => { - setErrorResendingCode(true); - setToastAlert({ - title: "Oops!", - type: "error", - message: err?.error, - }); - }); - }; - - const handleSignin = async (formData: EmailCodeFormValues) => { - await authenticationService - .magicSignIn(formData) - .then((response) => { - onSuccess(response); - }) - .catch((error) => { - setToastAlert({ - title: "Oops!", - type: "error", - message: error?.response?.data?.error ?? "Enter the correct code to sign in", - }); - setError("token" as keyof EmailCodeFormValues, { - type: "manual", - message: error.error, - }); - }); - }; - - const emailOld = getValues("email"); - - useEffect(() => { - setErrorResendingCode(false); - }, [emailOld]); - - return ( - <> -
- {(codeSent || codeResent) && ( -
-
-
-
-
-

- {codeResent - ? "Please check your mail for new code." - : "Please check your mail for code."} -

-
-
-
- )} -
- - /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test( - value - ) || "Email ID is not valid", - }} - error={errors.email} - placeholder="Enter your Email ID" - /> -
- - {codeSent && ( -
- - -
- )} -
- {codeSent ? ( - - {isSubmitting ? "Signing in..." : "Sign in"} - - ) : ( - { - handleSubmit(onSubmit)().then(() => { - setResendCodeTimer(30); - }); - }} - loading={isSubmitting || (!isValid && isDirty)} - > - {isSubmitting ? "Sending code..." : "Send code"} - - )} -
-
- - ); -}; diff --git a/apps/app/components/account/email-password-form.tsx b/apps/app/components/account/email-password-form.tsx deleted file mode 100644 index d35abdfe8..000000000 --- a/apps/app/components/account/email-password-form.tsx +++ /dev/null @@ -1,113 +0,0 @@ -import React from "react"; - -import Link from "next/link"; - -// react hook form -import { useForm } from "react-hook-form"; -// services -import authenticationService from "services/authentication.service"; -// hooks -import useToast from "hooks/use-toast"; -// ui -import { Input, SecondaryButton } from "components/ui"; -// types -type EmailPasswordFormValues = { - email: string; - password?: string; - medium?: string; -}; - -export const EmailPasswordForm = ({ onSuccess }: any) => { - const { setToastAlert } = useToast(); - const { - register, - handleSubmit, - setError, - formState: { errors, isSubmitting, isValid, isDirty }, - } = useForm({ - defaultValues: { - email: "", - password: "", - medium: "email", - }, - mode: "onChange", - reValidateMode: "onChange", - }); - - const onSubmit = (formData: EmailPasswordFormValues) => { - authenticationService - .emailLogin(formData) - .then((response) => { - onSuccess(response); - }) - .catch((error) => { - console.log(error); - setToastAlert({ - title: "Oops!", - type: "error", - message: "Enter the correct email address and password to sign in", - }); - if (!error?.response?.data) return; - Object.keys(error.response.data).forEach((key) => { - const err = error.response.data[key]; - console.log(err); - setError(key as keyof EmailPasswordFormValues, { - type: "manual", - message: Array.isArray(err) ? err.join(", ") : err, - }); - }); - }); - }; - return ( - <> -
-
- - /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test( - value - ) || "Email ID is not valid", - }} - error={errors.email} - placeholder="Enter your Email ID" - /> -
-
- -
-
-
- - Forgot your password? - -
-
-
- - {isSubmitting ? "Signing in..." : "Sign In"} - -
-
- - ); -}; diff --git a/apps/app/components/account/email-signin-form.tsx b/apps/app/components/account/email-signin-form.tsx deleted file mode 100644 index e2f81d50c..000000000 --- a/apps/app/components/account/email-signin-form.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { useState, FC } from "react"; -import { KeyIcon } from "@heroicons/react/24/outline"; -// components -import { EmailCodeForm, EmailPasswordForm } from "components/account"; - -export interface EmailSignInFormProps { - handleSuccess: () => void; -} - -export const EmailSignInForm: FC = (props) => { - const { handleSuccess } = props; - // states - const [useCode, setUseCode] = useState(true); - - return ( - <> - {useCode ? ( - - ) : ( - - )} - - ); -}; diff --git a/apps/app/components/account/github-login-button.tsx b/apps/app/components/account/github-login-button.tsx deleted file mode 100644 index 5b49208bb..000000000 --- a/apps/app/components/account/github-login-button.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { useEffect, useState, FC } from "react"; -import Link from "next/link"; -import Image from "next/image"; -import { useRouter } from "next/router"; -// images -import githubImage from "/public/logos/github-black.png"; - -const { NEXT_PUBLIC_GITHUB_ID } = process.env; - -export interface GithubLoginButtonProps { - handleSignIn: React.Dispatch; -} - -export const GithubLoginButton: FC = (props) => { - const { handleSignIn } = props; - // router - const { - query: { code }, - } = useRouter(); - // states - const [loginCallBackURL, setLoginCallBackURL] = useState(undefined); - - useEffect(() => { - if (code) { - handleSignIn(code.toString()); - } - }, [code, handleSignIn]); - - useEffect(() => { - const origin = - typeof window !== "undefined" && window.location.origin ? window.location.origin : ""; - setLoginCallBackURL(`${origin}/signin` as any); - }, []); - - return ( -
- - - -
- ); -}; diff --git a/apps/app/components/account/google-login.tsx b/apps/app/components/account/google-login.tsx deleted file mode 100644 index 478ffc67e..000000000 --- a/apps/app/components/account/google-login.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { FC, CSSProperties, useEffect, useRef, useCallback, useState } from "react"; -// next -import Script from "next/script"; - -export interface IGoogleLoginButton { - text?: string; - handleSignIn: React.Dispatch; - styles?: CSSProperties; -} - -export const GoogleLoginButton: FC = (props) => { - const { handleSignIn } = props; - - const googleSignInButton = useRef(null); - const [gsiScriptLoaded, setGsiScriptLoaded] = useState(false); - - const loadScript = useCallback(() => { - if (!googleSignInButton.current || gsiScriptLoaded) return; - window?.google?.accounts.id.initialize({ - client_id: process.env.NEXT_PUBLIC_GOOGLE_CLIENTID || "", - callback: handleSignIn, - }); - window?.google?.accounts.id.renderButton( - googleSignInButton.current, - { - type: "standard", - theme: "outline", - size: "large", - logo_alignment: "center", - width: "410", - text: "continue_with", - } as GsiButtonConfiguration // customization attributes - ); - window?.google?.accounts.id.prompt(); // also display the One Tap dialog - setGsiScriptLoaded(true); - }, [handleSignIn, gsiScriptLoaded]); - - useEffect(() => { - if (window?.google?.accounts?.id) { - loadScript(); - } - return () => { - window?.google?.accounts.id.cancel(); - }; - }, [loadScript]); - - return ( - <> -