feat: add password input

This commit is contained in:
lemmyMwaura
2024-08-06 12:26:23 +03:00
parent 8e53a1b171
commit 0321ec32fb

View File

@@ -32,6 +32,7 @@ const viewLimitOptions = [
const schema = z.object({
name: z.string().optional(),
password: z.string().optional(),
secret: z.string(),
expiresIn: z.string(),
viewLimit: z.string(),
@@ -67,7 +68,7 @@ export const ShareSecretForm = ({ isPublic, value }: Props) => {
}
});
const onFormSubmit = async ({ name, secret, expiresIn, viewLimit, accessType }: FormData) => {
const onFormSubmit = async ({ name, password, secret, expiresIn, viewLimit, accessType }: FormData) => {
try {
const expiresAt = new Date(new Date().getTime() + Number(expiresIn));
@@ -80,6 +81,7 @@ export const ShareSecretForm = ({ isPublic, value }: Props) => {
const { id } = await createSharedSecret.mutateAsync({
name,
password,
encryptedValue: ciphertext,
hashedHex,
iv,
@@ -149,6 +151,19 @@ export const ShareSecretForm = ({ isPublic, value }: Props) => {
</FormControl>
)}
/>
<Controller
control={control}
name="password"
render={({ field, fieldState: { error } }) => (
<FormControl
label="Password (Optional)"
isError={Boolean(error)}
errorText={error?.message}
>
<Input {...field} placeholder="Password" type="text" />
</FormControl>
)}
/>
<Controller
control={control}
name="expiresIn"