finalize json format, still not put to database

This commit is contained in:
Naytitorn Chaovirachot 2024-10-14 01:04:50 +07:00
parent d8a2f13d6c
commit a13a6112f9

View File

@ -19,12 +19,14 @@ export default function Apply() {
const [companyName, setCompanyName] = useState(""); const [companyName, setCompanyName] = useState("");
const [selectedIndustry, setSelectedIndustry] = useState(""); const [selectedIndustry, setSelectedIndustry] = useState("");
const [industry, setIndustry] = useState<string[]>([]); const [moneyRaisedToDate, setMoneyRaisedToDate] = useState("");
const [isInUS, setIsInUS] = useState(""); const [isInUS, setIsInUS] = useState("");
const [isForSale, setIsForSale] = useState(""); const [isForSale, setIsForSale] = useState("");
const [isGenerating, setIsGenerating] = useState(""); const [isGeneratingRevenue, setIsGeneratingRevenue] = useState("");
const [pitch, setPitch] = useState(""); const [businessPitch, setBusinessPitch] = useState("");
const [selectedCommunitySize, setSelectedCommunitySize] = useState("");
const [industry, setIndustry] = useState<string[]>([]);
const communitySize = [ const communitySize = [
"N/A", "N/A",
"0-5K", "0-5K",
@ -35,9 +37,10 @@ export default function Apply() {
"100K+", "100K+",
]; ];
// move to lib?
const fetchIndustry = async () => { const fetchIndustry = async () => {
let { data: BusinessType, error } = await supabase let { data: BusinessType, error } = await supabase
.from("BusinessType") .from("business_type")
.select("value"); .select("value");
if (!BusinessType) { if (!BusinessType) {
@ -50,14 +53,22 @@ export default function Apply() {
fetchIndustry(); fetchIndustry();
}, []); }, []);
/* temp */ const createFormat = () => ({
let format = {
"Company Name: ": companyName, "Company Name: ": companyName,
"Industry": selectedIndustry, "Industry": selectedIndustry,
} "Money Raised to Date": moneyRaisedToDate,
"Is in USA": isInUS,
"Is for sale": isForSale,
"Is generating revenue": isGeneratingRevenue,
"Business Pitch": businessPitch,
"Community Size": selectedCommunitySize,
"Created At": new Date().toString()
});
/* TEMP log */ const submitApplication = () => {
const submitApplication = () => alert(JSON.stringify(format)); let format = createFormat();
alert(JSON.stringify(format));
}
return ( return (
<div> <div>
@ -126,6 +137,7 @@ export default function Apply() {
</Label> </Label>
<div className="flex space-x-5"> <div className="flex space-x-5">
<Input <Input
onChange={(event) => setMoneyRaisedToDate(event.target.value)}
type="text" type="text"
id="companyName" id="companyName"
className="w-96" className="w-96"
@ -210,15 +222,15 @@ export default function Apply() {
<div className="flex space-x-5"> <div className="flex space-x-5">
<div className="flex space-x-2 w-96"> <div className="flex space-x-2 w-96">
<Button <Button
variant={isGenerating === "Yes" ? "default" : "outline"} variant={isGeneratingRevenue === "Yes" ? "default" : "outline"}
onClick={() => setIsGenerating("Yes")} onClick={() => setIsGeneratingRevenue("Yes")}
className="w-20 h-12 text-base" className="w-20 h-12 text-base"
> >
Yes Yes
</Button> </Button>
<Button <Button
variant={isGenerating === "No" ? "default" : "outline"} variant={isGeneratingRevenue === "No" ? "default" : "outline"}
onClick={() => setIsGenerating("No")} onClick={() => setIsGeneratingRevenue("No")}
className="w-20 h-12 text-base" className="w-20 h-12 text-base"
> >
No No
@ -238,15 +250,15 @@ export default function Apply() {
</Label> </Label>
<div className="flex space-x-2 w-96"> <div className="flex space-x-2 w-96">
<Button <Button
variant={pitch === "text" ? "default" : "outline"} variant={businessPitch === "text" ? "default" : "outline"}
onClick={() => setPitch("text")} onClick={() => setBusinessPitch("text")}
className="w-32 h-12 text-base" className="w-32 h-12 text-base"
> >
Paste URL Paste URL
</Button> </Button>
<Button <Button
variant={pitch === "file" ? "default" : "outline"} variant={businessPitch === "file" ? "default" : "outline"}
onClick={() => setPitch("file")} onClick={() => setBusinessPitch("file")}
className="w-32 h-12 text-base" className="w-32 h-12 text-base"
> >
Upload a file Upload a file
@ -254,7 +266,7 @@ export default function Apply() {
</div> </div>
<div className="flex space-x-5"> <div className="flex space-x-5">
<Input <Input
type={pitch} type={businessPitch}
id="companyName" id="companyName"
className="w-96" className="w-96"
placeholder="https:// " placeholder="https:// "
@ -276,7 +288,7 @@ export default function Apply() {
What{"'"}s the rough size of your <br /> community? What{"'"}s the rough size of your <br /> community?
</Label> </Label>
<div className="flex space-x-5"> <div className="flex space-x-5">
<Select> <Select onValueChange={(value) => setSelectedCommunitySize(value)}>
<SelectTrigger className="w-96"> <SelectTrigger className="w-96">
<SelectValue placeholder="Select" /> <SelectValue placeholder="Select" />
</SelectTrigger> </SelectTrigger>