From de7f174158e4f4756417f64b4eb5eb0652019ecb Mon Sep 17 00:00:00 2001 From: Saugat Maharjan Date: Thu, 18 Jan 2024 12:54:39 +0545 Subject: [PATCH 1/2] OUT-31 form bug fixes - [x] retain saved message even when response type chages - [x] call reset function with updated data to reset isDirty - [x] removed Next server action experimental feature flag - [x] update next version to latest --- next.config.js | 6 +----- package.json | 2 +- src/app/components/AutoResponder.tsx | 16 +--------------- src/app/page.tsx | 1 - yarn.lock | 2 +- 5 files changed, 4 insertions(+), 23 deletions(-) diff --git a/next.config.js b/next.config.js index 63ebb36..22478d5 100644 --- a/next.config.js +++ b/next.config.js @@ -1,10 +1,6 @@ /** @type {import('next').NextConfig} */ const withSvgr = require('next-plugin-svgr'); -const nextConfig = { - experimental: { - serverActions: true, - }, -}; +const nextConfig = {}; module.exports = withSvgr(nextConfig); diff --git a/package.json b/package.json index d72b3f3..b4c2599 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@radix-ui/react-select": "^2.0.0", "@vercel/postgres": "^0.5.0", "copilot-node-sdk": "^0.0.45", - "next": "latest", + "next": "^14.0.4", "next-plugin-svgr": "^1.1.8", "prisma": "^5.4.2", "react": "latest", diff --git a/src/app/components/AutoResponder.tsx b/src/app/components/AutoResponder.tsx index 7367eb2..2590604 100644 --- a/src/app/components/AutoResponder.tsx +++ b/src/app/components/AutoResponder.tsx @@ -183,9 +183,6 @@ const AutoResponder = ({ onSave, activeSettings }: Props) => { setValue('timezone', null, { shouldValidate: true, }); - setValue('response', null, { - shouldValidate: true, - }); } if (autoRespond === SettingType.ENABLED) { setValue('timezone', null, { @@ -194,9 +191,6 @@ const AutoResponder = ({ onSave, activeSettings }: Props) => { setValue('selectedDays', null, { shouldValidate: true, }); - setValue('response', "Thanks for your message. We'll get back to you shortly.", { - shouldValidate: true, - }); } if (autoRespond === SettingType.OUTSIDE_WORKING_HOURS) { setValue('timezone', Intl.DateTimeFormat().resolvedOptions().timeZone, { @@ -205,14 +199,6 @@ const AutoResponder = ({ onSave, activeSettings }: Props) => { setValue('selectedDays', defaultSelectedDays, { shouldValidate: true, }); - - setValue( - 'response', - "Thanks for your message. You've reached us outside our working hours. We'll get back to you within 24 hours.", - { - shouldValidate: true, - }, - ); } } }, [autoRespond]); @@ -265,7 +251,7 @@ const AutoResponder = ({ onSave, activeSettings }: Props) => { setSaving(true); await onSave(data); setSaving(false); - reset({}, { keepValues: true }); + reset(data); setWorkingHoursErrors({}); defaultFormValues.current = data; }; diff --git a/src/app/page.tsx b/src/app/page.tsx index c6412c7..3fcc05e 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -52,7 +52,6 @@ export default async function Page({ searchParams }: { searchParams: SearchParam const setting = await settingsService.findByUserId(me?.id as string); const saveSettings = async (data: SettingsData) => { 'use server'; - const setting = { type: data.autoRespond, message: data.response, diff --git a/yarn.lock b/yarn.lock index 191edfd..309e640 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4014,7 +4014,7 @@ next-plugin-svgr@^1.1.8: "@svgr/webpack" "^8.1.0" file-loader "^6.2.0" -next@^14.0.2, next@latest: +next@^14.0.2, next@^14.0.4: version "14.0.4" resolved "https://registry.yarnpkg.com/next/-/next-14.0.4.tgz#bf00b6f835b20d10a5057838fa2dfced1d0d84dc" integrity sha512-qbwypnM7327SadwFtxXnQdGiKpkuhaRLE2uq62/nRul9cj9KhQ5LhHmlziTNqUidZotw/Q1I9OjirBROdUJNgA== From 63d2e2679b229d19e469387b75088712c30b7501 Mon Sep 17 00:00:00 2001 From: Saugat Maharjan Date: Thu, 25 Jan 2024 11:18:26 +0545 Subject: [PATCH 2/2] OUT-31 fix eslint warning --- src/config/app.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config/app.ts b/src/config/app.ts index 7aa4be9..17d0342 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -1,4 +1,6 @@ -export default { +const appConfig = { copilotApiKey: process.env.COPILOT_API_KEY || '', webhookSigningSecret: process.env.WEBHOOK_SIGNING_SECRET || '', }; + +export default appConfig;