Skip to content

Commit

Permalink
relint
Browse files Browse the repository at this point in the history
  • Loading branch information
factoidforrest committed Feb 6, 2023
1 parent 980d76f commit 9567293
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 16 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ deploy-apigateway-to-firehose.ts
lunatrace/bsl/semgrep/
**/real-dependency-tree-hasura-output.ts
**/huge-docusaurus-tree-hasura-output.ts
**/backend-cdk/ts-output/**
21 changes: 20 additions & 1 deletion lunatrace/bsl/frontend/src/api/generated.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ query GetCurrentUserInfo($kratos_id: uuid!) {
users(where: {kratos_id: {_eq: $kratos_id}}) {
role
survey
id
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mutation UpdateUserSurvey($id: uuid!, $survey: jsonb!) {
update_users_by_pk(pk_columns: {id: $id}, _set: {survey: $survey}) {
id
}
}
6 changes: 6 additions & 0 deletions lunatrace/bsl/frontend/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ const appApi = generatedApi.enhanceEndpoints({
SetProjectFolderSettingsIgnore: {
invalidatesTags: ['ProjectDetails', 'Builds'],
},
UpdateUserSurvey: {
invalidatesTags: ['User'],
},
GetCurrentUserInfo: {
providesTags: ['User'],
},
},
});

Expand Down
62 changes: 48 additions & 14 deletions lunatrace/bsl/frontend/src/pages/homepage/NewCustomerSurvey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,48 @@
*
*/
import React, { FormEvent, useState } from 'react';
import { Button, Card, Col, FloatingLabel, Form, Row, Spinner } from 'react-bootstrap';
import { Button, Col, FloatingLabel, Form, Row } from 'react-bootstrap';
import { AiOutlineSearch } from 'react-icons/ai';
import { FiBriefcase } from 'react-icons/fi';
import { HiOutlineBuildingOffice2 } from 'react-icons/hi2';

import api from '../../api';
import { SpinIfLoading } from '../../components/SpinIfLoading';
import { User } from '../../types/user';

export const NewCustomerSurvey: React.FunctionComponent<{ user: User }> = ({ user }) => {
const [survey, setSurvey] = useState({ organization: '', role: '', hear_about_us: '' });

function submitForm(e: FormEvent<HTMLFormElement>) {
const [updateSurvey, updateSurveyResult] = api.useUpdateUserSurveyMutation();

async function submitForm(e: FormEvent<HTMLFormElement>) {
e.preventDefault();
console.log(e);
if (updateSurveyResult.isLoading) {
return;
}
await updateSurvey({ id: user.id, survey });
}
return (
<>
<div className="text-center mb-4">
<h1>Welcome to LunaTrace</h1>
<p>Answer a few quick questions first.</p>
<p>Please just answer a few quick questions first.</p>
</div>
<Row>
<Col sm={{ offset: 1, span: 10 }}>
<Form onSubmit={(e) => void submitForm(e)}>
<Row className="justify-content-center">
<Col md={6}>
<Form.Group className="mb-3" controlId="organization">
<FloatingLabel controlId="floatingInput" label="Your Company" className="mb-3">
<FloatingLabel
controlId="floatingInput"
label={(
<span>
<HiOutlineBuildingOffice2 size="20px" className="mb-1 me-1 lighter" /> Your Company
</span>
)}
className="mb-3"
>
<Form.Control
value={survey.organization}
onChange={(e) => setSurvey({ ...survey, organization: e.target.value })}
Expand All @@ -49,10 +67,18 @@ export const NewCustomerSurvey: React.FunctionComponent<{ user: User }> = ({ use
<Row className="justify-content-center">
<Col md={6}>
<Form.Group className="mb-3" controlId="organization">
<FloatingLabel controlId="floatingInput" label="Your Role" className="mb-3">
<FloatingLabel
controlId="floatingInput"
label={(
<span>
<FiBriefcase size="20px" className="mb-1 me-1 lighter" /> Your Role
</span>
)}
className="mb-3"
>
<Form.Control
value={survey.organization}
onChange={(e) => setSurvey({ ...survey, organization: e.target.value })}
value={survey.role}
onChange={(e) => setSurvey({ ...survey, role: e.target.value })}
required={true}
placeholder="enter project name"
/>
Expand All @@ -63,21 +89,29 @@ export const NewCustomerSurvey: React.FunctionComponent<{ user: User }> = ({ use
<Row className="justify-content-center">
<Col md={6}>
<Form.Group className="mb-3" controlId="organization">
<Form.Label controlId="floatingInput" label="How did you hear about us?" className="mb-3">
<FloatingLabel
controlId="floatingInput"
label={(
<span>
<AiOutlineSearch size="20px" className="mb-1 me-1 lighter" /> How you heard about us
</span>
)}
className="mb-3"
>
<Form.Control
value={survey.organization}
onChange={(e) => setSurvey({ ...survey, organization: e.target.value })}
value={survey.hear_about_us}
onChange={(e) => setSurvey({ ...survey, hear_about_us: e.target.value })}
required={true}
placeholder="enter project name"
/>
</Form.Label>
</FloatingLabel>
</Form.Group>
</Col>
</Row>
<Row className="justify-content-center text-center">
<Col md={6} className="d-grid gap-2">
<Button size="lg" variant="primary" type="submit">
Try Lunatrace
<Button size="lg" variant="primary" disabled={updateSurveyResult.isLoading} type="submit">
<SpinIfLoading isLoading={updateSurveyResult.isLoading}>Submit</SpinIfLoading>
</Button>
</Col>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import React from 'react';
import { Helmet } from 'react-helmet-async';

import { Login } from '../../components/auth/Login';
import { LunaTraceIntroVideo } from '../../components/LunaTraceIntroVideo';
import { Login } from '../../components/auth/Login';

export const UnauthenticatedHome: React.FunctionComponent = (_props) => {
return (
Expand Down

0 comments on commit 9567293

Please sign in to comment.