fix(dashboard): fix issues where info can accidentally be removed by a save
This commit is contained in:
@@ -32,7 +32,7 @@ const validator = zProject.pick({
|
||||
type IForm = z.infer<typeof validator>;
|
||||
|
||||
export default function EditProjectDetails({ project }: Props) {
|
||||
const [hasDomain, setHasDomain] = useState(true);
|
||||
const [hasDomain, setHasDomain] = useState(project.domain !== null);
|
||||
const form = useForm<IForm>({
|
||||
resolver: zodResolver(validator),
|
||||
defaultValues: {
|
||||
@@ -101,7 +101,7 @@ export default function EditProjectDetails({ project }: Props) {
|
||||
</div>
|
||||
<AnimateHeight open={hasDomain}>
|
||||
<Input
|
||||
placeholder="Domain"
|
||||
placeholder="https://example.com"
|
||||
{...form.register('domain')}
|
||||
className="mb-4"
|
||||
error={form.formState.errors.domain?.message}
|
||||
@@ -112,7 +112,10 @@ export default function EditProjectDetails({ project }: Props) {
|
||||
name="cors"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<WithLabel label="Cors">
|
||||
<WithLabel
|
||||
label="Cors"
|
||||
error={form.formState.errors.cors?.message}
|
||||
>
|
||||
<TagInput
|
||||
{...field}
|
||||
id="Cors"
|
||||
|
||||
@@ -51,9 +51,18 @@ export const projectRouter = createTRPCRouter({
|
||||
data: {
|
||||
name: input.name,
|
||||
crossDomain: input.crossDomain,
|
||||
filters: input.filters,
|
||||
domain: input.domain ? stripTrailingSlash(input.domain) : null,
|
||||
cors: input.cors?.map((c) => stripTrailingSlash(c)) || [],
|
||||
filters:
|
||||
input.filters === undefined ? undefined : input.filters || [],
|
||||
domain:
|
||||
input.domain === undefined
|
||||
? undefined
|
||||
: input.domain
|
||||
? stripTrailingSlash(input.domain)
|
||||
: null,
|
||||
cors:
|
||||
input.cors === undefined
|
||||
? undefined
|
||||
: input.cors.map((c) => stripTrailingSlash(c)) || [],
|
||||
},
|
||||
include: {
|
||||
clients: {
|
||||
|
||||
Reference in New Issue
Block a user