mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE): Add Zustand store for ProjectFlock management
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { create } from 'zustand';
|
||||||
|
import { devtools } from 'zustand/middleware';
|
||||||
|
import { createProjectFlockSlice } from '@/stores/project-flock/slices/project-flock.slice';
|
||||||
|
import { ProjectFlockSlice } from '@/types/stores';
|
||||||
|
|
||||||
|
export type ProjectFlockStore = ProjectFlockSlice;
|
||||||
|
|
||||||
|
export const useProjectFlockStore = create<ProjectFlockStore>()(
|
||||||
|
devtools(
|
||||||
|
(...args) => ({
|
||||||
|
...createProjectFlockSlice(...args),
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
name: 'ProjectFlockStore',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { ProjectFlockSlice } from '@/types/stores';
|
||||||
|
import { StateCreator } from 'zustand';
|
||||||
|
|
||||||
|
export const createProjectFlockSlice: StateCreator<
|
||||||
|
ProjectFlockSlice,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
ProjectFlockSlice
|
||||||
|
> = (set) => ({
|
||||||
|
// Initial state
|
||||||
|
isSuccess: false,
|
||||||
|
createdProjectFlock: null,
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
setIsSuccess: (success) => set({ isSuccess: success }),
|
||||||
|
|
||||||
|
setCreatedProjectFlock: (data) => set({ createdProjectFlock: data }),
|
||||||
|
|
||||||
|
resetProjectFlock: () =>
|
||||||
|
set({
|
||||||
|
isSuccess: false,
|
||||||
|
createdProjectFlock: null,
|
||||||
|
}),
|
||||||
|
});
|
||||||
Vendored
+12
@@ -5,6 +5,7 @@ import type {
|
|||||||
UniformityDetail,
|
UniformityDetail,
|
||||||
VerifyUniformityResponse,
|
VerifyUniformityResponse,
|
||||||
} from '@/types/api/production/uniformity';
|
} from '@/types/api/production/uniformity';
|
||||||
|
import type { ProjectFlock } from '@/types/api/production/project-flock';
|
||||||
|
|
||||||
type MainUiSlice = {
|
type MainUiSlice = {
|
||||||
mainDrawerOpen: boolean;
|
mainDrawerOpen: boolean;
|
||||||
@@ -97,3 +98,14 @@ export type DashboardFilterSlice = {
|
|||||||
setFilterValues: (values: DashboardFilterType) => void;
|
setFilterValues: (values: DashboardFilterType) => void;
|
||||||
resetFilterValues: () => void;
|
resetFilterValues: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ProjectFlockSlice = {
|
||||||
|
// State
|
||||||
|
isSuccess: boolean;
|
||||||
|
createdProjectFlock: ProjectFlock | null;
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
setIsSuccess: (success: boolean) => void;
|
||||||
|
setCreatedProjectFlock: (data: ProjectFlock | null) => void;
|
||||||
|
resetProjectFlock: () => void;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user