enBloc-org / kindly

GNU General Public License v3.0
17 stars 22 forks source link

#193/add an option to edit created items #225

Closed Edga380 closed 3 months ago

Edga380 commented 4 months ago

Checklist:

Description

Closes #193

Files changed

New files/folders

UI changes

Changes to Documentation

None

Tests

None

netlify[bot] commented 4 months ago

Deploy Preview for cool-creponne-3e1272 ready!

Name Link
Latest commit 5b8e9811b262a2728c361354ec59836347c4477d
Latest deploy log https://app.netlify.com/sites/cool-creponne-3e1272/deploys/66657c3a19db5d0008145f6e
Deploy Preview https://deploy-preview-225--cool-creponne-3e1272.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Edga380 commented 4 months ago

@camelPhonso Thank you for a detail review of the pull request. I will deal with these suggestions/changes as soon as possible. 😊

Edga380 commented 4 months ago

@camelPhonso So I did all the changes I hope I did them correctly let me know if I misunderstand something and if it needs to be changed.

Also I added new file in "supabase/models/upsertRow.ts" to replace "editRow" function with "upsertRow" one it looks like it works as you mention it will. This make sense to use again like you said with one route we cover both use cases.

Here is the code I wrote inside the file:

import newClient from '../utils/newClient';
import { PartialItem } from '@/types/supabaseTypes';

export default async function upsertRow(
  table: string,
  upsertValues: PartialItem
) {
  const supabase = newClient();
  const { error } = await supabase.from(table).upsert(upsertValues);

  if (error) {
    console.log(error);
    return false;
  }

  return true;
}

I return a boolean value here because I want to know if it successful or not so I could show an error to the user if it failed to edit.