refactor(ui): refactor accesses state using zustand store

This commit is contained in:
Fu Diwei
2024-12-11 19:55:50 +08:00
parent b744363736
commit bb3009a124
48 changed files with 359 additions and 404 deletions

View File

@@ -2,7 +2,7 @@ import React, { useEffect } from "react";
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue } from "../ui/select";
import { accessProvidersMap } from "@/domain/access";
import { useTranslation } from "react-i18next";
import { useConfigContext } from "@/providers/config";
import { useAccessStore } from "@/stores/access";
import { deployTargetsMap } from "@/domain/domain";
type AccessSelectProps = {
@@ -13,9 +13,7 @@ type AccessSelectProps = {
const AccessSelect = ({ value, onValueChange, providerType }: AccessSelectProps) => {
const [localValue, setLocalValue] = React.useState<string>("");
const { t } = useTranslation();
const {
config: { accesses },
} = useConfigContext();
const { accesses } = useAccessStore();
useEffect(() => {
setLocalValue(value);

View File

@@ -15,8 +15,8 @@ import EmailsEdit from "@/components/certimate/EmailsEdit";
import StringList from "@/components/certimate/StringList";
import { accessProvidersMap } from "@/domain/access";
import { useAccessStore } from "@/stores/access";
import { useContactStore } from "@/stores/contact";
import { useConfigContext } from "@/providers/config";
import { Switch } from "@/components/ui/switch";
import { TooltipFast } from "@/components/ui/tooltip";
import { WorkflowNode, WorkflowNodeConfig } from "@/domain/workflow";
@@ -33,9 +33,7 @@ const selectState = (state: WorkflowState) => ({
const ApplyForm = ({ data }: ApplyFormProps) => {
const { updateNode } = useWorkflowStore(useShallow(selectState));
const {
config: { accesses },
} = useConfigContext();
const { accesses } = useAccessStore();
const { emails, fetchEmails } = useContactStore();
useEffect(() => {

View File

@@ -1,15 +1,13 @@
import { ConfigProvider } from "@/providers/config";
import React from "react";
import { PanelProvider } from "./PanelProvider";
import { NotifyProvider } from "@/providers/notify";
import { PanelProvider } from "./PanelProvider";
const WorkflowProvider = ({ children }: { children: React.ReactNode }) => {
return (
<ConfigProvider>
<NotifyProvider>
<PanelProvider>{children}</PanelProvider>
</NotifyProvider>
</ConfigProvider>
<NotifyProvider>
<PanelProvider>{children}</PanelProvider>
</NotifyProvider>
);
};