Skip to content

Commit

Permalink
fix: add missing button type (avoid submit form)
Browse files Browse the repository at this point in the history
  • Loading branch information
baptadn committed Oct 25, 2023
1 parent 60dcc9f commit c0b0838
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 34 deletions.
41 changes: 21 additions & 20 deletions src/components/digests/dialog/EditBookmarkDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getTweetId, isTwitterLink } from '@/utils/link';
import { BookmarkDigestStyle } from '@prisma/client';
import { AxiosError, AxiosResponse } from 'axios';
import { useParams } from 'next/navigation';
import React, { useEffect } from 'react';
import { useEffect } from 'react';
import { SubmitHandler, useForm } from 'react-hook-form';
import { useMutation } from 'react-query';
import Button from '../../Button';
Expand Down Expand Up @@ -153,17 +153,22 @@ export default function EditBookmarkDialog({
})}
/>
</fieldset>
<fieldset className="flex flex-col gap-2 w-full">
<label htmlFor="description">Description</label>
<TextArea className="min-h-[10rem]" {...register('description')} />
</fieldset>
<SummaryButton
url={url}
handleSuccess={(text) =>
setValue('description', text, { shouldDirty: true })
}
hasAccess={!!subscriptionId}
/>
<div className="w-full flex flex-col gap-3">
<fieldset className="flex flex-col gap-2 w-full">
<label htmlFor="description">Description</label>
<TextArea
className="min-h-[10rem]"
{...register('description')}
/>
</fieldset>
<SummaryButton
url={url}
handleSuccess={(text) =>
setValue('description', text, { shouldDirty: true })
}
hasAccess={!!subscriptionId}
/>
</div>
<fieldset className="flex flex-col gap-2 w-full">
<label htmlFor="style">
Style{' '}
Expand All @@ -177,21 +182,17 @@ export default function EditBookmarkDialog({
options={getStyleSelectOptions()}
/>
</fieldset>
<div className="flex justify-start gap-4 w-full items-center">
<div className="flex justify-between gap-4 w-full items-center">
<Button type="button" variant="ghost" onClick={closeDialog}>
Cancel
</Button>
<Button
isLoading={isRemoving || isRefreshing}
type="submit"
disabled={!isDirty}
>
Save
</Button>
<Button
type="button"
variant="destructiveGhost"
onClick={closeDialog}
>
Cancel
</Button>
</div>
</form>
</DialogContent>
Expand Down
8 changes: 5 additions & 3 deletions src/components/digests/dialog/SummaryButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ const SummaryButton = ({
if (!hasAccess) return null;

return (
<div className="flex flex-col justify-start w-full">
<span className="pb-2">Lacking inspiration ?</span>
<div className="flex flex-col items-end w-full">
<div>
<Button
size="sm"
variant="ghost"
type="button"
icon={<LightBulbIcon />}
onClick={() => {
generateSummary({ url });
}}
isLoading={isLoading}
loadingText="Generating"
>
Generate link summary
Generate Summary
</Button>
</div>
</div>
Expand Down
35 changes: 24 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4017,10 +4017,11 @@ brotli@^1.3.3:
dependencies:
base64-js "^1.1.2"

browser-request@*:
version "0.3.3"
resolved "https://registry.yarnpkg.com/browser-request/-/browser-request-0.3.3.tgz#9ece5b5aca89a29932242e18bf933def9876cc17"
integrity sha512-YyNI4qJJ+piQG6MMEuo7J3Bzaqssufx04zpEKYfSrl/1Op59HWali9zMtBpXnkmqMcOuWJPZvudrm9wISmnCbg==
"browser-request@github:postlight/browser-request#feat-add-headers-to-response":
version "0.3.2"
resolved "https://codeload.github.com/postlight/browser-request/tar.gz/38faa5b85741aabfca61aa37d1ef044d68969ddf"
dependencies:
http-headers "^3.0.1"

browserslist@^4.21.3:
version "4.21.7"
Expand Down Expand Up @@ -7160,6 +7161,13 @@ [email protected]:
statuses "2.0.1"
toidentifier "1.0.1"

http-headers@^3.0.1:
version "3.0.2"
resolved "https://registry.yarnpkg.com/http-headers/-/http-headers-3.0.2.tgz#5147771292f0b39d6778d930a3a59a76fc7ef44d"
integrity sha512-87E1I+2Wg4dxxz4rcxElo3dxO/w1ZtgL1yA0Sb6vH3qU16vRKq1NjWQv9SCY3ly2OQROcoxHZOUpmelS+k6wOw==
dependencies:
next-line "^1.1.0"

[email protected], http-proxy-agent@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz"
Expand Down Expand Up @@ -8228,7 +8236,7 @@ jose@^4.10.0, jose@^4.11.4:
resolved "https://registry.npmjs.org/jose/-/jose-4.13.1.tgz"
integrity sha512-MSJQC5vXco5Br38mzaQKiq9mwt7lwj2eXpgpRyQYNHYt2lq1PjkWa7DLXX0WVcQLE9HhMh3jPiufS7fhJf+CLQ==

jquery@*:
jquery@^3.5.0:
version "3.7.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.7.1.tgz#083ef98927c9a6a74d05a6af02806566d16274de"
integrity sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==
Expand Down Expand Up @@ -10028,14 +10036,14 @@ [email protected]:
resolved "https://registry.yarnpkg.com/moment-parseformat/-/moment-parseformat-3.0.0.tgz#3a1dc438b4bc073b7e93cc298cfb6c5daac26dba"
integrity sha512-dVgXe6b6DLnv4CHG7a1zUe5mSXaIZ3c6lSHm/EKeVeQI2/4pwe0VRde8OyoCE1Ro2lKT5P6uT9JElF7KDLV+jw==

moment-timezone@*:
version "0.5.43"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.43.tgz#3dd7f3d0c67f78c23cd1906b9b2137a09b3c4790"
integrity sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ==
moment-timezone@0.5.37:
version "0.5.37"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.37.tgz#adf97f719c4e458fdb12e2b4e87b8bec9f4eef1e"
integrity sha512-uEDzDNFhfaywRl+vwXxffjjq1q0Vzr+fcQpQ1bU0kbzorfS7zVtZnCnGc8mhWmF39d4g4YriF6kwA75mJKE/Zg==
dependencies:
moment "^2.29.4"
moment ">= 2.9.0"

moment@^2.23.0, moment@^2.29.4:
"moment@>= 2.9.0", moment@^2.23.0:
version "2.29.4"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==
Expand Down Expand Up @@ -10132,6 +10140,11 @@ next-contentlayer@^0.3.2:
"@contentlayer/core" "0.3.4"
"@contentlayer/utils" "0.3.4"

next-line@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/next-line/-/next-line-1.1.0.tgz#fcae57853052b6a9bae8208e40dd7d3c2d304603"
integrity sha512-+I10J3wKNoKddNxn0CNpoZ3eTZuqxjNM3b1GImVx22+ePI+Y15P8g/j3WsbP0fhzzrFzrtjOAoq5NCCucswXOQ==

next-superjson-plugin@^0.5.8:
version "0.5.8"
resolved "https://registry.npmjs.org/next-superjson-plugin/-/next-superjson-plugin-0.5.8.tgz"
Expand Down

1 comment on commit c0b0838

@vercel
Copy link

@vercel vercel bot commented on c0b0838 Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

digestclub – ./

digestclub-premieroctet.vercel.app
digestclub-git-main-premieroctet.vercel.app
digestclub.vercel.app

Please sign in to comment.