Migrated create visit action to use payload

This commit is contained in:
Alejandro Celaya
2022-11-05 13:01:00 +01:00
parent cd90d3e581
commit d588d8d9ef
17 changed files with 54 additions and 51 deletions

View File

@@ -56,13 +56,13 @@ export default buildReducer<ShortUrlsList, ListShortUrlsCombinedAction>({
state,
)),
),
[CREATE_VISITS]: (state, { createdVisits }) => assocPath(
[CREATE_VISITS]: (state, { payload }) => assocPath(
['shortUrls', 'data'],
state.shortUrls?.data?.map(
(currentShortUrl) => {
// Find the last of the new visit for this short URL, and pick the amount of visits from it
const lastVisit = last(
createdVisits.filter(
payload.createdVisits.filter(
({ shortUrl }) => shortUrl && shortUrlMatches(currentShortUrl, shortUrl.shortCode, shortUrl.domain),
),
);