Skip to content

Commit

Permalink
separate unhelpful comlum
Browse files Browse the repository at this point in the history
  • Loading branch information
mruwnik committed Oct 2, 2023
1 parent 5c0f905 commit 1932020
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/routes/questions/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {useState, useEffect, MouseEvent, useCallback, ReactNode} from 'react'
import type {ActionArgs} from '@remix-run/cloudflare'
import {Form, useSearchParams} from '@remix-run/react'
import {redirect, json} from '@remix-run/cloudflare'
import {makeColumnIncrementer, makeColumnDecrementer} from '~/server-utils/stampy'
import {makeColumnIncrementer} from '~/server-utils/stampy'
import {
DarkLight,
Edit,
Expand Down Expand Up @@ -63,7 +63,7 @@ const actions = {
unhelpful: {
Icon: Dislike,
title: 'Unhelpful',
handler: makeColumnDecrementer('Helpful'),
handler: makeColumnIncrementer('Unhelpful'),
},
hide: {
Icon: Hide,
Expand Down
4 changes: 1 addition & 3 deletions app/server-utils/stampy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ export const incAnswerColumn = async (column: string, pageid: PageId, subtract:
const incBy = subtract ? -1 : 1
const payload = {
row: {
cells: [{column, value: (row.values.Helpful || 0) + incBy}],
cells: [{column, value: (row.values[column] || 0) + incBy}],
},
}
const result = await sendToCoda(url, payload, 'PUT')
Expand All @@ -452,5 +452,3 @@ export const incAnswerColumn = async (column: string, pageid: PageId, subtract:

export const makeColumnIncrementer = (column: string) => (pageid: PageId, subtract: boolean) =>
incAnswerColumn(column, pageid, subtract)
export const makeColumnDecrementer = (column: string) => (pageid: PageId, subtract: boolean) =>
incAnswerColumn(column, pageid, !subtract)

0 comments on commit 1932020

Please sign in to comment.