github.com/minio/console@v1.4.1/web-app/src/screens/Console/Support/registerSlice.ts (about)

     1  // This file is part of MinIO Console Server
     2  // Copyright (c) 2023 MinIO, Inc.
     3  //
     4  // This program is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Affero General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // This program is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  // GNU Affero General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Affero General Public License
    15  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16  
    17  import { createSlice, PayloadAction } from "@reduxjs/toolkit";
    18  import { SubnetInfo, SubnetOrganization } from "../License/types";
    19  
    20  export interface RegisterState {
    21    license: string;
    22    subnetPassword: string;
    23    subnetEmail: string;
    24    subnetMFAToken: string;
    25    subnetOTP: string;
    26    subnetAccessToken: string;
    27    selectedSubnetOrganization: string;
    28    subnetRegToken: string;
    29    subnetOrganizations: SubnetOrganization[];
    30    loading: boolean;
    31    loadingLicenseInfo: boolean;
    32    clusterRegistered: boolean;
    33    licenseInfo: SubnetInfo | undefined;
    34    curTab: string;
    35  }
    36  
    37  const initialState: RegisterState = {
    38    license: "",
    39    subnetPassword: "",
    40    subnetEmail: "",
    41    subnetMFAToken: "",
    42    subnetOTP: "",
    43    subnetAccessToken: "",
    44    selectedSubnetOrganization: "",
    45    subnetRegToken: "",
    46    subnetOrganizations: [],
    47    loading: false,
    48    loadingLicenseInfo: false,
    49    clusterRegistered: false,
    50    licenseInfo: undefined,
    51    curTab: "simple-tab-0",
    52  };
    53  
    54  export const registerSlice = createSlice({
    55    name: "register",
    56    initialState,
    57    reducers: {
    58      setLicense: (state, action: PayloadAction<string>) => {
    59        state.license = action.payload;
    60      },
    61      setSubnetPassword: (state, action: PayloadAction<string>) => {
    62        state.subnetPassword = action.payload;
    63      },
    64      setSubnetEmail: (state, action: PayloadAction<string>) => {
    65        state.subnetEmail = action.payload;
    66      },
    67      setSubnetMFAToken: (state, action: PayloadAction<string>) => {
    68        state.subnetMFAToken = action.payload;
    69      },
    70      setSubnetOTP: (state, action: PayloadAction<string>) => {
    71        state.subnetOTP = action.payload;
    72      },
    73      setSubnetAccessToken: (state, action: PayloadAction<string>) => {
    74        state.subnetAccessToken = action.payload;
    75      },
    76      setSelectedSubnetOrganization: (state, action: PayloadAction<string>) => {
    77        state.selectedSubnetOrganization = action.payload;
    78      },
    79      setSubnetRegToken: (state, action: PayloadAction<string>) => {
    80        state.subnetRegToken = action.payload;
    81      },
    82      setSubnetOrganizations: (
    83        state,
    84        action: PayloadAction<SubnetOrganization[]>,
    85      ) => {
    86        state.subnetOrganizations = action.payload;
    87      },
    88      setLoading: (state, action: PayloadAction<boolean>) => {
    89        state.loading = action.payload;
    90      },
    91      setLoadingLicenseInfo: (state, action: PayloadAction<boolean>) => {
    92        state.loadingLicenseInfo = action.payload;
    93      },
    94      setClusterRegistered: (state, action: PayloadAction<boolean>) => {
    95        state.clusterRegistered = action.payload;
    96      },
    97      setLicenseInfo: (state, action: PayloadAction<SubnetInfo | undefined>) => {
    98        state.licenseInfo = action.payload;
    99      },
   100      setCurTab: (state, action: PayloadAction<string>) => {
   101        state.curTab = action.payload;
   102      },
   103      resetRegisterForm: () => initialState,
   104    },
   105  });
   106  
   107  // Action creators are generated for each case reducer function
   108  export const {
   109    setLicense,
   110    setSubnetPassword,
   111    setSubnetEmail,
   112    setSubnetMFAToken,
   113    setSubnetOTP,
   114    setSubnetAccessToken,
   115    setSelectedSubnetOrganization,
   116    setSubnetRegToken,
   117    setSubnetOrganizations,
   118    setLoading,
   119    setLoadingLicenseInfo,
   120    setClusterRegistered,
   121    setLicenseInfo,
   122    setCurTab,
   123    resetRegisterForm,
   124  } = registerSlice.actions;
   125  
   126  export default registerSlice.reducer;