You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I created an org table with a RLS policy to enable only the org owner to insert it.
When I try to use the plugin to create a new org with this policy defaulting to false (just to try if RLS is working) the org gets created locally, although it fails to save on the backend, but I get no error back.
Would be great to listen for the result of the API, and in case we get an error, it rolls back the action and propagate the error back to the client.
import { createClient } from '@/lib/supabase/client'
import { observable } from '@legendapp/state'
import { configureSyncedSupabase, syncedSupabase } from '@legendapp/state/sync-plugins/supabase'
import { v4 as uuidv4 } from "uuid"
becasue the default behaviour adds a select after the insert and because I have a trigger that runs after the row is inserted and the RLS Policy depends on this trigger outcome, the select fails, but ir rolls back the entire commit, making the insert fail as well.
But I am not sure if this work around can mess other inner logics from legend state... Anyone can help confirming that? Many thanks!
I created an org table with a RLS policy to enable only the org owner to insert it.
When I try to use the plugin to create a new org with this policy defaulting to false (just to try if RLS is working) the org gets created locally, although it fails to save on the backend, but I get no error back.
Would be great to listen for the result of the API, and in case we get an error, it rolls back the action and propagate the error back to the client.
import { createClient } from '@/lib/supabase/client'
import { observable } from '@legendapp/state'
import { configureSyncedSupabase, syncedSupabase } from '@legendapp/state/sync-plugins/supabase'
import { v4 as uuidv4 } from "uuid"
const generateId = () => uuidv4()
configureSyncedSupabase({
generateId,
changesSince: 'last-sync',
fieldCreatedAt: 'created_at',
fieldUpdatedAt: 'updated_at',
fieldDeleted: 'deleted'
})
const supabase = createClient()
export const orgs$ = observable(
syncedSupabase({
supabase,
collection: 'org',
select: (from) => from.select("*"),
actions: ['read', 'create'],
})
)
'use client';
import { Input, Button } from "@nextui-org/react";
import { Eye, IdCard, Users } from "lucide-react";
import { useFormik } from "formik";
import { usePreferredLanguage } from "@uidotdev/usehooks";
import { addOrg } from "@/lib/legend"
import * as Yup from "yup";
export function Form({ handleClose }) {
})
return (
<Input
autoFocus
name="nome"
type="string"
isRequired
variant="underlined"
label="Nome"
placeholder="Nome"
labelPlacement="outside"
endContent={
}
value={form.values.nome}
onChange={form.handleChange('nome')}
onBlur={form.handleBlur('nome')}
errorMessage={form.errors.nome}
isInvalid={form.touched.nome && form.errors.hasOwnProperty('nome')}
/>
<Input
name="cnpj"
type="string"
isRequired
variant="underlined"
label="CNPJ"
placeholder="CNPJ"
labelPlacement="outside"
endContent={
}
value={form.values.cnpj}
onChange={form.handleChange('cnpj')}
onBlur={form.handleBlur('cnpj')}
errorMessage={form.errors.cnpj}
isInvalid={form.touched.cnpj && form.errors.hasOwnProperty('cnpj')}
/>
<Button fullWidth color="primary" onPress={form.handleSubmit} isLoading={form.isSubmitting} isDisabled={!form.isValid || form.isSubmitting}>
Salvar
);
}
The text was updated successfully, but these errors were encountered: