diff --git a/remix/.gitignore b/remix/.gitignore
index b293477..2eb2e4b 100644
--- a/remix/.gitignore
+++ b/remix/.gitignore
@@ -10,4 +10,6 @@ public/build/*
api/index.js
api/index.js.map
-pnpm-lock.yaml
\ No newline at end of file
+pnpm-lock.yaml
+
+tmp/*
diff --git a/remix/src/Providers/Chakra/ChakraWrapper.tsx b/remix/app/Providers/Chakra/ChakraWrapper.tsx
similarity index 100%
rename from remix/src/Providers/Chakra/ChakraWrapper.tsx
rename to remix/app/Providers/Chakra/ChakraWrapper.tsx
diff --git a/remix/src/Providers/Chakra/colors.tsx b/remix/app/Providers/Chakra/colors.tsx
similarity index 100%
rename from remix/src/Providers/Chakra/colors.tsx
rename to remix/app/Providers/Chakra/colors.tsx
diff --git a/remix/src/Providers/Chakra/space.tsx b/remix/app/Providers/Chakra/space.tsx
similarity index 100%
rename from remix/src/Providers/Chakra/space.tsx
rename to remix/app/Providers/Chakra/space.tsx
diff --git a/remix/src/Providers/Chakra/theme.tsx b/remix/app/Providers/Chakra/theme.tsx
similarity index 100%
rename from remix/src/Providers/Chakra/theme.tsx
rename to remix/app/Providers/Chakra/theme.tsx
diff --git a/remix/src/Providers/ThingtimeProvider.tsx b/remix/app/Providers/ThingtimeProvider.tsx
similarity index 100%
rename from remix/src/Providers/ThingtimeProvider.tsx
rename to remix/app/Providers/ThingtimeProvider.tsx
diff --git a/remix/app/api/utils/checkUserExists.ts b/remix/app/api/utils/checkUserExists.ts
new file mode 100644
index 0000000..95b526e
--- /dev/null
+++ b/remix/app/api/utils/checkUserExists.ts
@@ -0,0 +1,21 @@
+// query mongodb for user objects with the email provided
+// if user exists, return true
+// if user does not exist, return false
+
+import { createConnection } from './mongodb/connection';
+
+export const checkUserExists = async ({ email }) => {
+
+ const client = await createConnection();
+ const db = client.db('auth');
+ const collection = db.collection('users');
+ const user = await collection.findOne({ email });
+
+ if (user) {
+ return true;
+ }
+
+ return false;
+
+}
+
\ No newline at end of file
diff --git a/remix/app/api/utils/mongodb/connection.ts b/remix/app/api/utils/mongodb/connection.ts
new file mode 100644
index 0000000..b5a0eca
--- /dev/null
+++ b/remix/app/api/utils/mongodb/connection.ts
@@ -0,0 +1,7 @@
+import { MongoClient } from 'mongodb';
+
+export const createConnection = async () => {
+ const client = new MongoClient(process.env.MONGODB_URI, {});
+ await client.connect();
+ return client;
+};
diff --git a/remix/src/components/Buttons/Attention.tsx b/remix/app/components/Buttons/Attention.tsx
similarity index 100%
rename from remix/src/components/Buttons/Attention.tsx
rename to remix/app/components/Buttons/Attention.tsx
diff --git a/remix/src/components/Buttons/Hamburger.tsx b/remix/app/components/Buttons/Hamburger.tsx
similarity index 100%
rename from remix/src/components/Buttons/Hamburger.tsx
rename to remix/app/components/Buttons/Hamburger.tsx
diff --git a/remix/src/components/Commander/Commander.tsx b/remix/app/components/Commander/Commander.tsx
similarity index 100%
rename from remix/src/components/Commander/Commander.tsx
rename to remix/app/components/Commander/Commander.tsx
diff --git a/remix/src/components/Commander/CommanderV2.tsx b/remix/app/components/Commander/CommanderV2.tsx
similarity index 100%
rename from remix/src/components/Commander/CommanderV2.tsx
rename to remix/app/components/Commander/CommanderV2.tsx
diff --git a/remix/src/components/Icon/Icon.tsx b/remix/app/components/Icon/Icon.tsx
similarity index 100%
rename from remix/src/components/Icon/Icon.tsx
rename to remix/app/components/Icon/Icon.tsx
diff --git a/remix/src/components/Layout/Main.tsx b/remix/app/components/Layout/Main.tsx
similarity index 100%
rename from remix/src/components/Layout/Main.tsx
rename to remix/app/components/Layout/Main.tsx
diff --git a/remix/src/components/Login/Login.tsx b/remix/app/components/Login/Login.tsx
similarity index 90%
rename from remix/src/components/Login/Login.tsx
rename to remix/app/components/Login/Login.tsx
index b8beb85..a983f8a 100644
--- a/remix/src/components/Login/Login.tsx
+++ b/remix/app/components/Login/Login.tsx
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { Flex, Button, FormControl, Input, Spinner, Link } from '@chakra-ui/react';
import { useFetcher } from '@remix-run/react';
-import { useLogin } from '~/api/v1/login/Login';
+import { useApi } from '~/hooks/useApi';
export const Login = (props) => {
const [username, setUsername] = useState('');
@@ -10,24 +10,22 @@ export const Login = (props) => {
const [loading, setLoading] = useState(false);
- const api = useFetcher();
+ const api = useApi();
- const { login } = useLogin();
+ const login = api.v1.login;
- const handleLogin = (e) => {
+ const handleLogin = async (e) => {
e?.preventDefault();
setLoading(true);
- login(username, password)
- .then((response) => {
- console.log('nik response 123', response);
- setLoading(false);
- })
- .catch((error) => {
- console.error('nik error 123', error);
- setLoading(false);
- });
+ const loginResp = await login({ username, password });
+
+ if (loginResp) {
+ console.log('nik loginResp', loginResp);
+ } else {
+ console.error('nik no loginResp', loginResp);
+ }
console.log('nik username', username);
console.log('nik password', password);
diff --git a/remix/src/components/MagicInput/MagicInput.tsx b/remix/app/components/MagicInput/MagicInput.tsx
similarity index 100%
rename from remix/src/components/MagicInput/MagicInput.tsx
rename to remix/app/components/MagicInput/MagicInput.tsx
diff --git a/remix/src/components/Nav/Footer.tsx b/remix/app/components/Nav/Footer.tsx
similarity index 100%
rename from remix/src/components/Nav/Footer.tsx
rename to remix/app/components/Nav/Footer.tsx
diff --git a/remix/src/components/Nav/Nav.tsx b/remix/app/components/Nav/Nav.tsx
similarity index 95%
rename from remix/src/components/Nav/Nav.tsx
rename to remix/app/components/Nav/Nav.tsx
index e1f4f39..226fe54 100644
--- a/remix/src/components/Nav/Nav.tsx
+++ b/remix/app/components/Nav/Nav.tsx
@@ -135,6 +135,12 @@ export const Nav = (props) => {
> */}
)}
+ {/* TODO - Add conditional only show if loggedIn */}
+
+
+
+
+
diff --git a/remix/src/components/Nav/ProfileDrawer.tsx b/remix/app/components/Nav/ProfileDrawer.tsx
similarity index 100%
rename from remix/src/components/Nav/ProfileDrawer.tsx
rename to remix/app/components/Nav/ProfileDrawer.tsx
diff --git a/remix/src/components/Nav/ReactiveNav.tsx b/remix/app/components/Nav/ReactiveNav.tsx
similarity index 100%
rename from remix/src/components/Nav/ReactiveNav.tsx
rename to remix/app/components/Nav/ReactiveNav.tsx
diff --git a/remix/src/components/Nav/ReactiveRightNav.tsx b/remix/app/components/Nav/ReactiveRightNav.tsx
similarity index 100%
rename from remix/src/components/Nav/ReactiveRightNav.tsx
rename to remix/app/components/Nav/ReactiveRightNav.tsx
diff --git a/remix/src/components/Rainbow/Rainbow.tsx b/remix/app/components/Rainbow/Rainbow.tsx
similarity index 100%
rename from remix/src/components/Rainbow/Rainbow.tsx
rename to remix/app/components/Rainbow/Rainbow.tsx
diff --git a/remix/src/components/Safety/Safe.tsx b/remix/app/components/Safety/Safe.tsx
similarity index 100%
rename from remix/src/components/Safety/Safe.tsx
rename to remix/app/components/Safety/Safe.tsx
diff --git a/remix/src/components/Skeleton/RainbowSkeleton.tsx b/remix/app/components/Skeleton/RainbowSkeleton.tsx
similarity index 100%
rename from remix/src/components/Skeleton/RainbowSkeleton.tsx
rename to remix/app/components/Skeleton/RainbowSkeleton.tsx
diff --git a/remix/src/components/Splash/Splash.tsx b/remix/app/components/Splash/Splash.tsx
similarity index 100%
rename from remix/src/components/Splash/Splash.tsx
rename to remix/app/components/Splash/Splash.tsx
diff --git a/remix/src/components/Thingtime/SettingsMenu.tsx b/remix/app/components/Thingtime/SettingsMenu.tsx
similarity index 100%
rename from remix/src/components/Thingtime/SettingsMenu.tsx
rename to remix/app/components/Thingtime/SettingsMenu.tsx
diff --git a/remix/src/components/Thingtime/Thingtime.tsx b/remix/app/components/Thingtime/Thingtime.tsx
similarity index 100%
rename from remix/src/components/Thingtime/Thingtime.tsx
rename to remix/app/components/Thingtime/Thingtime.tsx
diff --git a/remix/src/components/Thingtime/ThingtimeDemo.tsx b/remix/app/components/Thingtime/ThingtimeDemo.tsx
similarity index 100%
rename from remix/src/components/Thingtime/ThingtimeDemo.tsx
rename to remix/app/components/Thingtime/ThingtimeDemo.tsx
diff --git a/remix/src/components/Thingtime/ThingtimeURL.tsx b/remix/app/components/Thingtime/ThingtimeURL.tsx
similarity index 53%
rename from remix/src/components/Thingtime/ThingtimeURL.tsx
rename to remix/app/components/Thingtime/ThingtimeURL.tsx
index fb08463..5715ca3 100644
--- a/remix/src/components/Thingtime/ThingtimeURL.tsx
+++ b/remix/app/components/Thingtime/ThingtimeURL.tsx
@@ -1,24 +1,24 @@
-import React from "react"
+import React from 'react';
// import { Sticky, StickyContainer } from "react-sticky"
-import Sticky from "react-sticky-el"
-import { Box, Flex } from "@chakra-ui/react"
-import { useLocation, useMatches } from "@remix-run/react"
+import Sticky from 'react-sticky-el';
+import { Box, Flex } from '@chakra-ui/react';
+import { useLocation, useMatches } from '@remix-run/react';
-import { Thingtime } from "./Thingtime"
-import { useThingtime } from "./useThingtime"
+import { Thingtime } from './Thingtime';
+import { useThingtime } from './useThingtime';
export const ThingtimeURL = (props) => {
- const { getThingtime } = useThingtime()
+ const { getThingtime } = useThingtime();
- const { pathname } = useLocation()
+ const { pathname } = useLocation();
- const matches = useMatches()
+ const matches = useMatches();
const location = React.useMemo(() => {
- return matches[matches.length - 1]
- }, [matches])
+ return matches[matches.length - 1];
+ }, [matches]);
const path = React.useMemo(() => {
- console.log("ThingtimeURL location", location)
+ console.log('ThingtimeURL location', location);
// const sanitisation = ["/things", "/edit", "/editor", "/code", "/coder"]
@@ -31,64 +31,66 @@ export const ThingtimeURL = (props) => {
// })
// strip the leading /path1/path2 path1 section from the path
- const pathPartOne = location?.pathname?.split("/")[2]
+ const pathPartOne = location?.pathname?.split('/')[2];
- const path = pathPartOne?.replace(/\//g, ".")
+ const path = pathPartOne?.replace(/\//g, '.');
- return path || "thingtime"
- }, [location])
+ console.log('nik path', path);
+
+ return path || 'thingtime';
+ }, [location]);
const thing = React.useMemo(() => {
// remove /things/ from path
- const ret = getThingtime(path)
+ const ret = getThingtime(path);
- return ret
- }, [path, getThingtime])
+ return ret;
+ }, [path, getThingtime]);
const inEditorMode = React.useMemo(() => {
- if (pathname.slice(0, 7) === "/editor") {
- return true
+ if (pathname.slice(0, 7) === '/editor') {
+ return true;
}
- return false
- }, [pathname])
+ return false;
+ }, [pathname]);
const inEditMode = React.useMemo(() => {
- if (pathname.slice(0, 5) === "/edit") {
- return true
+ if (pathname.slice(0, 5) === '/edit') {
+ return true;
}
- return false
- }, [pathname])
+ return false;
+ }, [pathname]);
- const containerRef = React.useRef(null)
- const editorRef = React.useRef(null)
+ const containerRef = React.useRef(null);
+ const editorRef = React.useRef(null);
React.useEffect(() => {
const scrollListener = () => {
if (containerRef?.current?.getBoundingClientRect) {
- const { top } = containerRef?.current?.getBoundingClientRect()
+ const { top } = containerRef?.current?.getBoundingClientRect();
- editorRef.current.style.top = `${-top}px`
+ editorRef.current.style.top = `${-top}px`;
}
- }
+ };
- window.addEventListener("scroll", scrollListener)
+ window.addEventListener('scroll', scrollListener);
return () => {
- window.removeEventListener("scroll", scrollListener)
- }
- }, [])
+ window.removeEventListener('scroll', scrollListener);
+ };
+ }, []);
return (
@@ -109,18 +111,12 @@ export const ThingtimeURL = (props) => {
path={path}
thing={thing}
render
- chakras={{ marginY: "200px" }}
+ chakras={{ marginY: '200px' }}
// width="600px"
>
)}
-
+
- )
-}
+ );
+};
diff --git a/remix/src/components/Thingtime/useThingtime.tsx b/remix/app/components/Thingtime/useThingtime.tsx
similarity index 100%
rename from remix/src/components/Thingtime/useThingtime.tsx
rename to remix/app/components/Thingtime/useThingtime.tsx
diff --git a/remix/src/components/rainbowText.tsx b/remix/app/components/rainbowText.tsx
similarity index 97%
rename from remix/src/components/rainbowText.tsx
rename to remix/app/components/rainbowText.tsx
index 6c5d63b..10b2705 100644
--- a/remix/src/components/rainbowText.tsx
+++ b/remix/app/components/rainbowText.tsx
@@ -29,7 +29,7 @@ export const RainbowText = (props) => {
userSelect="none"
outline="none"
contentEditable={props?.ce}
- spellcheck="false"
+ spellCheck="false"
>
{props?.children}
diff --git a/remix/src/components/textAnimation1.tsx b/remix/app/components/textAnimation1.tsx
similarity index 100%
rename from remix/src/components/textAnimation1.tsx
rename to remix/app/components/textAnimation1.tsx
diff --git a/remix/src/entry.client.tsx b/remix/app/entry.client.tsx
similarity index 100%
rename from remix/src/entry.client.tsx
rename to remix/app/entry.client.tsx
diff --git a/remix/src/entry.server.tsx b/remix/app/entry.server.tsx
similarity index 100%
rename from remix/src/entry.server.tsx
rename to remix/app/entry.server.tsx
diff --git a/remix/src/functions/safe.tsx b/remix/app/functions/safe.tsx
similarity index 100%
rename from remix/src/functions/safe.tsx
rename to remix/app/functions/safe.tsx
diff --git a/remix/src/functions/sanitise.tsx b/remix/app/functions/sanitise.tsx
similarity index 100%
rename from remix/src/functions/sanitise.tsx
rename to remix/app/functions/sanitise.tsx
diff --git a/remix/src/global-types.d.ts b/remix/app/global-types.d.ts
similarity index 93%
rename from remix/src/global-types.d.ts
rename to remix/app/global-types.d.ts
index 3b1250a..51432dd 100644
--- a/remix/src/global-types.d.ts
+++ b/remix/app/global-types.d.ts
@@ -1,7 +1,7 @@
// modify window / globalThis to support any properties
// so there's no property does not exist on window typescript errors
-// Path: app/src/global-types.d.ts
+// Path: app/global-types.d.ts
declare global {
interface Window {
[key: string]: any;
diff --git a/remix/src/globals/GlobalStyles.tsx b/remix/app/globals/GlobalStyles.tsx
similarity index 100%
rename from remix/src/globals/GlobalStyles.tsx
rename to remix/app/globals/GlobalStyles.tsx
diff --git a/remix/src/gp/GradientPath.js b/remix/app/gp/GradientPath.js
similarity index 100%
rename from remix/src/gp/GradientPath.js
rename to remix/app/gp/GradientPath.js
diff --git a/remix/src/gp/Sample.js b/remix/app/gp/Sample.js
similarity index 100%
rename from remix/src/gp/Sample.js
rename to remix/app/gp/Sample.js
diff --git a/remix/src/gp/Segment.js b/remix/app/gp/Segment.js
similarity index 100%
rename from remix/src/gp/Segment.js
rename to remix/app/gp/Segment.js
diff --git a/remix/src/gp/_constants.js b/remix/app/gp/_constants.js
similarity index 100%
rename from remix/src/gp/_constants.js
rename to remix/app/gp/_constants.js
diff --git a/remix/src/gp/_data.js b/remix/app/gp/_data.js
similarity index 100%
rename from remix/src/gp/_data.js
rename to remix/app/gp/_data.js
diff --git a/remix/src/gp/_utils.js b/remix/app/gp/_utils.js
similarity index 100%
rename from remix/src/gp/_utils.js
rename to remix/app/gp/_utils.js
diff --git a/remix/src/gp/index.js b/remix/app/gp/index.js
similarity index 100%
rename from remix/src/gp/index.js
rename to remix/app/gp/index.js
diff --git a/remix/app/hooks/useApi.tsx b/remix/app/hooks/useApi.tsx
new file mode 100644
index 0000000..1b969a6
--- /dev/null
+++ b/remix/app/hooks/useApi.tsx
@@ -0,0 +1,28 @@
+import { useCallback, useEffect, useRef } from 'react';
+
+import { useAsyncFetcher } from './useAsyncFetcher';
+
+export function useApi() {
+ const asyncFetcher = useAsyncFetcher();
+
+ const v1 = {
+ login: useCallback(
+ async (args) => {
+ const { username, password } = args;
+
+ console.log('nik submitting with username', username);
+ console.log('nik submitting with password', password);
+
+ const ret = asyncFetcher.submit({ username, password }, { action: '/api/v1/login' });
+ return ret;
+ },
+ [asyncFetcher]
+ )
+ };
+
+ const ret = {
+ v1
+ };
+
+ return ret;
+}
diff --git a/remix/app/hooks/useAsyncFetcher.tsx b/remix/app/hooks/useAsyncFetcher.tsx
new file mode 100644
index 0000000..cfd944a
--- /dev/null
+++ b/remix/app/hooks/useAsyncFetcher.tsx
@@ -0,0 +1,44 @@
+import { useCallback, useEffect, useRef, useState } from 'react';
+import { useFetcher } from '@remix-run/react';
+
+export function useAsyncFetcher() {
+ let resolveRef = useRef();
+ let promiseRef = useRef>();
+ let fetcher = useFetcher();
+
+ if (!promiseRef.current) {
+ promiseRef.current = new Promise((resolve) => {
+ resolveRef.current = resolve;
+ });
+ }
+
+ const resetResolver = useCallback(() => {
+ promiseRef.current = new Promise((resolve) => {
+ resolveRef.current = resolve;
+ });
+ }, [promiseRef, resolveRef]);
+
+ const [defaultOpts, setDefaultOpts] = useState({
+ method: 'POST',
+ encType: 'application/json'
+ })
+
+ const submit = useCallback(
+ async (data, opts) => {
+ // @ts-ignore
+ fetcher.submit(data, { ...defaultOpts, ...opts });
+ return promiseRef.current;
+ },
+ [fetcher, promiseRef]
+ );
+
+ useEffect(() => {
+ if (fetcher.data && fetcher.state === 'idle') {
+ resolveRef.current(fetcher.data);
+ resetResolver();
+ }
+ }, [fetcher, resetResolver]);
+
+
+ return { ...fetcher, submit };
+}
diff --git a/remix/src/hooks/useIcons.tsx b/remix/app/hooks/useIcons.tsx
similarity index 100%
rename from remix/src/hooks/useIcons.tsx
rename to remix/app/hooks/useIcons.tsx
diff --git a/remix/src/hooks/usePath.tsx b/remix/app/hooks/usePath.tsx
similarity index 100%
rename from remix/src/hooks/usePath.tsx
rename to remix/app/hooks/usePath.tsx
diff --git a/remix/src/hooks/useProps.tsx b/remix/app/hooks/useProps.tsx
similarity index 100%
rename from remix/src/hooks/useProps.tsx
rename to remix/app/hooks/useProps.tsx
diff --git a/remix/src/hooks/useThings.tsx b/remix/app/hooks/useThings.tsx
similarity index 100%
rename from remix/src/hooks/useThings.tsx
rename to remix/app/hooks/useThings.tsx
diff --git a/remix/src/hooks/useTrace.tsx b/remix/app/hooks/useTrace.tsx
similarity index 100%
rename from remix/src/hooks/useTrace.tsx
rename to remix/app/hooks/useTrace.tsx
diff --git a/remix/src/hooks/useUuid.tsx b/remix/app/hooks/useUuid.tsx
similarity index 100%
rename from remix/src/hooks/useUuid.tsx
rename to remix/app/hooks/useUuid.tsx
diff --git a/remix/src/root.tsx b/remix/app/root.tsx
similarity index 100%
rename from remix/src/root.tsx
rename to remix/app/root.tsx
diff --git a/remix/src/routes/$.tsx b/remix/app/routes/$.tsx
similarity index 90%
rename from remix/src/routes/$.tsx
rename to remix/app/routes/$.tsx
index fd6c456..5c1061c 100644
--- a/remix/src/routes/$.tsx
+++ b/remix/app/routes/$.tsx
@@ -13,7 +13,7 @@ export const action = async ({ request }) => {
'Content-Type': 'application/json'
},
body: {
- message: 'Hello, World! $ Action'
+ message: 'Hello Thingtime!'
},
cache: {
revalidate: 60
diff --git a/remix/src/routes/_index.tsx b/remix/app/routes/_index.tsx
similarity index 100%
rename from remix/src/routes/_index.tsx
rename to remix/app/routes/_index.tsx
diff --git a/remix/app/routes/api/v1/login/_login.tsx b/remix/app/routes/api/v1/login/_login.tsx
new file mode 100644
index 0000000..3f45989
--- /dev/null
+++ b/remix/app/routes/api/v1/login/_login.tsx
@@ -0,0 +1,37 @@
+import { checkUserExists } from "~/api/utils/checkUserExists";
+
+export default function Index() {
+ return Login
;
+}
+
+export const action = async ({ request }) => {
+
+ console.log('nik request', request);
+
+ // get remix action body
+
+ const body = await request.json();
+
+ const { username, password } = body;
+
+ console.log('nik body', body)
+
+ console.log('nik username', username);
+ console.log('nik password', password);
+
+
+ return {
+ status: 200,
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: {
+ message: 'Hello, World!',
+ username,
+ password
+ },
+ cache: {
+ revalidate: 60
+ }
+ };
+};
diff --git a/remix/src/routes/edge.tsx b/remix/app/routes/edge.tsx
similarity index 100%
rename from remix/src/routes/edge.tsx
rename to remix/app/routes/edge.tsx
diff --git a/remix/app/routes/login.tsx b/remix/app/routes/login.tsx
new file mode 100644
index 0000000..b5167c5
--- /dev/null
+++ b/remix/app/routes/login.tsx
@@ -0,0 +1,17 @@
+import { Flex } from '@chakra-ui/react';
+import React from 'react';
+
+import { Login } from '~/components/Login/Login';
+import { useApi } from '~/hooks/useApi';
+
+export default function login() {
+ const template = (
+ <>
+
+
+
+ >
+ );
+
+ return template;
+}
diff --git a/remix/src/routes/ode.tsx b/remix/app/routes/ode.tsx
similarity index 100%
rename from remix/src/routes/ode.tsx
rename to remix/app/routes/ode.tsx
diff --git a/remix/src/routes/rainbow.$.tsx b/remix/app/routes/rainbow.$.tsx
similarity index 100%
rename from remix/src/routes/rainbow.$.tsx
rename to remix/app/routes/rainbow.$.tsx
diff --git a/remix/src/smarts/index.tsx b/remix/app/smarts/index.tsx
similarity index 100%
rename from remix/src/smarts/index.tsx
rename to remix/app/smarts/index.tsx
diff --git a/remix/package.json b/remix/package.json
index e16c4bf..ef5f978 100644
--- a/remix/package.json
+++ b/remix/package.json
@@ -11,6 +11,7 @@
"dependencies": {
"@chakra-ui/react": "^2.7.1",
"@editorjs/editorjs": "^2.27.2",
+ "@emotion/react": "^11.11.4",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-regular-svg-icons": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
@@ -29,6 +30,7 @@
"gradient-path": "^2.3.0",
"isbot": "latest",
"lodash-es": "^4.17.21",
+ "mongodb": "^6.5.0",
"react": "^18.2.0",
"react-click-away-listener": "^2.2.3",
"react-contenteditable": "^3.3.7",
@@ -59,6 +61,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
+ "remix-flat-routes": "^0.6.4",
"typescript": "^4.9.3",
"vite": "^5.1.0",
"vite-tsconfig-paths": "^4.3.2"
diff --git a/remix/remix.config.js b/remix/remix.config.js
deleted file mode 100644
index 9d573cf..0000000
--- a/remix/remix.config.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * @type {import('@remix-run/dev').AppConfig}
- */
-module.exports = {
- ignoredRouteFiles: ['**/.*'],
- // future: {
- // unstable_dev: true
- // appServerPort: 3999
- // }
- appDirectory: 'src'
- // assetsBuildDirectory: "public/build",
- // serverBuildPath: "build/index.js",
- // publicPath: "/build/",
-};
diff --git a/remix/src/api/v1/login/Login.tsx b/remix/src/api/v1/login/Login.tsx
deleted file mode 100644
index 99c3ec2..0000000
--- a/remix/src/api/v1/login/Login.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import React from 'react';
-
-import axios from 'axios';
-import { useFetcher } from '@remix-run/react';
-
-export const useLogin = () => {
- const fetcher = useFetcher();
-
- const login = React.useCallback(async (email, password) => {
- try {
- fetcher.submit(
- { email, password },
- {
- method: 'post',
- action: '/api/v1/login'
- }
- );
-
- // const response = await axios.post('/api/v1/login', { email, password });
- // console.log('nik response', response.data);
- // return response.data;
- } catch (error) {
- return error;
- }
- }, []);
-
- return { login };
-};
diff --git a/remix/src/routes/api/v1/login.tsx b/remix/src/routes/api/v1/login.tsx
deleted file mode 100644
index 2f18d59..0000000
--- a/remix/src/routes/api/v1/login.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-export const action = async ({ request }) => {
- return {
- status: 200,
- headers: {
- 'Content-Type': 'application/json'
- },
- body: {
- message: 'Hello, World!'
- },
- cache: {
- revalidate: 60
- }
- };
-};
diff --git a/remix/src/routes/login.tsx b/remix/src/routes/login.tsx
deleted file mode 100644
index 1d2fadb..0000000
--- a/remix/src/routes/login.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { Flex } from "@chakra-ui/react"
-
-import { Login } from "~/components/Login/Login"
-
-export default function login() {
- const template = (
- <>
-
-
-
- >
- )
-
- return template
-}
diff --git a/remix/tsconfig.json b/remix/tsconfig.json
index c45aa5b..12a7428 100644
--- a/remix/tsconfig.json
+++ b/remix/tsconfig.json
@@ -15,7 +15,7 @@
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
- "~/*": ["./src/*"]
+ "~/*": ["./app/*"]
},
// Remix takes care of building everything in `remix build`.
diff --git a/remix/vite.config.ts b/remix/vite.config.ts
index b9395e0..b7ba49f 100644
--- a/remix/vite.config.ts
+++ b/remix/vite.config.ts
@@ -2,11 +2,10 @@ import { vitePlugin as remix } from '@remix-run/dev';
import { installGlobals } from '@remix-run/node';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
+import { flatRoutes } from 'remix-flat-routes'
installGlobals();
-// set app path to src/
-
export default defineConfig({
// define web socket port
@@ -18,8 +17,13 @@ export default defineConfig({
},
plugins: [
remix({
+
+ routes: async defineRoutes => {
+ return flatRoutes('routes', defineRoutes)
+ },
+
// app path
- appDirectory: 'src'
+ appDirectory: 'app'
}),
tsconfigPaths()
]