Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createContestReducer() {
const builder = TypedReducer.builder();
builder.withHandler(PutContest.TYPE, (state, payload) => ({ value: payload }));
builder.withHandler(DelContest.TYPE, () => ({ value: undefined }));
builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));
return builder.build();
}
const createSessionReducer = () => {
const builder = TypedReducer.builder();
builder.withHandler(PutToken.TYPE, (state, payload) => ({
isLoggedIn: true,
token: payload,
}));
builder.withHandler(PutUser.TYPE, (state, payload) => setWith(state, { user: payload }));
builder.withHandler(DelSession.TYPE, () => INITIAL_STATE);
builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));
return builder.build();
};
const createBreadcrumbsReducer = () => {
const builder = TypedReducer.builder();
builder.withHandler(PushBreadcrumb.TYPE, (state, { link, ...rest }) => ({
values: [...state.values, { link: cleanLink(link), ...rest }],
}));
builder.withHandler(PopBreadcrumb.TYPE, (state, payload) => ({
values: state.values.filter(b => b.link !== cleanLink(payload.link)),
}));
builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));
return builder.build();
};
function createWebPrefsReducer() {
const builder = TypedReducer.builder();
builder.withHandler(PutStatementLanguage.TYPE, (state, statementLanguage) => setWith(state, { statementLanguage }));
builder.withHandler(PutGradingLanguage.TYPE, (state, gradingLanguage) => setWith(state, { gradingLanguage }));
builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));
return builder.build();
}
function createRoleReducer() {
const builder = TypedReducer.builder();
builder.withHandler(PutRole.TYPE, (state, payload) => ({ value: payload }));
builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));
return builder.build();
}
function createWebConfigReducer() {
const builder = TypedReducer.builder();
builder.withHandler(PutWebConfig.TYPE, (state, payload) => ({ value: payload }));
builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));
return builder.build();
}
function createCourseReducer() {
const builder = TypedReducer.builder();
builder.withHandler(PutCourse.TYPE, (state, payload) => setWith(state, { value: payload }));
builder.withHandler(DelCourse.TYPE, () => ({ value: undefined }));
builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));
return builder.build();
}
function createPublicProfileReducer() {
const builder = TypedReducer.builder();
builder.withHandler(PutPublicProfile.TYPE, (state, payload) => ({ value: payload }));
builder.withHandler(DelPublicProfile.TYPE, () => ({ value: undefined }));
builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));
return builder.build();
}
function createReducer() {
return TypedReducer.builder()
.withHandler(Actions.NotesLoaded.TYPE, (state, payload) => {
if (payload.notes.length === 0) {
return { id: null };
}
return { id: sortNotes(payload.notes)[0].id };
})
.withHandler(Actions.NoteSelected.TYPE, (state, payload) => {
return { id: payload.noteId };
})
.build();
}
function createProfileReducer() {
const builder = TypedReducer.builder();
builder.withHandler(PutUser.TYPE, (state, payload) => payload);
builder.withHandler(DelUser.TYPE, () => ({ userJid: undefined, username: undefined }));
builder.withDefaultHandler(state => (state !== undefined ? state : INITIAL_STATE));
return builder.build();
}