multi tenancy stuff

This commit is contained in:
m5r
2021-08-06 01:07:15 +08:00
parent b54f9ef43c
commit d20eeb0617
51 changed files with 907 additions and 2542 deletions

View File

@ -4,10 +4,8 @@ import clsx from "clsx";
import Button from "./button";
import SettingsSection from "./settings-section";
import Modal, { ModalTitle } from "./modal";
import useCurrentCustomer from "../../core/hooks/use-current-customer";
export default function DangerZone() {
const customer = useCurrentCustomer();
const [isDeletingUser, setIsDeletingUser] = useState(false);
const [isConfirmationModalOpen, setIsConfirmationModalOpen] = useState(false);
const modalCancelButtonRef = useRef<HTMLButtonElement>(null);

View File

@ -6,7 +6,7 @@ import { useForm } from "react-hook-form";
import Alert from "./alert";
import Button from "./button";
import SettingsSection from "./settings-section";
import useCurrentCustomer from "../../core/hooks/use-current-customer";
import useCurrentUser from "../../core/hooks/use-current-user";
import appLogger from "../../../integrations/logger";
@ -18,7 +18,7 @@ type Form = {
const logger = appLogger.child({ module: "profile-settings" });
const ProfileInformations: FunctionComponent = () => {
const { customer } = useCurrentCustomer();
const { user } = useCurrentUser();
const router = useRouter();
const {
register,
@ -29,9 +29,9 @@ const ProfileInformations: FunctionComponent = () => {
const [errorMessage, setErrorMessage] = useState("");
useEffect(() => {
setValue("name", customer?.user.name ?? "");
setValue("email", customer?.user.email ?? "");
}, [setValue, customer]);
setValue("name", user?.name ?? "");
setValue("email", user?.email ?? "");
}, [setValue, user]);
const onSubmit = handleSubmit(async ({ name, email }) => {
if (isSubmitting) {
@ -40,7 +40,7 @@ const ProfileInformations: FunctionComponent = () => {
try {
// TODO
// await customer.updateUser({ email, data: { name } });
// await updateUser({ email, data: { name } });
} catch (error) {
logger.error(error.response, "error updating user infos");

View File

@ -6,7 +6,6 @@ import { useForm } from "react-hook-form";
import Alert from "./alert";
import Button from "./button";
import SettingsSection from "./settings-section";
import useCurrentCustomer from "../../core/hooks/use-current-customer";
import appLogger from "../../../integrations/logger";
@ -18,7 +17,6 @@ type Form = {
};
const UpdatePassword: FunctionComponent = () => {
const customer = useCurrentCustomer();
const router = useRouter();
const {
register,