From 5c0f90550878366d0de0fcc1f1eeca8a1fbf1e4a Mon Sep 17 00:00:00 2001 From: Daniel O'Connell Date: Sun, 1 Oct 2023 11:47:27 +0200 Subject: [PATCH 1/2] Add unhelpful button --- app/assets/icons/dislike.svg | 28 +++++++++++++++++ app/components/icons-generated/Dislike.js | 38 +++++++++++++++++++++++ app/components/icons-generated/index.js | 1 + app/routes/questions/$question.tsx | 1 + app/routes/questions/actions.tsx | 19 ++++++++++-- app/server-utils/stampy.ts | 2 ++ 6 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 app/assets/icons/dislike.svg create mode 100644 app/components/icons-generated/Dislike.js diff --git a/app/assets/icons/dislike.svg b/app/assets/icons/dislike.svg new file mode 100644 index 00000000..406bb56b --- /dev/null +++ b/app/assets/icons/dislike.svg @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/app/components/icons-generated/Dislike.js b/app/components/icons-generated/Dislike.js new file mode 100644 index 00000000..cdbfef87 --- /dev/null +++ b/app/components/icons-generated/Dislike.js @@ -0,0 +1,38 @@ +import * as React from 'react' +const SvgDislike = (props) => ( + + + + + + +) +export default SvgDislike diff --git a/app/components/icons-generated/index.js b/app/components/icons-generated/index.js index e88c7969..03da66c1 100644 --- a/app/components/icons-generated/index.js +++ b/app/components/icons-generated/index.js @@ -1,6 +1,7 @@ export {default as Code} from './Code' export {default as DarkLight} from './DarkLight' export {default as Discord} from './Discord' +export {default as Dislike} from './Dislike' export {default as Edit} from './Edit' export {default as Ellipsis} from './Ellipsis' export {default as Flag} from './Flag' diff --git a/app/routes/questions/$question.tsx b/app/routes/questions/$question.tsx index b9765e28..672fa044 100644 --- a/app/routes/questions/$question.tsx +++ b/app/routes/questions/$question.tsx @@ -155,6 +155,7 @@ export function Question({
+ {answerEditLink && ( // TODO: on the first click (remember in localstorage), display a disclaimer popup text from https://stampy.ai/wiki/Edit_popup (pageid: PageId, subtract: boolean) => incAnswerColumn(column, pageid, subtract) +export const makeColumnDecrementer = (column: string) => (pageid: PageId, subtract: boolean) => + incAnswerColumn(column, pageid, !subtract) From 1932020ad008e8cf4f59ae99210750e7e6cee4e1 Mon Sep 17 00:00:00 2001 From: Daniel O'Connell Date: Mon, 2 Oct 2023 20:29:47 +0200 Subject: [PATCH 2/2] separate unhelpful comlum --- app/routes/questions/actions.tsx | 4 ++-- app/server-utils/stampy.ts | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/routes/questions/actions.tsx b/app/routes/questions/actions.tsx index fb9c90cd..cdc31c49 100644 --- a/app/routes/questions/actions.tsx +++ b/app/routes/questions/actions.tsx @@ -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, @@ -63,7 +63,7 @@ const actions = { unhelpful: { Icon: Dislike, title: 'Unhelpful', - handler: makeColumnDecrementer('Helpful'), + handler: makeColumnIncrementer('Unhelpful'), }, hide: { Icon: Hide, diff --git a/app/server-utils/stampy.ts b/app/server-utils/stampy.ts index d8db55aa..b8e2aa3e 100644 --- a/app/server-utils/stampy.ts +++ b/app/server-utils/stampy.ts @@ -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') @@ -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)