Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // form.slice.js
- import { createSlice } from '@reduxjs/toolkit';
- const initialState = {
- fields: [], // Initialize fields array
- address: '',
- city: '',
- province: '',
- zip: '',
- unit: '',
- propertySize: '',
- footageType: '',
- find: '',
- propertyType: '',
- propertyCondition: '',
- access: '',
- luckBox: '',
- customerCode: '',
- specialRequest: '',
- date: '',
- slot: '',
- firstName: '',
- lastName: '',
- email: '',
- phone: '',
- };
- const formSlice = createSlice({
- name: 'form',
- initialState,
- reducers: {
- updateField(state, action) {
- const { fieldId, value } = action.payload;
- const fieldIndex = state.fields.findIndex((field) => field.id === fieldId);
- if (fieldIndex !== -1) {
- state.fields[fieldIndex].value = value;
- }
- },
- // Add other reducers as needed
- },
- });
- export const { updateField } = formSlice.actions;
- export default formSlice.reducer;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement