-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from bleu/jean/cow-407-add-vest-all-available-…
…option-on-vesting-hook Add vest all option in create vesting
- Loading branch information
Showing
58 changed files
with
570 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Input, Label } from "@bleu/ui"; | ||
import React, { useEffect } from "react"; | ||
import { useFormContext } from "react-hook-form"; | ||
import { useTokenAmountTypeContext } from "#/context/TokenAmountType"; | ||
|
||
export const FormCheckbox = ({ | ||
name, | ||
state, | ||
setState, | ||
label, | ||
}: { | ||
name: string; | ||
state: boolean; | ||
setState: (state: boolean) => void; | ||
label?: string; | ||
}) => { | ||
const { setValue } = useFormContext(); | ||
|
||
useEffect(() => { | ||
setValue("amount", ""); | ||
setValue(name, state); | ||
}, [name, state, setValue]); | ||
|
||
return ( | ||
<div className="flex items-center space-x-2"> | ||
<Input | ||
type="checkbox" | ||
id={name} | ||
name={name} | ||
checked={state} | ||
onChange={() => setState(!state)} | ||
className="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600" | ||
/> | ||
<Label | ||
htmlFor={name} | ||
className="text-sm font-medium text-gray-900 dark:text-gray-300" | ||
> | ||
{label} | ||
</Label> | ||
</div> | ||
); | ||
}; | ||
|
||
export const VestAllFromSwapCheckbox = () => { | ||
const { vestAllFromSwap, setVestAllFromSwap } = useTokenAmountTypeContext(); | ||
return ( | ||
<FormCheckbox | ||
name="vestAllFromSwap" | ||
state={vestAllFromSwap} | ||
setState={setVestAllFromSwap} | ||
label="Use all tokens from swap" | ||
/> | ||
); | ||
}; | ||
|
||
export const VestAllFromAccountCheckbox = () => { | ||
const { vestAllFromAccount, setVestAllFromAccount } = | ||
useTokenAmountTypeContext(); | ||
return ( | ||
<FormCheckbox | ||
name="vestAllFromAccount" | ||
state={vestAllFromAccount} | ||
setState={setVestAllFromAccount} | ||
label="Use all your tokens after swap" | ||
/> | ||
); | ||
}; |
32 changes: 0 additions & 32 deletions
32
apps/create-vesting/src/components/VestAllFromSwapCheckbox.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.