
import 'package:flutter/material.dart';
import 'package:flutter_wisetronic/store/actions.dart';
import 'package:flutter_wisetronic/store/store.dart';
import 'package:responsive_builder/responsive_builder.dart';

import '../constants.dart';
import '../routes.dart';
import '../widgets/desktop/create_online_store_1.dart' as desktop;
import '../widgets/mobile/create_online_store_1.dart' as mobile;

class CreateOnlineStore1 extends StatefulWidget {

  const CreateOnlineStore1({Key? key}) :
      super(key: key);

  @override
  State<StatefulWidget> createState() => CreateOnlineStore1State();
}

class CreateOnlineStore1State extends State<CreateOnlineStore1> {

  @override
  Widget build(BuildContext context) {

    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      if (store.state.user == null) {
        store.dispatch(UpdateRedirectRoute('/contact-stores'));
        Routes.router.navigateTo(context, '/login', replace: true);
        return;
      }
    });

    return ResponsiveBuilder(
      builder: (context, sizingInformation) =>
          ScreenTypeLayout(
            mobile: mobile.CreateOnlineStore1(Constants.BUSINESS_ID),
            tablet: desktop.CreateOnlineStore1(Constants.BUSINESS_ID),
            desktop: desktop.CreateOnlineStore1(Constants.BUSINESS_ID),
          ),
    );
  }

  @override
  void initState() {
    super.initState();
  }
}