summaryrefslogtreecommitdiff
path: root/packages/anastasis-webui/src/components/menu/SideBar.tsx
blob: 12223d473eb028d05fca10d36f9d0ac20750c3b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
 This file is part of GNU Taler
 (C) 2021 Taler Systems S.A.

 GNU Taler is free software; you can redistribute it and/or modify it under the
 terms of the GNU General Public License as published by the Free Software
 Foundation; either version 3, or (at your option) any later version.

 GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

 You should have received a copy of the GNU General Public License along with
 GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */

/**
*
* @author Sebastian Javier Marchano (sebasjm)
*/


import { Fragment, h, VNode } from 'preact';
import { BackupStates, RecoveryStates } from '../../../../anastasis-core/lib';
import { useAnastasisContext } from '../../context/anastasis';
import { Translate } from '../../i18n';
import { LangSelector } from './LangSelector';

interface Props {
  mobile?: boolean;
}

export function Sidebar({ mobile }: Props): VNode {
  // const config = useConfigContext();
  const config = { version: 'none' }
  const process = { env: { __VERSION__: '0.0.0' } }
  const reducer = useAnastasisContext()!

  return (
    <aside class="aside is-placed-left is-expanded">
      {mobile && <div class="footer" onClick={(e) => { return e.stopImmediatePropagation() }}>
        <LangSelector />
      </div>}
      <div class="aside-tools">
        <div class="aside-tools-label">
          <div><b>Anastasis</b> Reducer</div>
          <div class="is-size-7 has-text-right" style={{ lineHeight: 0, marginTop: -10 }}>
            {process.env.__VERSION__} ({config.version})
          </div>
        </div>
      </div>
      <div class="menu is-menu-main">
        {!reducer.currentReducerState &&
          <p class="menu-label">
            <Translate>Backup or Recorver</Translate>
          </p>
        }
        <ul class="menu-list">
          {!reducer.currentReducerState &&
            <li>
              <div class="ml-4">
                <span class="menu-item-label"><Translate>Select one option</Translate></span>
              </div>
            </li>
          }
          {reducer.currentReducerState && reducer.currentReducerState.backup_state ? <Fragment>
            <li class={
                reducer.currentReducerState.backup_state === BackupStates.ContinentSelecting ||
                reducer.currentReducerState.backup_state === BackupStates.CountrySelecting ? 'is-active' : ''}>
              <div class="ml-4">
                <span class="menu-item-label"><Translate>Location &amp; Currency</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.backup_state === BackupStates.UserAttributesCollecting ? 'is-active' : ''}>
              <div class="ml-4">
                <span class="menu-item-label"><Translate>Personal information</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.backup_state === BackupStates.AuthenticationsEditing ? 'is-active' : ''}>
              <div class="ml-4">

                <span class="menu-item-label"><Translate>Auth methods</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.backup_state === BackupStates.PoliciesReviewing ? 'is-active' : ''}>
              <div class="ml-4">

                <span class="menu-item-label"><Translate>PoliciesReviewing</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.backup_state === BackupStates.SecretEditing ? 'is-active' : ''}>
              <div class="ml-4">

                <span class="menu-item-label"><Translate>SecretEditing</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.backup_state === BackupStates.PoliciesPaying ? 'is-active' : ''}>
              <div class="ml-4">

                <span class="menu-item-label"><Translate>PoliciesPaying</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.backup_state === BackupStates.BackupFinished ? 'is-active' : ''}>
              <div class="ml-4">

                <span class="menu-item-label"><Translate>BackupFinished</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.backup_state === BackupStates.TruthsPaying ? 'is-active' : ''}>
              <div class="ml-4">

                <span class="menu-item-label"><Translate>TruthsPaying</Translate></span>
              </div>
            </li>
          </Fragment> : (reducer.currentReducerState && reducer.currentReducerState?.recovery_state && <Fragment>
            <li class={reducer.currentReducerState.recovery_state === RecoveryStates.ContinentSelecting ? 'is-active' : ''}>
              <div class="ml-4">
                <span class="menu-item-label"><Translate>ContinentSelecting</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.recovery_state === RecoveryStates.CountrySelecting ? 'is-active' : ''}>
              <div class="ml-4">
                <span class="menu-item-label"><Translate>CountrySelecting</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.recovery_state === RecoveryStates.UserAttributesCollecting ? 'is-active' : ''}>
              <div class="ml-4">
                <span class="menu-item-label"><Translate>UserAttributesCollecting</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.recovery_state === RecoveryStates.SecretSelecting ? 'is-active' : ''}>
              <div class="ml-4">
                <span class="menu-item-label"><Translate>SecretSelecting</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.recovery_state === RecoveryStates.ChallengeSelecting ? 'is-active' : ''}>
              <div class="ml-4">
                <span class="menu-item-label"><Translate>ChallengeSelecting</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.recovery_state === RecoveryStates.ChallengeSolving ? 'is-active' : ''}>
              <div class="ml-4">
                <span class="menu-item-label"><Translate>ChallengeSolving</Translate></span>
              </div>
            </li>
            <li class={reducer.currentReducerState.recovery_state === RecoveryStates.RecoveryFinished ? 'is-active' : ''}>
              <div class="ml-4">
                <span class="menu-item-label"><Translate>RecoveryFinished</Translate></span>
              </div>
            </li>
          </Fragment>)}
          {reducer.currentReducerState &&
            <li>
              <div class="buttons ml-4">
                <button class="button is-danger is-right" onClick={() => reducer.reset()}>Reset session</button>
              </div>
            </li>
          }

        </ul>
      </div>
    </aside>
  );
}