I have written some code that will take in user input from a few input boxes, and pass them to the corresponsing table on Supabase.
This is what the code looks like
const initialState = { solution_id: '', organization_id: '', budget_usd: '', other_info: '', country: '', project_duration_days: '', status: ''}
export default function Projects({ Projects }) {
useEffect(() => {
console.log(Projects)
}, [])
const [newProject, setProject] = useState(initialState)
console.log("User inputed data")
console.log(newProject)
const { solution_id, organization_id, budget_usd, other_info, country, project_duration_days, status } = newProject
console.log(solution_id)
console.log(budget_usd)
console.log(country)
const router = useRouter()
function onChange(e) {
setProject(() => ({ ...newProject, [e.target.name]: e.target.value }))
}
async function createNewProject() {
if (!solution_id || !organization_id || !country) return
console.log("Got to here")
console.log(newProject)
console.log("Got to here now")
console.log(newProject.solution_id)
console.log(newProject.country)
console.log("Got to here now")
let { data, error } = await supabase
.from('Projects')
.insert({ solution_id: newProject.solution_id, organization_id: newProject.organization_id, budget_usd: newProject.budget_usd, other_info: newProject.other_info, country: newProject.country, project_duration_days: newProject.project_duration_days, status: newProject.status })
.single();
console.log(data, error)
router.push(`/projects`)
}
This is what the supabase table for the Projects table looks like
However, everytime I press the submit button, I get this error on my browser
I am not sure why it keeps throwing this error, as I am not inputting any data that is overiding the primary key of the database