-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(create secret): create secret using backend endpoint (#3)
- Loading branch information
Showing
10 changed files
with
171 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { AxiosPromise, AxiosRequestConfig } from "axios"; | ||
import client from "config"; | ||
import { Secret } from "utils/interfaces/Secret"; | ||
|
||
export default function createSecret(data: Secret, config: AxiosRequestConfig = {}): AxiosPromise { | ||
return client.post("/secrets", data, config); | ||
} |
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,20 @@ | ||
import { makeStyles, Theme } from "@material-ui/core"; | ||
|
||
export const useStyles = makeStyles((theme: Theme) => ({ | ||
form: { | ||
display: "flex", | ||
flexDirection: "column", | ||
gap: theme.spacing(2), | ||
maxWidth: 400, | ||
margin: "auto", | ||
"& .MuiTextField-root": { | ||
width: "100%" | ||
} | ||
}, | ||
height__full: { | ||
height: "100%" | ||
}, | ||
hide: { | ||
display: "none" | ||
} | ||
})); |
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,24 @@ | ||
import { makeStyles, Theme } from "@material-ui/core"; | ||
|
||
export const useStyles = makeStyles((theme: Theme) => ({ | ||
root: { | ||
flexGrow: 1, | ||
padding: theme.spacing(2) | ||
}, | ||
h__full: { | ||
height: "100%" | ||
}, | ||
w__full: { | ||
width: "100%", | ||
position: "absolute", | ||
top: "50%", | ||
left: "50%", | ||
transform: "translate(-50%, -50%)" | ||
}, | ||
alert: { | ||
maxWidth: 400, | ||
margin: "0 auto", | ||
boxSizing: "border-box", | ||
marginBottom: "1rem" | ||
} | ||
})); |
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,3 @@ | ||
export * as createSecretStyles from "./createSecretStyles"; | ||
export * as footerStyles from "./footerStyles"; | ||
export * as createSecretFormStyles from "./createSecretFormStyles"; |
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,8 @@ | ||
import { FormikHelpers, FormikValues } from "formik"; | ||
import { ObjectSchema } from "yup"; | ||
|
||
export type CreateSecretFormProps = { | ||
onSubmit: (values: FormikValues, helpers: FormikHelpers<any>) => void; | ||
validationSchema: ObjectSchema<any>; | ||
initialValues: FormikValues; | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export type LifetimeValue = "5m" | "15m" | "30m" | "1h" | "2h" | "3h" | "24h" | "48h" | "72h" | "168h"; | ||
|
||
export interface Lifetime { | ||
label: string; | ||
value: string; | ||
value: LifetimeValue; | ||
} |
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,8 @@ | ||
export interface Secret { | ||
secret: string; | ||
password: string; | ||
accesses: number; | ||
lifetime: string; | ||
filename?: string; | ||
is_base64: false; | ||
} |
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,10 @@ | ||
import { Form } from "formik"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
export function preventNonNumericalInput(e: React.KeyboardEvent<typeof Form>) { | ||
e = e || window.event; | ||
const charCode = typeof e.which == "undefined" ? e.keyCode : e.which; | ||
const charStr = String.fromCharCode(charCode); | ||
|
||
if (!charStr.match(/^[0-9]+$/)) e.preventDefault(); | ||
} |