Skip to content

Commit

Permalink
added feature to get the param from URL example https://localhost:300…
Browse files Browse the repository at this point in the history
…0?q=H2SO4
  • Loading branch information
Pradeepvarma333 committed Dec 12, 2023
1 parent fdb37e1 commit bd329c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TextField, Button, Typography } from '@mui/material';
import styles from './input-section.module.css';
import UploadIcon from '@mui/icons-material/Upload';
import React, { Dispatch, SetStateAction, useEffect, useState } from 'react';
import { useLocation } from 'react-router-dom';

const PLACEHOLDER_TEXT = 'ex. LiMn2O4';
const LABEL_TEXT = 'Chemical Composition';
Expand All @@ -13,11 +14,13 @@ interface InputSectionProps {
) => void;
handleSubmitClick: (inputText: string) => void;
handleEnterClick: (event: React.KeyboardEvent<HTMLInputElement>, inputText: string) => void;
inputFromUrl : any
}

const InputSection = ({ handleFileUpload, handleSubmitClick, handleEnterClick, inputFromUrl }: InputSectionProps) => {
const [inputText, setInputText] = useState(inputFromUrl);
const InputSection = ({ handleFileUpload, handleSubmitClick, handleEnterClick }: InputSectionProps) => {
const location = useLocation();
const param = new URLSearchParams(location.search);
const qparam = param.get('q');
const [inputText, setInputText] = useState(qparam||'');
if(inputText == null){
setInputText('')
}
Expand Down
5 changes: 0 additions & 5 deletions ui/src/pages/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ import DataViewer from '@/components/DataViewer/DataViewer';
import PageWrapper from '@/components/PageWrapper/PageWrapper';
import { useEffect} from 'react';
import useInputs from '@/features/input-submission/input-hooks/use-inputs';
import { useLocation } from 'react-router-dom';

function Home() {
const location = useLocation();
const { handleFileUpload, handleSubmitClick, handleEnterClick} = useInputs();
const param = new URLSearchParams(location.search);
const qparam = param.get('q');
useEffect(() => {
document.title = 'Oxidation State Analyzer';
}, []);
Expand Down Expand Up @@ -45,7 +41,6 @@ function Home() {
handleFileUpload={handleFileUpload}
handleSubmitClick={handleSubmitClick}
handleEnterClick={handleEnterClick}
inputFromUrl={qparam}
/>
</Grid>
</Grid>
Expand Down

0 comments on commit bd329c8

Please sign in to comment.