Merge pull request #1060 from sashokbg/feat/multiple_work_sections

feat: additional work sections
This commit is contained in:
Amruth Pillai
2022-11-13 10:28:28 +01:00
committed by GitHub
13 changed files with 184 additions and 38 deletions

View File

@ -9,6 +9,7 @@ export type ModalName =
| 'dashboard.import-external'
| 'dashboard.rename-resume'
| 'builder.sections.profile'
| 'builder.sections.work'
| `builder.sections.${string}`;
export type ModalState = {

View File

@ -1,4 +1,4 @@
import { ListItem, Profile, Resume, Section } from '@reactive-resume/schema';
import { ListItem, Profile, Resume, Section, SectionType } from '@reactive-resume/schema';
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import cloneDeep from 'lodash/cloneDeep';
import get from 'lodash/get';
@ -7,6 +7,8 @@ import pick from 'lodash/pick';
import set from 'lodash/set';
import { v4 as uuidv4 } from 'uuid';
import { getSectionsByType } from '@/config/sections';
type SetResumeStatePayload = { path: string; value: unknown };
type AddItemPayload = { path: string; value: ListItem };
@ -17,7 +19,7 @@ type DuplicateItemPayload = { path: string; value: ListItem };
type DeleteItemPayload = { path: string; value: ListItem };
type AddSectionPayload = { value: Section };
type AddSectionPayload = { value: Section; type: SectionType };
type DeleteSectionPayload = { path: string };
@ -80,6 +82,15 @@ export const resumeSlice = createSlice({
state.sections[id] = value;
state.metadata.layout[0][0].push(id);
},
duplicateSection: (state: Resume, action: PayloadAction<AddSectionPayload>) => {
const { value, type } = action.payload;
const id = getSectionsByType(state.sections, type).length + 1;
value.name = value.name + '-' + id;
state.sections[`${type}-${id}`] = value;
state.metadata.layout[0][0].push(`${type}-${id}`);
},
deleteSection: (state: Resume, action: PayloadAction<DeleteSectionPayload>) => {
const { path } = action.payload;
const id = path.split('.')[1];
@ -119,6 +130,7 @@ export const {
duplicateItem,
deleteItem,
addSection,
duplicateSection,
deleteSection,
addPage,
deletePage,