Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

feat: bug fixes & UI

AykutSarac748525c417ce
diff --git a/src/containers/Modals/AccountModal/index.tsx b/src/containers/Modals/AccountModal/index.tsx
index 2f7b2246..b6cfbb9b 100644
--- a/src/containers/Modals/AccountModal/index.tsx
+++ b/src/containers/Modals/AccountModal/index.tsx
@@ -24,8 +24,11 @@ export const AccountModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const setVisible = useModal(state => state.setVisible);
const logout = useUser(state => state.logout);
+ const username =
+ user?.user_metadata.full_name || user?.user_metadata.display_name || user?.user_metadata.name;
+
return (
- <Modal title={`Hello, ${user?.user_metadata.name}!`} opened={opened} onClose={onClose} centered>
+ <Modal title={`Hello, ${username}!`} opened={opened} onClose={onClose} centered>
<Paper p="md">
<Group>
<Avatar src={user?.user_metadata.avatar_url} size={94}>
@@ -33,7 +36,7 @@ export const AccountModal: React.FC<ModalProps> = ({ opened, onClose }) => {
</Avatar>
<div>
<Text fz="lg" tt="uppercase" fw={700}>
- {user?.user_metadata.name}
+ {username}
</Text>
<Group gap={10} mt={3}>
diff --git a/src/containers/Modals/CancelPremiumModal/index.tsx b/src/containers/Modals/CancelPremiumModal/index.tsx
index 3b16423a..b23a5ada 100644
--- a/src/containers/Modals/CancelPremiumModal/index.tsx
+++ b/src/containers/Modals/CancelPremiumModal/index.tsx
@@ -1,41 +1,67 @@
import React from "react";
-import { Modal, Group, Button, Divider, ModalProps, Text, Image, Anchor } from "@mantine/core";
+import {
+ Modal,
+ Group,
+ Button,
+ Divider,
+ ModalProps,
+ Text,
+ Anchor,
+ List,
+ Checkbox,
+ TextInput,
+} from "@mantine/core";
+import { useUser as useSupabaseUser } from "@supabase/auth-helpers-react";
import { toast } from "react-hot-toast";
import { supabase } from "src/lib/api/supabase";
import useModal from "src/store/useModal";
export const CancelPremiumModal: React.FC<ModalProps> = ({ opened, onClose }) => {
+ const user = useSupabaseUser()?.user_metadata;
const [cancelling, setCancelling] = React.useState(false);
+ const [reasons, setReasons] = React.useState<number[]>([]);
+ const [textReason, setTextReason] = React.useState("");
const showFeedback = useModal(state => state.setVisible("review"));
+ const username = user?.full_name || user?.display_name || user?.name;
+
const cancelSub = async () => {
try {
setCancelling(true);
const { data: user } = await supabase.auth.getSession();
+ if (!user) {
+ throw new Error("Couldn't fetch user details, please contact: [email protected]");
+ }
- if (user) {
- const { error } = await supabase.functions.invoke("lemonsqueezy", {
- method: "DELETE",
- body: {
- jwt: user.session?.access_token,
- },
- });
+ const { error: lmError } = await supabase.functions.invoke("lemonsqueezy", {
+ method: "DELETE",
+ body: { jwt: user.session?.access_token },
+ });
+
+ if (lmError) {
+ throw new Error(
+ "An error occured while cancelling subscription, please contact: [email protected]"
+ );
+ }
- if (error) {
- return toast.error(
- "An error occured while cancelling subscription, please contact: [email protected]"
- );
- }
+ const { error: feedbackError } = await supabase.from("cancel_feedback").insert({
+ email: user.session?.user.email,
+ text_reason: textReason,
+ reasons,
+ });
- toast.success("Cancelled premium plan!");
- showFeedback(true);
- } else {
- toast.error("Couldn't fetch user details, please contact: [email protected]");
+ if (feedbackError) {
+ throw new Error(feedbackError.message);
}
toast.success("Cancelled premium plan!");
+ showFeedback(true);
onClose();
} catch (err) {
+ if (err instanceof Error) {
+ toast.error(err.message);
+ }
+
console.error(err);
} finally {
setCancelling(false);
@@ -43,28 +69,87 @@ export const CancelPremiumModal: React.FC<ModalProps> = ({ opened, onClose }) =>
};
return (
- <Modal title="CANCEL PREMIUM?" opened={opened} onClose={onClose} centered>
- <Image py="xs" src="assets/taken.svg" mx="auto" w={200} alt="taken" />
- <Text fz="sm" pb="md">
- Cancellation will take effect at the end of your current billing period.
- <br />
- <br />
- You can restart your subscription anytime.
- <br />
- <Anchor fz="xs" target="_blank" href="https://patreon.com/herowand">
- Click here to cancel if you are Patreon member
- </Anchor>
- <Text size="xs" c="dimmed" mt="lg">
- If you have problems with cancelling plan please contact: [email protected]
- </Text>
+ <Modal title="PREMIUM" opened={opened} onClose={onClose} centered>
+ <Text fz="lg" fw="bold" pb="md">
+ {username}, are you sure you want to cancel?
+ </Text>
+ <Text fz="sm" pb="lg">
+ If you cancel, you will lose access to premium features and existing pricing. Your plan will
+ remain active until the end of the current billing cycle.
+ </Text>
+ <Text fz="sm" fw="bold">
+ Why are you cancelling your plan?
</Text>
+ <List icon={<></>} pb="lg">
+ <List.Item>
+ <Checkbox
+ checked={reasons.includes(1)}
+ onChange={e => {
+ if (e.target.checked) {
+ setReasons([...reasons, 1]);
+ } else {
+ setReasons(reasons.filter(r => r !== 1));
+ }
+ }}
+ label="The software is too difficult to use."
+ />
+ </List.Item>
+ <List.Item>
+ <Checkbox
+ checked={reasons.includes(2)}
+ onChange={e => {
+ if (e.target.checked) {
+ setReasons([...reasons, 2]);
+ } else {
+ setReasons(reasons.filter(r => r !== 2));
+ }
+ }}
+ label="I'm not satisfied with its performance."
+ />
+ </List.Item>
+ <List.Item>
+ <Checkbox
+ checked={reasons.includes(3)}
+ onChange={e => {
+ if (e.target.checked) {
+ setReasons([...reasons, 3]);
+ } else {
+ setReasons(reasons.filter(r => r !== 3));
+ }
+ }}
+ label="Features I need are missing."
+ />
+ </List.Item>
+ <List.Item>
+ <Checkbox
+ checked={reasons.includes(4)}
+ onChange={e => {
+ if (e.target.checked) {
+ setReasons([...reasons, 4]);
+ } else {
+ setReasons(reasons.filter(r => r !== 4));
+ }
+ }}
+ label="I don't use the app enough."
+ />
+ </List.Item>
+ </List>
+ <TextInput
+ value={textReason}
+ onChange={e => setTextReason(e.currentTarget.value)}
+ placeholder="Give more details about your reason..."
+ pb="lg"
+ />
+ <Anchor fz="xs" target="_blank" href="https://patreon.com/herowand">
+ Click here to cancel if you are Patreon member
+ </Anchor>
<Divider py="xs" />
<Group justify="right">
- <Button color="dark" variant="subtle" onClick={onClose}>
- Cancel
+ <Button color="red" variant="outline" onClick={onClose}>
+ Never mind, keep premium
</Button>
<Button onClick={cancelSub} loading={cancelling} color="red">
- QUIT SUBSCRIPTION
+ Cancel Plan
</Button>
</Group>
</Modal>
diff --git a/src/containers/Toolbar/AccountMenu.tsx b/src/containers/Toolbar/AccountMenu.tsx
index acaae3a6..450a8a39 100644
--- a/src/containers/Toolbar/AccountMenu.tsx
+++ b/src/containers/Toolbar/AccountMenu.tsx
@@ -8,10 +8,12 @@ import useUser from "src/store/useUser";
import * as Styles from "./styles";
export const AccountMenu = () => {
- const user = useSupabaseUser();
+ const user = useSupabaseUser()?.user_metadata;
const logout = useUser(state => state.logout);
const setVisible = useModal(state => state.setVisible);
+ const username = user?.full_name || user?.display_name || user?.name;
+
return (
<Menu shadow="md" trigger="click" closeOnItemClick={false} withArrow>
<Menu.Target>
@@ -24,13 +26,11 @@ export const AccountMenu = () => {
<Menu.Dropdown>
{user ? (
<Menu.Item
- leftSection={
- <Avatar color="indigo" alt={user.user_metadata?.name} size={20} radius="xl" />
- }
+ leftSection={<Avatar color="indigo" alt={username} size={20} radius="xl" />}
onClick={() => setVisible("account")(true)}
closeMenuOnClick
>
- <Text size="xs">{user.user_metadata?.name ?? "Account"}</Text>
+ <Text size="xs">{username ?? "Account"}</Text>
</Menu.Item>
) : (
<Link href="/sign-in">
diff --git a/src/layout/EditorWrapper/index.tsx b/src/layout/EditorWrapper/index.tsx
index 4fe41fd3..196fa72e 100644
--- a/src/layout/EditorWrapper/index.tsx
+++ b/src/layout/EditorWrapper/index.tsx
@@ -1,10 +1,14 @@
import React from "react";
+import dynamic from "next/dynamic";
import { MantineProvider } from "@mantine/core";
import { ThemeProvider } from "styled-components";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { lightTheme, darkTheme } from "src/constants/theme";
import useConfig from "src/store/useConfig";
+const Toaster = dynamic(() => import("react-hot-toast").then(c => c.Toaster));
+const ModalController = dynamic(() => import("src/layout/ModalController"));
+
const queryClient = new QueryClient({
defaultOptions: {
queries: {
@@ -21,8 +25,26 @@ export const EditorWrapper: React.FC<{
return (
<ThemeProvider theme={darkmodeEnabled ? darkTheme : lightTheme}>
+ <Toaster
+ position="bottom-right"
+ containerStyle={{
+ bottom: 34,
+ right: 8,
+ fontSize: 14,
+ }}
+ toastOptions={{
+ style: {
+ background: "#4D4D4D",
+ color: "#B9BBBE",
+ borderRadius: 4,
+ },
+ }}
+ />
<MantineProvider forceColorScheme={darkmodeEnabled ? "dark" : "light"}>
- <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
+ <QueryClientProvider client={queryClient}>
+ <ModalController />
+ {children}
+ </QueryClientProvider>
</MantineProvider>
</ThemeProvider>
);
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx
index 34751897..52f7d2ad 100644
--- a/src/pages/_app.tsx
+++ b/src/pages/_app.tsx
@@ -23,9 +23,7 @@ const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID;
ReactGA.initialize(GA_TRACKING_ID, { testMode: isDevelopment });
-const Toaster = dynamic(() => import("react-hot-toast").then(c => c.Toaster));
const ExternalMode = dynamic(() => import("src/layout/ExternalMode"));
-const ModalController = dynamic(() => import("src/layout/ModalController"));
function JsonCrack({
Component,
@@ -64,22 +62,6 @@ function JsonCrack({
<ThemeProvider theme={lightTheme}>
<GlobalStyle />
<Component {...pageProps} />
- <ModalController />
- <Toaster
- position="bottom-right"
- containerStyle={{
- bottom: 34,
- right: 8,
- fontSize: 14,
- }}
- toastOptions={{
- style: {
- background: "#4D4D4D",
- color: "#B9BBBE",
- borderRadius: 4,
- },
- }}
- />
<ExternalMode />
</ThemeProvider>
</MantineProvider>
diff --git a/src/services/document.service.ts b/src/services/document.service.ts
index d043a82c..076a948b 100644
--- a/src/services/document.service.ts
+++ b/src/services/document.service.ts
@@ -1,4 +1,4 @@
-import { PostgrestSingleResponse } from "@supabase/supabase-js";
+import type { PostgrestSingleResponse } from "@supabase/supabase-js";
import toast from "react-hot-toast";
import { FileFormat } from "src/enums/file.enum";
import { supabase } from "src/lib/api/supabase";
diff --git a/src/store/useUser.ts b/src/store/useUser.ts
index 86f49e6f..cb86b29c 100644
--- a/src/store/useUser.ts
+++ b/src/store/useUser.ts
@@ -1,4 +1,4 @@
-import { Session, User } from "@supabase/supabase-js";
+import type { Session, User } from "@supabase/supabase-js";
import toast from "react-hot-toast";
import { create } from "zustand";
import { supabase } from "src/lib/api/supabase";