Skip to main content

add-project

Adding a project. Multiple projects can be set for one organisation

  • localhost:3000/add-project

Project data is available via Supabase client import { supabase } from "@utils/supabaseClient";

Project add function. A new project is linked to the organisation for the user that is logged in.

src/pages/add-project.js
async function addProject() {
try {
setLoading(true);

const dataEnter = {
name: projectName.entry,
target: projectTarget.entry,
target_malaria: projectTargetMalaria.entry,
target_tb: projectTargetTB.entry,
organisation: organisation,
};

const { data, error } = await supabase
.from("projects")
.insert(dataEnter)
.select();

if (error) {
throw error;
}
} catch (error) {
alert(error.message);
} finally {
setLoading(false);
console.log("record created");
setProjectCreated(true);
}
}