From fc76713edfc6f32f82d84d4532ecb3b422c60aed Mon Sep 17 00:00:00 2001 From: Philipp Rich Date: Sat, 9 Mar 2024 13:55:16 +0400 Subject: [PATCH] updated modules description --- serverActions/appendRecord.js | 16 +++++++++++++--- serverActions/getLatestRecord.js | 9 +++++++++ serverActions/getQuotes.js | 6 ++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/serverActions/appendRecord.js b/serverActions/appendRecord.js index 159725d..635aa80 100644 --- a/serverActions/appendRecord.js +++ b/serverActions/appendRecord.js @@ -1,3 +1,16 @@ +/* +Server action appends new record to mongoDB + +Record transformed before being appended. +- Added quotes +- Added date +- Removed institutions with 'isDeleted:true' +*/ + +// TODO add error handling to ui +// TODO add success handling to UI +// TODO prevent adding multiple records per month. Ask to override + "use server"; import Ajv from "ajv"; @@ -62,9 +75,6 @@ export async function appendRecord(formData) { if (!isFormDataValid) { throw new Error(`Provided data has wrong structure: ${ajv.errorsText()}`); } - // TODO add error handling to ui - // TODO add success handling to UI - // TODO prevent adding multiple records per month. Ask to override const recordInstitutions = formData.institutions .filter((institution) => !institution.isDeleted) diff --git a/serverActions/getLatestRecord.js b/serverActions/getLatestRecord.js index 564b83d..ddecc32 100644 --- a/serverActions/getLatestRecord.js +++ b/serverActions/getLatestRecord.js @@ -1,3 +1,12 @@ +/* +Server Action used to get latest record from mongodb. + +Latest record then transfomed into format, which is used by react-hook-form in RecordForm +as defaultValues. +*/ + +// TODO pass errors to RecordForm + "use server"; import connect from "utils/mongooseConnect"; diff --git a/serverActions/getQuotes.js b/serverActions/getQuotes.js index 581d10d..f74c96d 100644 --- a/serverActions/getQuotes.js +++ b/serverActions/getQuotes.js @@ -1,3 +1,9 @@ +/* +Helper server action which used in appendRecord() get quotes based on app's base +curencies list(currencies we need to calculate to) +and currencies from record being saved +*/ + "use server"; export async function getQuotes({ baseCurrencies, recordCurrencies }) {