From 50525ad8810de356856eb098a1e0882ce3607b9f Mon Sep 17 00:00:00 2001
From: Sebastien Castiel <sebastien@castiel.me>
Date: Wed, 14 Feb 2024 09:45:10 -0500
Subject: Add cancel button on expense form (fixes #92)

---
 src/components/group-form.tsx | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

(limited to 'src/components/group-form.tsx')

diff --git a/src/components/group-form.tsx b/src/components/group-form.tsx
index 27555ec..886070c 100644
--- a/src/components/group-form.tsx
+++ b/src/components/group-form.tsx
@@ -35,6 +35,7 @@ import { getGroup } from '@/lib/api'
 import { GroupFormValues, groupFormSchema } from '@/lib/schemas'
 import { zodResolver } from '@hookform/resolvers/zod'
 import { Save, Trash2 } from 'lucide-react'
+import Link from 'next/link'
 import { useEffect, useState } from 'react'
 import { useFieldArray, useForm } from 'react-hook-form'
 
@@ -272,13 +273,19 @@ export function GroupForm({
           </CardContent>
         </Card>
 
-        <SubmitButton
-          size="lg"
-          loadingContent={group ? 'Saving…' : 'Creating…'}
-          onClick={updateActiveUser}
-        >
-          <Save className="w-4 h-4 mr-2" /> {group ? <>Save</> : <> Create</>}
-        </SubmitButton>
+        <div className="flex mt-4 gap-2">
+          <SubmitButton
+            loadingContent={group ? 'Saving…' : 'Creating…'}
+            onClick={updateActiveUser}
+          >
+            <Save className="w-4 h-4 mr-2" /> {group ? <>Save</> : <> Create</>}
+          </SubmitButton>
+          {!group && (
+            <Button variant="ghost" asChild>
+              <Link href="/groups">Cancel</Link>
+            </Button>
+          )}
+        </div>
       </form>
     </Form>
   )
-- 
cgit v1.3

