Skip to content

Commit

Permalink
♻️ vuex getters 수정
Browse files Browse the repository at this point in the history
  - id 파라미터전달
  • Loading branch information
padosum committed Feb 28, 2023
1 parent fbf70cc commit 5d68dba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/store/__tests__/getters.spec.ts
Expand Up @@ -21,7 +21,7 @@ describe('getters', () => {

const state = { learnsets };

const actual = getters.learnset(state, '1');
const actual = getters.learnset(state)('1');

expect(actual).toEqual([learnsets[0]]);
});
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('getters', () => {

const state = { learnsets };

const [learnset] = getters.learnset(state, '1');
const [learnset] = getters.learnset(state)('1');

const BASE_DATE = new Date('2023-02-27').getTime();
const actual = getters.reviewCards(state, learnset)(BASE_DATE);
Expand Down
8 changes: 5 additions & 3 deletions src/store/getters.ts
Expand Up @@ -2,9 +2,11 @@ import type { Card, Learnset } from '@/types/interfaces';
import type { RootState } from './state';

export const getters = {
learnset: (state: RootState, id: string): Learnset[] => {
return state.learnsets.filter((learnset) => learnset.id === id);
},
learnset:
(state: RootState) =>
(id: string): Learnset[] => {
return state.learnsets.filter((learnset) => learnset.id === id);
},
reviewCards:
(state: RootState, learnset: Learnset) =>
(baseDate = new Date().getTime()): Learnset => {
Expand Down

0 comments on commit 5d68dba

Please sign in to comment.