summaryrefslogtreecommitdiff
path: root/src/common/stores/useLoginStore.ts
blob: 7b4551c6246f2c138a84fd89b952aad5dbcae61d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { create } from "zustand";

type State = {
  form: {
    username: string;
    password: string;
  };
};

type Action = {
  updateForm: (name: string, value: string) => void;
};

export const useLoginStore = create<State & Action>((set) => ({
  form: {
    username: "",
    password: "",
  },
  updateForm: (name, value) =>
    set((state) => ({
      form: {
        ...state.form,
        [name]: value,
      },
    })),
}));