Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add language button #58

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/components/GeoViewMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import MenuIcon from '@mui/icons-material/Menu';
import DrawerTabs from './DrawerTabs';
import { CGPVContext } from '../providers/cgpvContextProvider/CGPVContextProvider';
import { MapRenderer } from './MapRenderer';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
import { useNavigate } from 'react-router-dom';
import { AppToolbar } from './AppToolbar';
import { useSearchParams } from "react-router-dom";
import { DEFAULT_CONFIG_FILE } from '@/constants';
Expand All @@ -20,7 +18,6 @@ interface GeoViewMapProps {

function GeoViewMap(props: GeoViewMapProps) {
const cgpvContext = useContext(CGPVContext);
const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();


Expand Down
23 changes: 16 additions & 7 deletions src/components/MapBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useContext, useState } from 'react';
import { CGPVContext } from '@/providers/cgpvContextProvider/CGPVContextProvider';
import _ from 'lodash';
import PillsAutoComplete from './PillsAutoComplete';
import { componentsOptions, footerTabslist, navBarOptions, appBarOptions, mapInteractionOptions, mapProjectionOptions, zoomOptions, themeOptions, CONFIG_FILES_LIST, corePackagesOptions } from '@/constants';
import { componentsOptions, footerTabslist, languageOptions, navBarOptions, appBarOptions, mapInteractionOptions, mapProjectionOptions, zoomOptions, themeOptions, CONFIG_FILES_LIST, corePackagesOptions } from '@/constants';
import SingleSelectComplete from './SingleSelectAutoComplete';
import { ConfigSaveUploadButtons } from './ConfigSaveUploadButtons';

Expand All @@ -25,11 +25,13 @@ export function MapBuilder() {
if (!cgpvContext) {
throw new Error('CGPVContent must be used within a CGPVProvider');
}

const { configJson,handleApplyStateToConfigFile, handleConfigFileChange, handleConfigJsonChange, configFilePath, mapWidth, mapHeight, setMapWidth, setMapHeight } = cgpvContext;
const { mapId } = cgpvContext;
const { configJson, handleApplyStateToConfigFile,handleConfigFileChange, handleConfigJsonChange, configFilePath, mapWidth, mapHeight, setMapWidth, setMapHeight } = cgpvContext;

const [modifiedConfigJson, setModifiedConfigJson] = useState<object>(configJson);
const [isModified, setIsModified] = useState<boolean>(false);
const [isEn, setEn] = useState<boolean>(true);


const _updateConfigProperty = (property: string, value: any) => {
const newConfig = { ...modifiedConfigJson };
Expand Down Expand Up @@ -73,8 +75,8 @@ export function MapBuilder() {
handleConfigJsonChange(modifiedConfigJson);
setIsModified(false);
}

return (
return(
<Box sx={{ display: 'flex', flexDirection: 'column' }}>

<ConfigSaveUploadButtons />
Expand Down Expand Up @@ -129,7 +131,14 @@ export function MapBuilder() {
</Box>
</FormGroup>

<Divider sx={{ my: 2 }} />
<SingleSelectComplete
options={languageOptions}
defaultValue={(isEn) ? 'English' : 'French'}
onChange={(event) => {
(isEn) ? cgpv.api.maps[mapId].setLanguage('fr') : cgpv.api.maps[mapId].setLanguage('en');
setEn(!isEn);
}}
label="Change Language" placeholder="" />

<SingleSelectComplete
options={themeOptions}
Expand Down Expand Up @@ -229,4 +238,4 @@ export function MapBuilder() {
</FormControl>
</Box>
);
}
}
Loading