migrate to app dir and ssr

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-01-20 22:54:38 +01:00
parent 719a82f1c4
commit 308ae98472
194 changed files with 4706 additions and 2194 deletions

View File

@@ -1,11 +1,12 @@
'use client';
import { api, handleError } from '@/app/_trpc/client';
import { ButtonContainer } from '@/components/ButtonContainer';
import { InputWithLabel } from '@/components/forms/InputWithLabel';
import { Button } from '@/components/ui/button';
import { toast } from '@/components/ui/use-toast';
import { useOrganizationParams } from '@/hooks/useOrganizationParams';
import { useRefetchActive } from '@/hooks/useRefetchActive';
import { api, handleError } from '@/utils/api';
import { zodResolver } from '@hookform/resolvers/zod';
import { useRouter } from 'next/navigation';
import { useForm } from 'react-hook-form';
import { z } from 'zod';
@@ -17,18 +18,19 @@ const validator = z.object({
});
type IForm = z.infer<typeof validator>;
export default function AddProject() {
const params = useOrganizationParams();
const refetch = useRefetchActive();
interface AddProjectProps {
organizationId: string;
}
export default function AddProject({ organizationId }: AddProjectProps) {
const router = useRouter();
const mutation = api.project.create.useMutation({
onError: handleError,
onSuccess() {
router.refresh();
toast({
title: 'Success',
description: 'Project created! Lets create a client for it 🤘',
});
refetch();
popModal();
},
});
@@ -46,11 +48,17 @@ export default function AddProject() {
onSubmit={handleSubmit((values) => {
mutation.mutate({
...values,
organizationSlug: params.organization,
organizationId,
});
})}
>
<InputWithLabel label="Name" placeholder="Name" {...register('name')} />
<div className="flex flex-col gap-4">
<InputWithLabel
label="Name"
placeholder="Name"
{...register('name')}
/>
</div>
<ButtonContainer>
<Button type="button" variant="outline" onClick={() => popModal()}>
Cancel