-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
197 lines (190 loc) · 4.87 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import Head from "next/head"
import { useState } from "react"
import {
Button,
Heading,
Flex,
Text,
Accordion,
AccordionItem,
AccordionButton,
AccordionPanel,
AccordionIcon,
Box,
Link,
HStack,
Divider,
} from "@chakra-ui/react"
import NextLink from "next/link"
import { Step, Steps, useSteps } from "chakra-ui-steps"
import { steps } from "@/data/steps"
export default function Home() {
const [input, setInput] = useState("")
const [output, setOutput] = useState("")
const { nextStep, prevStep, setStep, reset, activeStep } = useSteps({
initialStep: 0,
})
const [submitted, setSubmitted] = useState(false)
const changeInputType = (val) => {
setInput(val)
}
const outputHandler = (output) => {
setOutput((prev) => prev + output)
}
const toggleSumbitted = () => {
setSubmitted(true)
}
const restart = () => {
setSubmitted(!submitted)
}
return (
<>
<Head>
<title>Lirical App</title>
<meta name='viewport' content='width=device-width, initial-scale=1' />
<link rel='icon' href='/favicon.ico' />
</Head>
<Flex h='100vh' justifyContent='center' alignItems='flex-start'>
<Flex alignItems='center' flexDir='column' textAlign='center' pb={5}>
<HStack alignContent='center' mt={10}>
<Link fontSize={20} as={NextLink} color='brand.900' href='/'>
Home
</Link>
<Divider orientation='vertical' borderColor='brand.900' h={8} />
<Link
fontSize={20}
as={NextLink}
color='brand.900'
href='/subscribe'
>
Subscribe
</Link>
<Divider orientation='vertical' borderColor='brand.900' h={8} />
<Link fontSize={20} as={NextLink} color='brand.900' href='/account'>
Account
</Link>
</HStack>
<Steps mt={[0, 0, 20]} w='sm' p={5} activeStep={activeStep}>
{steps.map(({ label }, indx) => (
<Step key={indx}>
{(indx === 0 && steps[0].content(changeInputType)) ||
(indx === 1 &&
steps[1].content(input, outputHandler, toggleSumbitted)) ||
(indx === 2 && steps[2].content(output))}
</Step>
))}
</Steps>
{activeStep === steps.length ? (
<Flex direction='column' gap={5} p={4}>
<Text fontWeight='bold' color='brand.800'>
Would you like to start all over?
</Text>
<Button
bg='brand.900'
mx='auto'
size='md'
onClick={() => {
reset()
restart()
}}
_hover={{ background: "#f1ecaf" }}
>
Reset
</Button>
</Flex>
) : (
<Flex width='100%' justify='flex-end' pr={5}>
<Button
isDisabled={activeStep === 0}
mr={4}
onClick={prevStep}
size='sm'
variant='ghost'
_disabled={{
cursor: "not-allowed",
opacity: 0.2,
}}
_hover={
activeStep !== 0 && {
background: "brand.900",
color: "black",
}
}
color='brand.800'
>
Prev
</Button>
<Button
size='sm'
bg='brand.900'
onClick={nextStep}
_hover={{ background: "brand.800" }}
isDisabled={!input || (activeStep === 1 && !submitted)}
>
{activeStep === steps.length - 1 ? "Finish" : "Next"}
</Button>
</Flex>
)}
<Heading
mt={5}
w={["80%", "sm"]}
justifySelf='left'
color='brand.900'
size='lg'
>
Disclaimer
</Heading>
<Accordion
allowToggle
textAlign='left'
w={["80%", "xs"]}
color='brand.800'
>
<AccordionItem>
<h2>
<AccordionButton>
<Box as='span' flex='1' textAlign='left'>
Why is it saying my lyrics are inappropriate or offensive?
</Box>
<AccordionIcon />
</AccordionButton>
</h2>
<AccordionPanel pb={4}>
Besides the reason it gives you, it's because Open AI has
policies that prevent discrimination, harassment, and hate
speech. You may have to try again with different lyrics.
</AccordionPanel>
</AccordionItem>
<AccordionItem>
<h2>
<AccordionButton>
<Box as='span' flex='1' textAlign='left'>
How do I restart from the beginning?
</Box>
<AccordionIcon />
</AccordionButton>
</h2>
<AccordionPanel pb={4}>
Go to step 3, hit Finish and then hit Reset.
</AccordionPanel>
</AccordionItem>
<AccordionItem>
<h2>
<AccordionButton>
<Box as='span' flex='1' textAlign='left'>
There is an issue with my account.
</Box>
<AccordionIcon />
</AccordionButton>
</h2>
<AccordionPanel pb={4}>
Please email me at bustosandrew28@gmail.com with any account
issues.
</AccordionPanel>
</AccordionItem>
</Accordion>
</Flex>
</Flex>
</>
)
}