<commit_before>/*
 * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * WSO2 Inc. licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import React from 'react';
import { withRouter } from 'react-router';
import { Link } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import Avatar from '@material-ui/core/Avatar';
import Icon from '@material-ui/core/Icon';
import classNames from 'classnames';
import Box from '@material-ui/core/Box';
import { PropTypes } from 'prop-types';
import LinearProgress from '@material-ui/core/LinearProgress';
import { FormattedMessage } from 'react-intl';

const useStyles = makeStyles((theme) => ({
    chipHeadWrapperDefault: {
        background: theme.palette.grey[100],
        color: theme.palette.getContrastText(theme.palette.grey[100]),
    },
    chipHeadWrapperDone: {
        background: theme.custom.productSampleProgess.backgroundMain,
        color: theme.palette.getContrastText(theme.custom.productSampleProgess.backgroundMain),
    },
    chipHeadWrapper: {
        padding: 5,
        borderRadius: 10,
        display: 'flex',
        flexDirection: 'row',
        alignItems: 'center',
        marginBottom: 10,
        marginTop: 10,
    },
    chipAvatarDone: {
        background: theme.custom.productSampleProgess.backgroundChip,
        color: theme.palette.getContrastText(theme.custom.productSampleProgess.backgroundChip),
        marginRight: 10,
    },
    chipAvatarDefault: {
        background: theme.palette.grey[50],
        color: theme.palette.getContrastText(theme.palette.grey[50]),
        marginRight: 10,
    },
    post: {
        background: theme.custom.resourceChipColors.post,
        color: theme.palette.getContrastText(theme.custom.resourceChipColors.post),
        display: 'inline-block',
        marginLeft: 5,
        marginRight: 15,
        borderRadius: 5,
        padding: 5,
        textTransform: 'lowercase',
    },
    get: {
        background: theme.custom.resourceChipColors.get,
        color: theme.palette.getContrastText(theme.custom.resourceChipColors.get),
        display: 'inline-block',
        marginLeft: 10,
        borderRadius: 5,
        padding: 5,
        textTransform: 'lowercase',
    },
    actions: {
        justifyContent: 'flex-start',
        paddingLeft: 20,
        paddingTop: 20,
    },
    progress: {
        width: '100%',
        marginLeft: 20,
    },
    chipHeadTitle: {
        whiteSpace: 'nowrap',
    },
}));

function SampleAPIProductWizard(props) {
    const classes = useStyles();
    const {
        step, setStep, productPath, history,
    } = props;

    function handleClose() {
        if (step === 4) {
            console.log('setting up step 0');
            setStep(1);
            history.push(productPath);
            console.log('setting up step 0 finished');
        }
    }

    return (
        <>
            <Dialog
                fullWidth
                maxWidth='md'
                open={step !== 0}
                onClose={handleClose}
                aria-labelledby='max-width-dialog-title'
            >
                <DialogTitle id='max-width-dialog-title'>
                    <FormattedMessage
                        id='Apis.Listing.SampleAPI.SampleAPIProductWizard.title'
                        defaultMessage='Auto Generating API Product Progress..'
                    />
                </DialogTitle>
                <DialogContent>
                    {/* Calculator api creation */}
                    <div
                        className={classNames(classes.chipHeadWrapper, {
                            [classes.chipHeadWrapperDefault]: step < 2,
                            [classes.chipHeadWrapperDone]: step >= 2,
                        })}
                    >
                        <Avatar
                            className={classNames({<commit_msg>Remove test logging lines<commit_after>/*
 * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * WSO2 Inc. licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import React from 'react';
import { withRouter } from 'react-router';
import { Link } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import Avatar from '@material-ui/core/Avatar';
import Icon from '@material-ui/core/Icon';
import classNames from 'classnames';
import Box from '@material-ui/core/Box';
import { PropTypes } from 'prop-types';
import LinearProgress from '@material-ui/core/LinearProgress';
import { FormattedMessage } from 'react-intl';

const useStyles = makeStyles((theme) => ({
    chipHeadWrapperDefault: {
        background: theme.palette.grey[100],
        color: theme.palette.getContrastText(theme.palette.grey[100]),
    },
    chipHeadWrapperDone: {
        background: theme.custom.productSampleProgess.backgroundMain,
        color: theme.palette.getContrastText(theme.custom.productSampleProgess.backgroundMain),
    },
    chipHeadWrapper: {
        padding: 5,
        borderRadius: 10,
        display: 'flex',
        flexDirection: 'row',
        alignItems: 'center',
        marginBottom: 10,
        marginTop: 10,
    },
    chipAvatarDone: {
        background: theme.custom.productSampleProgess.backgroundChip,
        color: theme.palette.getContrastText(theme.custom.productSampleProgess.backgroundChip),
        marginRight: 10,
    },
    chipAvatarDefault: {
        background: theme.palette.grey[50],
        color: theme.palette.getContrastText(theme.palette.grey[50]),
        marginRight: 10,
    },
    post: {
        background: theme.custom.resourceChipColors.post,
        color: theme.palette.getContrastText(theme.custom.resourceChipColors.post),
        display: 'inline-block',
        marginLeft: 5,
        marginRight: 15,
        borderRadius: 5,
        padding: 5,
        textTransform: 'lowercase',
    },
    get: {
        background: theme.custom.resourceChipColors.get,
        color: theme.palette.getContrastText(theme.custom.resourceChipColors.get),
        display: 'inline-block',
        marginLeft: 10,
        borderRadius: 5,
        padding: 5,
        textTransform: 'lowercase',
    },
    actions: {
        justifyContent: 'flex-start',
        paddingLeft: 20,
        paddingTop: 20,
    },
    progress: {
        width: '100%',
        marginLeft: 20,
    },
    chipHeadTitle: {
        whiteSpace: 'nowrap',
    },
}));

function SampleAPIProductWizard(props) {
    const classes = useStyles();
    const {
        step, setStep, productPath, history,
    } = props;

    function handleClose() {
        if (step === 4) {
            setStep(1);
            history.push(productPath);
        }
    }

    return (
        <>
            <Dialog
                fullWidth
                maxWidth='md'
                open={step !== 0}
                onClose={handleClose}
                aria-labelledby='max-width-dialog-title'
            >
                <DialogTitle id='max-width-dialog-title'>
                    <FormattedMessage
                        id='Apis.Listing.SampleAPI.SampleAPIProductWizard.title'
                        defaultMessage='Auto Generating API Product Progress..'
                    />
                </DialogTitle>
                <DialogContent>
                    {/* Calculator api creation */}
                    <div
                        className={classNames(classes.chipHeadWrapper, {
                            [classes.chipHeadWrapperDefault]: step < 2,
                            [classes.chipHeadWrapperDone]: step >= 2,
                        })}
                    >
                        <Avatar
                            className={classNames({
{'fraction_non_alphanumeric': 0.10805016614856898, 'fraction_numerical': 0.012005574016507665, 'mean_word_length': 2.2117039586919107, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6446522', 'n_tokens_mistral': 2633, 'n_tokens_neox': 2482, 'n_words': 605}