@weareconceptstudio/account 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- export const defaultFormFields: {
1
+ export declare const defaultFormFields: {
2
2
  fieldType: string;
3
3
  labelProps: {
4
4
  label: string;
@@ -1,7 +1,7 @@
1
1
  export default AccountTemplate;
2
- declare function AccountTemplate({ isFullWidth, menu_options, children, onSignOut }: {
2
+ declare function AccountTemplate({ isFullWidth, menuOptions, children, onSignOut }: {
3
3
  isFullWidth?: boolean;
4
- menu_options?: any[];
4
+ menuOptions?: any[];
5
5
  children: any;
6
6
  onSignOut: any;
7
7
  }): React.JSX.Element;
@@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
2
2
  import { Text, Link, useUi, Page } from '@weareconceptstudio/core';
3
3
  //* Style
4
4
  import AccountStyle from './style';
5
- const AccountTemplate = ({ isFullWidth = false, menu_options = [], children, onSignOut }) => {
5
+ const AccountTemplate = ({ isFullWidth = false, menuOptions = [], children, onSignOut }) => {
6
6
  const { winWidth } = useUi();
7
7
  //! Line Store
8
8
  const lineStore = useMemo(() => {
@@ -10,6 +10,11 @@ const AccountTemplate = ({ isFullWidth = false, menu_options = [], children, onS
10
10
  return React.createElement("div", { className: `space-line` });
11
11
  }
12
12
  }, [winWidth]);
13
+ //! Menu
14
+ const menu = useMemo(() => {
15
+ return menuOptions.map((menuItem, index) => (React.createElement(Link, { key: index, href: menuItem.url, className: `menu-item ${menuItem.className ? menuItem.className : ''}`, ...menuItem.options },
16
+ React.createElement(Text, { tag: `span`, className: `account-p account-p1 account-font-bold sidebar-item`, text: menuItem.name }))));
17
+ }, [menuOptions]);
13
18
  return (React.createElement(Page, { className: 'account use-account' },
14
19
  React.createElement(AccountStyle, null,
15
20
  React.createElement("div", { className: 'account-wrap' },
@@ -18,12 +23,7 @@ const AccountTemplate = ({ isFullWidth = false, menu_options = [], children, onS
18
23
  React.createElement("div", { className: `my-acc-wrap` },
19
24
  React.createElement(Text, { className: 'account-p account-p1 account-font-bold account-primary-color1', text: 'myAccount' }),
20
25
  React.createElement("div", { className: `account-line` })),
21
- React.createElement("div", { className: 'tabs-wrap' }, menu_options?.length > 0
22
- ? menu_options.map((item, index) => {
23
- return (React.createElement(Link, { key: index, href: item.url, className: 'link-item' },
24
- React.createElement(Text, { tag: `span`, className: `account-p account-p1 account-font-bold sidebar-item`, text: item.name })));
25
- })
26
- : null),
26
+ React.createElement("div", { className: 'tabs-wrap' }, menu),
27
27
  React.createElement(Text, { text: 'signOut', onClick: onSignOut, className: 'account-p account-p1 account-error-color account-font-bold sign-out' }))),
28
28
  lineStore,
29
29
  React.createElement("div", { className: `right-bar` },
@@ -51,7 +51,7 @@ const AccountStyle = styled.section `
51
51
  display: flex;
52
52
  flex-direction: column;
53
53
 
54
- .link-item {
54
+ .menu-item {
55
55
  width: fit-content;
56
56
 
57
57
  &:not(:last-child) {
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  interface ResetPasswordProps {
3
- initialValues: object;
4
- isSuccess: boolean;
5
- onResetPassword: () => Promise<any>;
3
+ formFields: [];
4
+ onFormSubmit: (values: any) => Promise<any>;
6
5
  }
7
- declare const ResetPasswordTemplate: ({ initialValues, isSuccess, onResetPassword }: ResetPasswordProps) => React.JSX.Element;
6
+ declare const ResetPasswordTemplate: ({ formFields, onFormSubmit }: ResetPasswordProps) => React.JSX.Element;
8
7
  export default ResetPasswordTemplate;
@@ -1,27 +1,25 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { Text, Link, Page } from '@weareconceptstudio/core';
3
- import { Form, Input } from '@weareconceptstudio/form';
3
+ import { FormBuilder } from '@weareconceptstudio/form';
4
4
  import { AccountButton } from '../../components';
5
5
  import ResetPasswordTemplateStyle from './style';
6
- const ResetPasswordTemplate = ({ initialValues, isSuccess = false, onResetPassword }) => {
6
+ import { defaultFormFields } from './utils';
7
+ // @ts-ignore
8
+ const ResetPasswordTemplate = ({ formFields = defaultFormFields, onFormSubmit }) => {
9
+ const [isSuccess, setIsSuccess] = useState(false);
10
+ const onSubmit = async (values) => {
11
+ return await onFormSubmit(values).then(() => {
12
+ setIsSuccess(true);
13
+ });
14
+ };
7
15
  return (React.createElement(Page, { className: 'reset-password use-account' },
8
16
  React.createElement(ResetPasswordTemplateStyle, null,
9
17
  React.createElement("div", { className: `reset-password-wrapper` }, !isSuccess ? (React.createElement(React.Fragment, null,
10
18
  React.createElement(Text, { tag: 'h1', text: 'resetPassword', className: 'account-h2 account-font-bold account-primary-color1 title' }),
11
- React.createElement(Form, { onSubmit: onResetPassword, initialValues: initialValues },
12
- React.createElement(Form.Item, { name: 'password', label: 'newPassword', className: `new-password-input-wrap` },
13
- React.createElement(Input.Password, { placeholder: 'newPasswordPlaceholder' })),
19
+ React.createElement(FormBuilder, { fields: formFields, onSubmit: onSubmit },
14
20
  React.createElement("div", { className: 'forgotLinkWrap' },
15
21
  React.createElement(Link, { href: '/forgot-password' },
16
22
  React.createElement(Text, { tag: 'span', className: 'account-p account-p3 account-font-medium account-primary-color1 underline forgotLink', text: 'forgotPasswordLink' }))),
17
- React.createElement(Form.Item, { name: 'token',
18
- // @ts-ignore
19
- options: { noStyle: true } },
20
- React.createElement(Input, { type: 'hidden' })),
21
- React.createElement(Form.Item, { name: 'email',
22
- // @ts-ignore
23
- options: { noStyle: true } },
24
- React.createElement(Input, { type: 'hidden' })),
25
23
  React.createElement(AccountButton
26
24
  // @ts-ignore
27
25
  , {
@@ -1,11 +1,11 @@
1
- declare const _default: {
1
+ export declare const defaultFormFields: {
2
2
  fieldType: string;
3
3
  labelProps: {
4
4
  label: string;
5
5
  name: string;
6
+ className: string;
6
7
  };
7
8
  fieldProps: {
8
9
  placeholder: string;
9
10
  };
10
11
  }[];
11
- export default _default;
@@ -0,0 +1,13 @@
1
+ export const defaultFormFields = [
2
+ {
3
+ fieldType: 'password',
4
+ labelProps: {
5
+ label: 'newPassword',
6
+ name: 'password',
7
+ className: 'new-password-input-wrap',
8
+ },
9
+ fieldProps: {
10
+ placeholder: 'newPasswordPlaceholder',
11
+ },
12
+ },
13
+ ];
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  interface SignInProps {
3
+ formFields: [];
3
4
  onFormSubmit: () => Promise<any>;
4
5
  }
5
- declare const SignInTemplate: ({ onFormSubmit }: SignInProps) => React.JSX.Element;
6
+ declare const SignInTemplate: ({ formFields, onFormSubmit }: SignInProps) => React.JSX.Element;
6
7
  export default SignInTemplate;
@@ -1,18 +1,16 @@
1
1
  import React from 'react';
2
2
  import { Text, Link, Page } from '@weareconceptstudio/core';
3
- import { Form, Input } from '@weareconceptstudio/form';
3
+ import { FormBuilder } from '@weareconceptstudio/form';
4
4
  import { AccountButton } from '../../components';
5
5
  import SignInTemplateStyle from './style';
6
- const SignInTemplate = ({ onFormSubmit }) => {
6
+ import { defaultFormFields } from './utils';
7
+ // @ts-ignore
8
+ const SignInTemplate = ({ formFields = defaultFormFields, onFormSubmit }) => {
7
9
  return (React.createElement(Page, { className: 'sign-in use-account' },
8
10
  React.createElement(SignInTemplateStyle, null,
9
11
  React.createElement("div", { className: 'sign-in-wrapper' },
10
12
  React.createElement(Text, { tag: 'h1', className: 'account-h2 account-font-bold account-primary-color1 title', text: 'welcomeBack' }),
11
- React.createElement(Form, { onSubmit: onFormSubmit },
12
- React.createElement(Form.Item, { name: 'email', label: 'email', rules: [{ type: 'email' }] },
13
- React.createElement(Input, { placeholder: 'emailPlaceholder' })),
14
- React.createElement(Form.Item, { name: 'password', label: 'password' },
15
- React.createElement(Input.Password, { placeholder: 'passwordPlaceholder' })),
13
+ React.createElement(FormBuilder, { fields: formFields, onSubmit: onFormSubmit },
16
14
  React.createElement("div", { className: 'forgotLinkWrap' },
17
15
  React.createElement(Link, { href: '/forgot-password' },
18
16
  React.createElement(Text, { tag: 'span', className: 'account-p account-p3 account-font-medium account-primary-color1 underline forgotLink', text: 'forgotPasswordLink' }))),
@@ -160,7 +160,7 @@ const SignInTemplateStyle = styled.section `
160
160
  --account_joinNowMTop: var(--sp1x);
161
161
  --account_joinNowDistance: var(--sp0-5x);
162
162
 
163
- .login-wrapper {
163
+ .sign-in-wrapper {
164
164
  padding: 0 var(--sp2x);
165
165
  }
166
166
  }
@@ -0,0 +1,23 @@
1
+ export declare const defaultFormFields: ({
2
+ fieldType: string;
3
+ labelProps: {
4
+ label: string;
5
+ name: string;
6
+ rules: {
7
+ type: string;
8
+ }[];
9
+ };
10
+ fieldProps: {
11
+ placeholder: string;
12
+ };
13
+ } | {
14
+ fieldType: string;
15
+ labelProps: {
16
+ label: string;
17
+ name: string;
18
+ rules?: undefined;
19
+ };
20
+ fieldProps: {
21
+ placeholder: string;
22
+ };
23
+ })[];
@@ -0,0 +1,23 @@
1
+ export const defaultFormFields = [
2
+ {
3
+ fieldType: 'input',
4
+ labelProps: {
5
+ label: 'email',
6
+ name: 'email',
7
+ rules: [{ type: 'email' }],
8
+ },
9
+ fieldProps: {
10
+ placeholder: 'emailPlaceholder',
11
+ },
12
+ },
13
+ {
14
+ fieldType: 'password',
15
+ labelProps: {
16
+ label: 'password',
17
+ name: 'password',
18
+ },
19
+ fieldProps: {
20
+ placeholder: 'passwordPlaceholder',
21
+ },
22
+ },
23
+ ];
@@ -3,7 +3,7 @@ import { Text, useTranslation, Link, Page } from '@weareconceptstudio/core';
3
3
  import { FormBuilder } from '@weareconceptstudio/form';
4
4
  import { AccountButton, CustomCheckbox } from '../../components';
5
5
  import SignUpTemplateStyle from './style';
6
- import defaultFormFields from './defaultFormFields';
6
+ import { defaultFormFields } from './utils';
7
7
  // @ts-ignore
8
8
  const SignUpTemplate = ({ formFields = defaultFormFields, onFormSubmit }) => {
9
9
  const { translate } = useTranslation();
@@ -0,0 +1,23 @@
1
+ export declare const defaultFormFields: ({
2
+ fieldType: string;
3
+ labelProps: {
4
+ label: string;
5
+ name: string;
6
+ rules?: undefined;
7
+ };
8
+ fieldProps: {
9
+ placeholder: string;
10
+ };
11
+ } | {
12
+ fieldType: string;
13
+ labelProps: {
14
+ label: string;
15
+ name: string;
16
+ rules: {
17
+ type: string;
18
+ }[];
19
+ };
20
+ fieldProps: {
21
+ placeholder: string;
22
+ };
23
+ })[];
@@ -1,4 +1,4 @@
1
- export default [
1
+ export const defaultFormFields = [
2
2
  {
3
3
  fieldType: 'input',
4
4
  labelProps: {
@@ -24,6 +24,7 @@ export default [
24
24
  labelProps: {
25
25
  label: 'email',
26
26
  name: 'email',
27
+ rules: [{ type: 'email' }],
27
28
  },
28
29
  fieldProps: {
29
30
  placeholder: 'emailPlaceholder',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weareconceptstudio/account",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Concept Studio Account",
5
5
  "author": "Concept Studio",
6
6
  "license": "ISC",