25 Commits
Author SHA1 Message Date
itschip 795de75da4 Prettified Code! 2021-01-14 15:41:55 +00:00
Christopher 60bf8be58d feat(marketplace/nui): useListing interface 2021-01-14 16:40:33 +01:00
itschip d443b794c3 Prettified Code! 2021-01-09 22:02:03 +00:00
Christopher 361a8ac6eb feat(marketplace/nui): style overhaul | listing modal 2021-01-09 22:56:32 +01:00
Christopher 9adc01f870 feat(marketplace/nui): search and header 2021-01-07 21:24:19 +01:00
Christopher 98d4aa345a feat(marketplace/nui): new styling for the item component 2021-01-07 21:23:43 +01:00
Christopher 8577995d4a Merge branch 'tweak/sellout' of https://github.com/Re-Ignited-Development/new-phone-who-dis into tweak/sellout 2021-01-03 21:43:09 +01:00
Christopher a494f5225a cleanup phots 2021-01-03 21:42:56 +01:00
Christopher 8ff550cd6f notes cleanup 2021-01-03 21:42:33 +01:00
Christopher 6ee401e3d5 bank cleanup 2021-01-03 21:42:13 +01:00
Christopher d0ed913d7c messages cleanup 2021-01-03 21:41:47 +01:00
Christopher 9c1fc2e885 typings for listing 2021-01-03 21:40:49 +01:00
Christopher c8af1fc61f sellout server cleanup 2021-01-03 21:40:35 +01:00
Christopher a3d8285265 cleanup contacts 2021-01-03 21:40:05 +01:00
Christopher 5debff0ae7 listing modal hook 2021-01-03 21:39:43 +01:00
Christopher ec21abc7d4 state for listing modal 2021-01-03 21:39:17 +01:00
Christopher bcc2e45697 tweak(listing/nui): tweak on form modal 2021-01-03 21:38:55 +01:00
Christopher c9f24e3ce2 change in header 2021-01-03 21:36:09 +01:00
Christopher fc211acb98 feat(listing/nui): hide/show on modal status 2021-01-03 21:35:21 +01:00
Christopher 6c8ab4aadd background for listing 2021-01-03 21:34:47 +01:00
Christopher 1addd5cead new listing style 2021-01-03 21:33:33 +01:00
Christopher dc8074fb21 added some css stuff 2021-01-03 21:32:22 +01:00
Christopher f29b9d2be6 removed certian css stuff 2021-01-03 21:32:03 +01:00
itschip 0e6383891a Prettified Code! 2020-12-26 15:00:00 +00:00
Christopher 7a32bbc0c4 feat(apps): new keywords 2020-12-26 15:58:40 +01:00
623 changed files with 16354 additions and 33934 deletions

No files matched your search

-35
View File
@@ -1,35 +0,0 @@
---
name: Bug Report
about: Create a report to help us improve
title: 'Bug: TITLE'
labels: New Issue
assignees: ''
---
**Is this issue related to the phone still being in development?**
If so, please consult the [gitkraken](https://app.gitkraken.com/glo/board/X9YZ_x_SVQEcMwpH) to see if it's already being tracked.
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Evidence**
If applicable, add a screenshot or a video to help explain your problem.
**Needed information (please complete the following information):**
- **Server OS**: [e.g. Windows 10]
- **Server Artifact version**: [e.g. 3486] Don't know? Do `version` into your server console.
- What version of **new-phone-who-dis** are you running?
**Additional context**
Add any other context about the problem here.
-21
View File
@@ -1,21 +0,0 @@
---
name: Feature Request
about: Suggest a feature that you would like added/improved upon.
title: 'Enhancement: TITLE'
labels: Enhancement
assignees: ''
---
**Is your feature request related to a problem or design oversight? If so, please explain it.**
Provide evidence to help support your claim so we can better understand such as pictures or a video.
**What is your suggestion?**
Please include as much details as possible. Avoid vague suggestions such as "An app to order food with.". Include as much details as possible such as: "An app that will allow a player to order a food item of their choice and have a player/npc deliver it to them."
**Does your suggestion require any dependencies? (Jobs and Money are framework dependencies.)**
**Do you have any references to help us visualize your suggestion?**
Such as "Here is a link to a similar concept: https://www.youtube.com/watch?v=j5a0jTc9S10 "
**Any additional comments or concerns?**
+30 -22
View File
@@ -1,10 +1,10 @@
name: Test Suite
name: Tests and CI
on: [push, pull_request]
on: [push]
jobs:
nui_preformatting_tests:
name: Tests for NUI
name: NUI Preformatting and Tests
runs-on: ubuntu-latest
defaults:
run:
@@ -13,6 +13,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
# This is important to fetch the changes to the previous commit
fetch-depth: 0
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
@@ -29,15 +34,21 @@ jobs:
node-version: '14.x'
- name: Install dependencies NUI
run: yarn --frozen-lockfile
- name: Prettify Code
uses: creyD/[email protected]
with:
# This part is also where you can pass other options, for example:
prettier_options: --write **/*.{js,jsx,ts,tsx,json,css,scss,md}
only_changed: True
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run Enzyme Tests
run: yarn test
- name: Check build status
run: yarn build
env:
CI: true
game_scripts_test:
name: Tests for Game Scripts
name: Formatting/Tests for Native Scripts
runs-on: ubuntu-latest
defaults:
run:
@@ -46,29 +57,26 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
# This is important to fetch the changes to the previous commit
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Install dependencies NUI
run: yarn --frozen-lockfile
- name: Prettify code
uses: creyD/[email protected]
with:
# This part is also where you can pass other options, for example:
prettier_options: --write **/*.{js,jsx,ts,tsx,json,css,scss,md}
only_changed: True
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run Jest Tests
run: yarn test
- name: Check build status
run: yarn build
env:
CI: true
lint:
name: Lint Lua scripts
runs-on: ubuntu-latest
defaults:
run:
working-directory: resources
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Lint
uses: GoatG33k/fivem-lua-lint-action@v1
-57
View File
@@ -1,57 +0,0 @@
name: Prerelease Publisher
on:
push:
branches:
- master
jobs:
pre-release-build:
name: 'Build & Create Pre-Release'
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Setup Node and Yarn Cache
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'yarn'
# Get zip util
- name: Install archive tools
run: sudo apt install zip
- name: Get variables
id: get_vars
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "::set-output name=DATE::$(date +'%D')"
- name: Install Deps
run: yarn --frozen-lockfile
- name: Run build
run: yarn build
- name: Bundle and Zip files
run: |
mkdir -p ./temp/npwd/resources
cp ./{LICENSE,README.md,config.json,import.sql,fxmanifest.lua} ./temp/npwd/
cp -r ./resources/{dist,html} ./temp/npwd/resources
cd ./temp && zip -r npwd-pre-${{ steps.get_vars.outputs.SHORT_SHA }}.zip ./npwd
- name: Create Release & Changelog
uses: "marvinpinto/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
title: Pre-Release Build (${{ steps.get_vars.outputs.SHORT_SHA }}) | ${{ steps.get_vars.outputs.DATE }}
prerelease: true
automatic_release_tag: "unstable"
files: ./temp/npwd-pre-${{ steps.get_vars.outputs.SHORT_SHA }}.zip
env:
CI: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-107
View File
@@ -1,107 +0,0 @@
name: Tagged Release Publisher
on:
push:
tags:
- "*"
jobs:
bump-version:
name: Bump Version
runs-on: ubuntu-latest
outputs:
VERSION_TAG: ${{ steps.get_version_tag.outputs.VERSION_TAG }}
steps:
- name: Checkout source code
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Get Version Tag
id: get_version_tag
run: echo ::set-output name=VERSION_TAG::${GITHUB_REF/refs\/tags\//}
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14.x
- name: Bump package shells
run: |
cd phone && npm version ${{ needs.bump-version.outputs.VERSION_TAG }}
cd resources && npm version ${{ needs.bump-version.outputs.VERSION_TAG }}
git status
- name: Commit and push
uses: EndBug/[email protected]
with:
message: Bump version to v${{ needs.bump-version.outputs.VERSION_TAG }}
default_author: github_actions
branch: master
add: |
phone/package.json
resources/package.json
create-tagged-release:
name: Build and Create Tagged Release
runs-on: ubuntu-latest
needs: bump-version
steps:
- name: Install archive tools
run: sudo apt install zip
- name: Checkout source code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Install dependencies
run: yarn
- name: Run build
run: yarn build
- name: Create Sentry Release (NPWD)
uses: tclindner/[email protected]
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: 'project-error'
SENTRY_PROJECT: 'npwd'
SENTRY_URL: https://sentry.projecterror.dev/
SENTRY_LOG_LEVEL: debug
with:
environment: production
tagName: ${{ needs.bump-version.outputs.VERSION_TAG }}
sourceMapOptions: './resources/html/static/js'
- name: Create Sentry Release (NodeJS)
uses: tclindner/[email protected]
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: 'project-error'
SENTRY_PROJECT: 'npwd-s'
SENTRY_URL: https://sentry.projecterror.dev/
with:
environment: production
tagName: ${{ steps.get_vars.outputs.VERSION_TAG }}
sourceMapOptions: './resources/html/static/js'
- name: Bundle built files
run: |
mkdir -p ./temp/npwd/resources
cp ./{LICENSE,README.md,config.json,import.sql,fxmanifest.lua} ./temp/npwd/
cp -r ./resources/{dist,html} ./temp/npwd/resources
cd ./temp && zip -r npwd-${{ needs.bump-version.outputs.VERSION_TAG }}.zip ./npwd
- name: Create Release
uses: "marvinpinto/[email protected]"
id: auto_release
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
title: NPWD Release | ${{ needs.bump-version.outputs.VERSION_TAG }}
prerelease: false
files: npwd-${{ needs.bump-version.outputs.VERSION_TAG }}.zip
env:
CI: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+1 -26
View File
@@ -1,27 +1,2 @@
# No IDE Folders
# No intellij folder
.idea
npwd_temp
resources/html
phone/.eslintcache
# Node Modules and Built Folders
node_modules
build
dist
# Error Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Mac thing
.DS_Store
# Debug logs
sv_npwd.log
# FXServer Yarn
.yarn.installed
-1
View File
@@ -1 +0,0 @@
_
-4
View File
@@ -1,4 +0,0 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit ""
-4
View File
@@ -1,4 +0,0 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn pretty-quick --staged
-9
View File
@@ -1,9 +0,0 @@
build
dist
coverage
node_modules
.idea
.github
.vscode
resources/html
resources/dist
-9
View File
@@ -1,9 +0,0 @@
{
"printWidth": 100,
"singleQuote": true,
"semi": true,
"bracketSpacing": true,
"trailingComma": "all",
"useTabs": false,
"tabWidth": 2
}
+7 -93
View File
@@ -1,97 +1,11 @@
Copyright (c) Kidz, ItsChip, ROCKY_southpaw, Kire and TasoOneAsia
Copyright (c) BTNGaming, itzchip, ROCKY_southpaw
All rights reserved.
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
Section 1 – Definitions.
Even if 'All rights reserved' is very clear :
Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
BY-NC-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.
Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike.
Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
Licensor means the individual(s) or entity(ies) granting rights under this Public License.
NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 – Scope.
License grant.
Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
Term. The term of this Public License is specified in Section 6(a).
Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
Downstream recipients.
Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
Other rights.
Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
Patent and trademark rights are not licensed under this Public License.
To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
Section 3 – License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
Attribution.
If You Share the Licensed Material (including in modified form), You must:
retain the following if it is supplied by the Licensor with the Licensed Material:
identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
a copyright notice;
a notice that refers to this Public License;
a notice that refers to the disclaimer of warranties;
a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
ShareAlike.
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License.
You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
Section 4 – Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
Section 5 – Disclaimer of Warranties and Limitation of Liability.
Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Section 6 – Term and Termination.
This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 – Other Terms and Conditions.
The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 – Interpretation.
For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
You shall not use any piece of this software in a commercial product / service
You shall not resell this software
You shall not provide any facility to install this particular software in a commercial product / service
You are in no way allowed to redistribute this code until this private project has become public, unless given written consent by one of the copyright holders.
This copyright should appear in every part of the project code
+61 -30
View File
@@ -1,48 +1,79 @@
# New-Phone-Who-Dis (NPWD)
# New Phone README TITLE
<img src="https://i.file.glass/zVkK7.png" width="500" height="300" />
TODO
## Production Server Installation
NPWD is our flagship and current running project. The team has been working on the project since August, 2020. This resource isn’t complete yet and currently has a pre-release. There is however no ETA for a stable release, yet. Feel free to test it out in a dev environment by following the installation guide.
### Configuration
Written completely by the Project Error Dev Team in [React](https://reactjs.org/) with a [TypeScript](https://www.typescriptlang.org/) client/server environment.
This resource is highly configurable through the [config.json](./config.json). This JSON file holds configuration for the phone itself, for the apps running on it and peripheral information.
## Project Error Discord
Below is the list of configuration options:
- Join the [Discord](https://discord.gg/HYwBjTbAY5) to follow current development of the project.
| Option | Default | Description |
|--------------------------------------|----------|--------------------------------------------------------------------------------------------------------------------------------|
| Locale | en | The language locale used by the app. See [fivem keybinds](https://docs.fivem.net/docs/game-references/controls/) for options |
| KeyTogglePhone | 288 (F1) | The keybind to open and close the app. See [fivem keybinds](https://docs.fivem.net/docs/game-references/controls/) for options |
| PhoneAsItem | false | whether or not the phone is an item in game |
| SwimDestroy | false | whether or not the phone will have a chance to be destroyed while swimming |
| RunRate | 10 | interval in seconds to check phone destruction |
| DestoryChance | 100 | Percent chance that phone destruction will occur |
| DestroyPhoneReCheck | 3 | Time in minutes before another phone destruction attempt will happen |
| notificationPosition.horizontal | right | Horizontal position of phone notifications. `left`, `center` or `right` |
| notificationPosition.vertical | bottom | Vertical positon of phone notifications. `top` or `bottom` |
| twitter.showNotifications | true | Whether or not to show twitter notifications |
| twitter.generateProfileNameFromUsers | true | Whether or not the server should automtically generate a player's profile name from their user in the database |
| twitter.allowEdtiableProfileName | true | Whether or not players can edit their profile name |
| twitter.allowDeleteTweets | true | Whether or not players can delete their own tweets |
| twitter.allowReportTweets | true | Whether or not players can report tweets. Optional discord integration. |
| twitter.characterLimit | 240 | Limit on how many characters tweets can contain |
| twitter.enableAvatars | true | Whether or not player's can select avatars for their twitter profile |
| twitter.enableEmojis | true | Whether or not player's can use emojis in tweets |
| twitter.enableImages | true | Whether or not player's can add images to tweets (external URLs) |
| twitter.maxImages | 3 | The maximum amount of images allowed in a tweet |
## Documentation & Installation
### Discord
- [Project-Error Docs](https://docs.projecterror.dev/#/) contains all the information regarding this resource. Please consult it for installation, dependencies, and other important information.
It is possible to perform discord integration with the phone. To configure discord add the following variables to your `server.cfg` file:
## Support
```
set discord_bot_token "YOUR_DISCORD_BOT_TOKEN"
set discord_channel_id "YOUR_DISCORD_CHANNEL_ID"
```
No support is being provided currently for the resource as it is still in an unfinished state.
Current discord integrations with the phone:
Should you encounter any issues, please do the following:
- Twitter: reporting tweets
- Check the [Git Kraken](https://app.gitkraken.com/glo/board/X9YZ_x_SVQEcMwpH) to see if the issue you're referring to is already tracked.
- Check the [State of Development](https://docs.projecterror.dev/#/npwd/state-of-dev?id=introduction) to see if the app is still a **WIP**.
- If the issue isn't on the Git Kraken and the app is finished, please open an issue.
- If the issue isn't on the Git Kraken and the app is **not** finished, please contact us in Discord.
We do not want issues opened that are due to the phone being **WIP** as this slows down development since we now have to address it more immediately.
## Development
## Preview
This phone is a [React](https://reactjs.org/) project with a TypeScript client/server environment.
[Latest Teaser Video (October 28th)](https://streamable.com/f1ri9r)
### Prerequisites
#### Apps (February 20th, 2021)
The development environment assumes you have the following prerequisites:
Most of these apps have UI that does **not** represent the final product and are subject to change.
1. A windows environment and Powershell as your default terminal
1. [Git for windows](https://git-scm.com/download/win) installed
1. [LTS node.js](https://nodejs.org/en/about/releases/) installed
1. [yarn](https://yarnpkg.com/) package manager installed (`npm install -g yarn`)
1. A fivem environment that is set up according to the [setting up a server instructions](https://docs.fivem.net/docs/server-manual/setting-up-a-server/) from the fivem documentation
- [**Bank**](https://i.file.glass/Eh53X.png)
- [**Calculator**](https://i.file.glass/s6VQV.png)
- [**Camera**](https://i.file.glass/vW0y9.png)
- [**Contacts**](https://i.file.glass/3fujR.png)
- [**Marketplace**](https://i.file.glass/5bUa8.png)
- [**Messages**](https://i.file.glass/S4Lia.png)
- [**Notes**](https://i.file.glass/qTkBb.png)
- [**Phone**](https://i.file.glass/z0ii9.png)
- [**Settings**](https://i.file.glass/mZAIt.png)
- [**Twitter**](https://i.file.glass/rQZFR.png)
### Development Environment
#### Steps
1. Clone the repo into your `server-data/resources/[local]` folder
1. Go into the react project: `cd phone`
1. Install node dependencies: `yarn install`
2. Install `lint-staged` globally `npm i -g lint-staged
3. Add the `new-phone-who-dis` app to your `server.cfg`
4. Start your fivem server
#### Development iteration cycle:
- If iterating on client/server Lua make your change and then `ensure new-phone-who-dis` in the fivem server terminal
- If iteration on UI changes run the project with `yarn watch` which will monitor the JavaScript project and rebuild when you make code changes and then `ensure new-phone-who-dis` after making your change
- Avoid commiting `index.html` as the development version overrides the production version
-3
View File
@@ -1,3 +0,0 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
+31 -41
View File
@@ -1,42 +1,32 @@
{
"Locale": "en",
"PhoneAsItem": {
"enabled": false,
"exportResource": "my-core-resource",
"exportName": "myCheckerFunction"
},
"general": {
"useDashNumber": true,
"enableMultiChar": false
},
"database": {
"useIdentifierPrefix": false,
"playerTable": "users",
"identifierColumn": "identifier"
},
"twitter": {
"showNotifications": true,
"generateProfileNameFromUsers": true,
"allowEditableProfileName": true,
"allowDeleteTweets": true,
"allowReportTweets": true,
"characterLimit": 160,
"newLineLimit": 10,
"enableAvatars": true,
"enableEmojis": true,
"enableImages": true,
"maxImages": 3
},
"match": {
"generateProfileNameFromUsers": true,
"allowEditableProfileName": true
},
"bank": {
"showNotifications": true
},
"debug": {
"level": "silly",
"enabled": true,
"sentryEnabled": true
}
}
"Locale": "en",
"KeyTogglePhone": 288,
"KeyTakeCall": 38,
"PhoneAsItem": false,
"SwimDestroy": false,
"RunRate": 10,
"DestoryChance": 100,
"DestroyPhoneReCheck": 3,
"notificationPosition": {
"horizontal": "right",
"vertical": "top"
},
"general": {
"useDashNumber": false
},
"twitter": {
"showNotifications": true,
"generateProfileNameFromUsers": true,
"allowEdtiableProfileName": true,
"allowDeleteTweets": true,
"allowReportTweets": true,
"characterLimit": 240,
"enableAvatars": true,
"enableEmojis": true,
"enableImages": true,
"maxImages": 3
},
"bank": {
"showNotifications": true
}
}
+22 -9
View File
@@ -1,21 +1,34 @@
fx_version "cerulean"
fx_version "adamant"
game "gta5"
description 'js runtime monkaW'
authors { "itschip", "erik-sn", "TasoOneAsia", "kidz", "RockySouthpaw"}
description 'New-PHone-Who-Dis'
author { "chip", "BTNGaming", "ROCKY_southpaw" }
client_scripts {
'resources/dist/client/*.client.js',
'resources/client/*.lua'
client_script {
'@es_extended/locale.lua',
'resources/locales/*.lua',
'resources/client/*lua',
'resources/dist/client/*.client.js'
}
shared_script {
'resources/config.lua'
}
server_script {
"@mysql-async/lib/MySQL.lua",
'@es_extended/locale.lua',
'resources/locales/*.lua',
'resources/server/*.lua',
'resources/dist/server/*.server.js'
}
ui_page 'resources/html/index.html'
files {
'config.json',
'resources/html/index.html',
'resources/html/**/*',
}
'resources/html/*.js',
'resources/html/media/frames/*.png',
'resources/html/media/backgrounds/*.png',
'resources/html/media/backgrounds/*.jpg',
'resources/html/media/twitter/*'
}
-164
View File
@@ -1,164 +0,0 @@
# comment this out if your server has a different table/location for phone_number
# or if it already exists in the users table
ALTER TABLE `users` ADD COLUMN `phone_number` VARCHAR(20) DEFAULT NULL;
CREATE TABLE IF NOT EXISTS `npwd_phone_contacts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) DEFAULT NULL,
`avatar` varchar(512) DEFAULT NULL,
`number` varchar(12) DEFAULT NULL,
`display` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS `npwd_twitter_tweets` (
`id` int NOT NULL AUTO_INCREMENT,
`message` varchar(1000) NOT NULL,
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`likes` int NOT NULL DEFAULT '0',
`identifier` varchar(48) NOT NULL,
`visible` tinyint NOT NULL DEFAULT '1',
`images` varchar(1000) DEFAULT '',
`retweet` int DEFAULT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `npwd_twitter_profiles` (
`id` int NOT NULL AUTO_INCREMENT,
`profile_name` varchar(90) NOT NULL,
`identifier` varchar(48) NOT NULL,
# Default Profile avatar can be set here
`avatar_url` varchar(255) DEFAULT 'https://i.file.glass/QrEvq.png',
`bio` varchar(512) DEFAULT NULL,
`location` varchar(45) DEFAULT NULL,
`job` varchar(45) DEFAULT NULL,
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `profile_name_UNIQUE` (`profile_name`)
);
CREATE TABLE IF NOT EXISTS `npwd_twitter_likes` (
`id` int NOT NULL AUTO_INCREMENT,
`profile_id` int NOT NULL,
`tweet_id` int NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_combination` (`profile_id`,`tweet_id`),
KEY `profile_idx` (`profile_id`),
KEY `tweet_idx` (`tweet_id`),
CONSTRAINT `profile` FOREIGN KEY (`profile_id`) REFERENCES `npwd_twitter_profiles` (`id`),
CONSTRAINT `tweet` FOREIGN KEY (`tweet_id`) REFERENCES `npwd_twitter_tweets` (`id`) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS `npwd_match_profiles` (
`id` int NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) NOT NULL,
`name` varchar(90) NOT NULL,
`image` varchar(255) NOT NULL,
`bio` varchar(512) DEFAULT NULL,
`location` varchar(45) DEFAULT NULL,
`job` varchar(45) DEFAULT NULL,
`tags` varchar(255) NOT NULL DEFAULT '',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`),
UNIQUE KEY `identifier_UNIQUE` (`identifier`)
);
CREATE TABLE IF NOT EXISTS `npwd_match_views` (
`id` int NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) NOT NULL,
`profile` int NOT NULL,
`liked` tinyint DEFAULT '0',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `match_profile_idx` (`profile`),
CONSTRAINT `match_profile` FOREIGN KEY (`profile`) REFERENCES `npwd_match_profiles` (`id`)
);
CREATE TABLE IF NOT EXISTS `npwd_notes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) NOT NULL,
`title` varchar(255) NOT NULL,
`content` varchar(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS `npwd_marketplace_listings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL,
`number` varchar(255) NOT NULL,
`title` varchar(255) DEFAULT NULL,
`url` varchar(255) DEFAULT NULL,
`description` varchar(255) NOT NULL,
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS `npwd_marketplace_reports` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`listing_id` int(11) DEFAULT NULL,
`profile` varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS `npwd_twitter_reports` (
`id` int NOT NULL AUTO_INCREMENT,
`profile_id` int NOT NULL,
`tweet_id` int NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_combination` (`profile_id`,`tweet_id`),
KEY `profile_idx` (`profile_id`),
KEY `tweet_idx` (`tweet_id`),
CONSTRAINT `report_profile` FOREIGN KEY (`profile_id`) REFERENCES `npwd_twitter_profiles` (`id`),
CONSTRAINT `report_tweet` FOREIGN KEY (`tweet_id`) REFERENCES `npwd_twitter_tweets` (`id`) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS `npwd_messages_groups` (
`id` int NOT NULL AUTO_INCREMENT,
`user_identifier` varchar(48) NOT NULL,
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`group_id` varchar(512) NOT NULL,
`participant_identifier` varchar(48) NOT NULL,
`label` varchar(60) DEFAULT '',
`unreadCount` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `npwd_messages` (
`id` int NOT NULL AUTO_INCREMENT,
`message` varchar(512) NOT NULL,
`user_identifier` varchar(48) NOT NULL,
`group_id` varchar(512) NOT NULL,
`isRead` tinyint NOT NULL DEFAULT '0',
`createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`visible` tinyint NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `npwd_calls` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) DEFAULT NULL,
`transmitter` varchar(255) NOT NULL,
`receiver` varchar(255) NOT NULL,
`is_accepted` tinyint(4) DEFAULT 0,
`start` varchar(255) DEFAULT NULL,
end varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS npwd_phone_gallery (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(48) DEFAULT NULL,
`image` varchar(255) DEFAULT NULL,
PRIMARY KEY (id)
);
-5
View File
@@ -1,5 +0,0 @@
{
"packages": ["phone", "resources"],
"version": "0.0.0",
"npmClient": "yarn"
}
-29
View File
@@ -1,29 +0,0 @@
{
"name": "npwd",
"version": "0.1.0",
"description": "A FiveM phone resource, made in React & TypeScript",
"repository": "https://github.com/project-error/new-phone-who-dis",
"license": "CC-BY-NC-SA-4.0",
"devDependencies": {
"@commitlint/cli": "^12.1.1",
"@commitlint/config-conventional": "^12.1.1",
"@octokit/core": "^3.4.0",
"husky": "^5.1.3",
"lerna": "^3.22.1",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0"
},
"scripts": {
"build": "lerna run test && lerna run build",
"prepare": "husky install",
"bootstrap": "lerna bootstrap",
"format:staged": "pretty-quick --staged",
"postinstall": "husky install && yarn bootstrap",
"test": "lerna run test"
},
"husky": {
"hooks": {
"pre-commit": "npx run format:staged"
}
}
}
+15
View File
@@ -0,0 +1,15 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
],
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-syntax-dynamic-import"
]
}
-1
View File
@@ -1 +0,0 @@
REACT_APP_VERSION=$npm_package_version
+23
View File
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+2
View File
@@ -0,0 +1,2 @@
build
node_modules
+1 -2
View File
@@ -1,3 +1,2 @@
# New Phone Who Dis
A FiveM phone created with ReactJS, with the power from TasoOneAsia, erik-sn (Kire), jfrader (kidz), r1OG, RockySouthpaw and itschip. Still missing commits from 99kr.
A FiveM phone created with ReactJS, with the power from BTNGaming, kidz, ROCKY_shouthpaw and chip.
-70
View File
@@ -1,70 +0,0 @@
const path = require('path');
const {
addAfterLoader,
removeLoaders,
loaderByName,
getLoaders,
throwUnexpectedConfigError,
} = require('@craco/craco');
const throwError = (message) =>
throwUnexpectedConfigError({
packageName: 'craco',
githubRepo: 'gsoft-inc/craco',
message,
githubIssueQuery: 'webpack',
});
module.exports = {
webpack: {
configure: (webpackConfig, { paths }) => {
const { hasFoundAny, matches } = getLoaders(webpackConfig, loaderByName('babel-loader'));
if (!hasFoundAny) throwError('failed to find babel-loader');
const { hasRemovedAny, removedCount } = removeLoaders(
webpackConfig,
loaderByName('babel-loader'),
);
if (!hasRemovedAny) throwError('no babel-loader to remove');
if (removedCount !== 2) throwError('had expected to remove 2 babel loader instances');
webpackConfig.resolve.plugins = webpackConfig.resolve.plugins.filter(
({ constructor: c }) => !c || c.name !== 'ModuleScopePlugin',
);
const tsLoader = {
test: /\.tsx?$/,
loader: require.resolve('ts-loader'),
options: { transpileOnly: true },
};
const { isAdded: tsLoaderIsAdded } = addAfterLoader(
webpackConfig,
loaderByName('url-loader'),
tsLoader,
);
if (!tsLoaderIsAdded) throwError('failed to add ts-loader');
const { isAdded: babelLoaderIsAdded } = addAfterLoader(
webpackConfig,
loaderByName('ts-loader'),
matches[1].loader, // babel-loader
);
if (!babelLoaderIsAdded) throwError('failed to add back babel-loader for non-application JS');
paths.appBuild = webpackConfig.output.path = path.resolve('../resources/html');
if (webpackConfig.mode === 'development') {
webpackConfig.devtool = 'eval-source-map';
}
return webpackConfig;
},
},
devServer: (devServerConfig) => {
devServerConfig.writeToDisk = true;
return devServerConfig;
},
};
-77
View File
@@ -1,77 +0,0 @@
const args = process.argv.slice(2);
console.log(args);
const path = './src/locale/';
const langs = ['bs', 'no', 'es', 'fr', 'pt', 'ptbr', 'sv', 'tr', "hu"];
const defaultLang = 'en';
const langFiles = [];
let defaultLangFile;
const missingKeys = {};
const promises = langs
.filter((l) => (args[0] ? args[0] === l : true))
.map((l) => {
return new Promise((res, rej) => {
import(path + l + '.json')
.then((module) => {
langFiles.push(module.default.translation);
res();
})
.catch((e) => {
console.error(e);
rej(e);
});
});
});
const Load = () => Promise.all(promises);
const LoadDefault = () =>
new Promise((res, rej) => {
import(path + defaultLang + '.json')
.then((module) => {
defaultLangFile = module.default.translation;
res();
})
.catch((e) => {
console.error(e);
rej(e);
});
});
(async () => {
const filteredLangs = langs.filter((l) => (args[0] ? args[0] === l : true));
await LoadDefault();
await Load();
let idx = 0;
for (const file of langFiles) {
const currLang = filteredLangs[idx];
if (currLang === defaultLang) {
return;
}
idx++;
if (args[0] && args[0] !== currLang) {
return;
}
missingKeys[currLang] = [];
for (const dKey in defaultLangFile) {
let exists = false;
for (const key in file) {
if (key === dKey) {
exists = true;
}
}
if (!exists) {
missingKeys[currLang].push([dKey, defaultLangFile[dKey]]);
}
}
}
console.log(missingKeys);
})();
+59 -39
View File
@@ -1,58 +1,78 @@
{
"name": "npwd-nui",
"name": "new-phone",
"version": "0.1.0",
"repository": "https://github.com/project-error/new-phone-who-dis",
"private": true,
"license": "CC-BY-NC-SA-4.0",
"homepage": "/resources/html",
"dependencies": {
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
"@babel/polyfill": "^7.4.4",
"@fortawesome/fontawesome-free": "^5.15.1",
"@fortawesome/fontawesome-svg-core": "^1.2.32",
"@fortawesome/free-brands-svg-icons": "^5.15.1",
"@fortawesome/free-solid-svg-icons": "^5.15.1",
"@fortawesome/react-fontawesome": "^0.1.11",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"dayjs": "^1.10.4",
"dompurify": "^2.2.6",
"emoji-mart": "^3.0.1",
"@popperjs/core": "^2.5.3",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^26.0.14",
"core-js": "^3.6.5",
"emoji-mart": "^3.0.0",
"enzyme": "^3.11.0",
"fivem-nui-react-lib": "^2.2.8",
"howler": "^2.2.1",
"i18next": "^20.3.4",
"jsonschema": "^1.4.0",
"parse-url": "^5.0.7",
"qs": "^6.9.6",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"enzyme-adapter-react-16": "^1.15.5",
"i18next": "^19.7.0",
"prettier": "^2.0.5",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-hotkeys": "^2.0.0",
"react-i18next": "^11.7.1",
"react-popper": "^2.2.3",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"recoil": "^0.3.1"
"react-scripts": "3.4.3",
"recoil": "^0.0.10",
"styled-components": "^5.1.1"
},
"devDependencies": {
"@craco/craco": "^6.1.1",
"@sentry/integrations": "^6.10.0",
"@sentry/webpack-plugin": "^1.16.0",
"@sentry/react": "^5.29.2",
"@sentry/tracing": "^5.29.2",
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"@types/enzyme": "^3.10.7",
"@types/howler": "^2.2.1",
"@types/node": "^14.11.5",
"@types/qs": "^6.9.5",
"@types/react": "^16.9.51",
"@types/react-dom": "^16.9.8",
"@types/react-router-dom": "^5.1.7",
"@welldone-software/why-did-you-render": "^6.1.1",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.1",
"cross-env": "^7.0.3",
"dotenv": "^10.0.0",
"ts-loader": "^8.3.0",
"typescript": "^4.3.2"
"babel-eslint": "^10.0.1",
"babel-loader": "^8.1.0",
"babel-plugin-styled-components": "^1.10.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"cra-build-watch": "^3.2.0",
"cross-env": "^7.0.2",
"css-loader": "^2.1.1",
"file-loader": "^3.0.1",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^4.3.0",
"ifdef-loader": "^2.1.5",
"react-test-renderer": "^16.13.1",
"style-loader": "^0.23.1",
"svg-url-loader": "^2.3.2",
"terser-webpack-plugin": "^1.3.0",
"ts-loader": "^8.0.4",
"typescript": "3.9.7",
"url-loader": "^1.1.2",
"webpack-cli": "^3.3.12"
},
"scripts": {
"i18n:missing": "node --experimental-json-modules i18n.missingKeys.js",
"start": "cross-env PUBLIC_URL=/ craco start",
"watch": "cross-env REACT_APP_IN_GAME=1 craco start",
"build:release": "cross-env SENTRY_RELEASE=true craco build",
"build": "craco build",
"test": "craco test --watchAll=false --testMatch **/src/**/*.test.{ts,js,tsx}"
"start": "react-scripts start",
"watch": "cra-build-watch --disable-chunks --build-path ../resources/html --output-filename dev.js",
"format": "prettier --write src/**/*.{js,jsx,ts,tsx,json,css,scss,md}",
"build": "react-scripts build",
"build:resources": "cross-env NODE_ENV=production webpack --config webpack/webpack.resources.js --color -p --progress --hide-modules --display-optimization-bailout",
"test": "react-scripts test --watchAll=false --testMatch **/src/**/*.test.{ts,js,tsx}",
"test:watch": "react-scripts test --watchAll --testMatch **/src/**/*.test.{ts,js,tsx}",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
+10
View File
@@ -0,0 +1,10 @@
// Taso: Including some default values for clarity sake
module.exports = {
trailingComma: "es5",
tabWidth: 2,
semi: true,
singleQuote: true,
jsxSingleQuote: true,
jsxBracketSameLine: false,
bracketSpacing: true
}
-96
View File
@@ -1,96 +0,0 @@
customElements.define(
'x-frame-bypass',
class extends HTMLIFrameElement {
static get observedAttributes() {
return ['src'];
}
constructor() {
super();
}
attributeChangedCallback() {
this.load(this.src);
}
connectedCallback() {
this.sandbox =
'' + this.sandbox ||
'allow-forms allow-modals allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation-by-user-activation'; // all except allow-top-navigation
}
load(url, options) {
if (!url || !url.startsWith('http'))
throw new Error(`Unable to load src ${url} does not start with http(s)://`);
this.srcdoc = `<html>
<head>
<style>
.loader {
position: absolute;
top: calc(50% - 25px);
left: calc(50% - 25px);
width: 50px;
height: 50px;
background-color: #333;
border-radius: 50%;
animation: loader 1s infinite ease-in-out;
}
@keyframes loader {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
opacity: 0;
}
}
</style>
</head>
<body>
<div class="loader"></div>
</body>
</html>`;
this.fetchProxy(url, options, 0)
.then((res) => res.text())
.then((data) => {
if (data)
this.srcdoc = data.replace(
/<head([^>]*)>/i,
`<head$1>
<base href="${url}">
<script>
// X-Frame-Bypass navigation event handlers
document.addEventListener('click', e => {
if (frameElement && document.activeElement && document.activeElement.href) {
e.preventDefault()
frameElement.load(document.activeElement.href)
}
})
document.addEventListener('submit', e => {
if (frameElement && document.activeElement && document.activeElement.form && document.activeElement.form.action) {
e.preventDefault()
if (document.activeElement.form.method === 'post')
frameElement.load(document.activeElement.form.action, {method: 'post', body: new FormData(document.activeElement.form)})
else
frameElement.load(document.activeElement.form.action + '?' + new URLSearchParams(new FormData(document.activeElement.form)))
}
})
</script>`,
);
})
.catch((e) => console.error('Unable to load proxy iframe service', e));
}
fetchProxy(url, options, i) {
const proxies = (options || {}).proxies || [
'https://cors-anywhere.herokuapp.com/',
'https://api.codetabs.com/v1/proxy/?quest=',
];
return fetch(proxies[i] + url, options)
.then((res) => {
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
return res;
})
.catch((error) => {
if (i === proxies.length - 1) throw error;
return this.fetchProxy(url, options, i + 1);
});
}
},
{ extends: 'iframe' },
);
+2 -7
View File
@@ -2,15 +2,10 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Enable experimental proxy custom iframe webcomp -->
<!-- <script type="module" src="./iframe.webcomp.js"></script>-->
<title>Project Error - New Phone Who Dis</title>
<title>ReIgnited React Phone</title>
</head>
<body>
<div id="root"></div>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.
Binary file not shown.
Binary file not shown.
+6 -5
View File
@@ -1,12 +1,12 @@
.PhoneWrapper {
width: 100vw;
height: 100vh;
position: relative;
}
.Phone {
position: absolute;
right: 0;
bottom: 0vh;
right: 0vh;
width: 500px;
height: 1000px;
background-size: cover;
@@ -24,6 +24,8 @@
overflow: hidden;
position: absolute;
background-color: black;
border-left: 4px solid black;
border-right: 4px solid black;
bottom: 100px;
left: 50px;
right: 50px;
@@ -33,7 +35,6 @@
background-position: center;
background-size: cover;
background-repeat: no-repeat;
border-radius: 20px;
}
.PhoneAppContainer {
@@ -48,12 +49,12 @@
}
*::-webkit-scrollbar-track {
box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
background-color: #666;
background-color: #f5f5f5;
}
*::-webkit-scrollbar {
width: 3px;
background-color: transparent;
}
*::-webkit-scrollbar-thumb {
background-color: #f5f5f5;
background-color: #666;
}
+7 -7
View File
@@ -1,12 +1,12 @@
import React from 'react';
import { RecoilRoot } from 'recoil';
import { shallow } from 'enzyme';
import { PhoneProviders } from './PhoneProviders';
import React from "react";
import { RecoilRoot } from "recoil";
import { shallow } from "enzyme";
import Phone from "./Phone";
it('renders Phone', () => {
it("renders Phone", () => {
shallow(
<RecoilRoot>
<PhoneProviders />
</RecoilRoot>,
<Phone />
</RecoilRoot>
);
});
+299 -96
View File
@@ -1,124 +1,327 @@
import React, { useEffect } from 'react';
import React from 'react';
import './Phone.css';
import './i18n';
import { Route } from 'react-router-dom';
import { CallModal } from './os/call/components/CallModal';
import { useSettings } from './apps/settings/hooks/useSettings';
import MessageIcon from '@material-ui/icons/Email';
import { CallModal } from './modal/components/CallModal';
import { HomeApp } from './apps/home/components/Home';
import { ThemeProvider } from '@material-ui/core';
import { useInitKeyboard } from './os/keyboard/hooks/useKeyboard';
import { NotificationIcon } from './os/notifications/components/NotificationIcon';
import { NotificationBar } from './os/notifications/components/NotificationBar';
import { Navigation } from './os/navigation-bar/components/Navigation';
import { useNuiService } from './os/nui-events/hooks/useNuiService';
import { useSimcardService } from './os/simcard/hooks/useSimcardService';
import { usePhoneService } from './os/phone/hooks/usePhoneService';
import { useApps } from './os/apps/hooks/useApps';
import { useContactsService } from './apps/contacts/hooks/useContactsService';
import { useTwitterService } from './apps/twitter/hooks/useTwitterService';
import { useMarketplaceService } from './apps/marketplace/hooks/useMarketplaceService';
import { useSelloutService } from './apps/sellout/hooks/useSelloutService';
import { useBankService } from './apps/bank/hooks/useBankService';
import { useMessagesService } from './apps/messages/hooks/useMessageService';
import { isSettingsSchemaValid, useSettings } from './apps/settings/hooks/useSettings';
import { useCallService } from './os/call/hooks/useCallService';
import { useDialService } from './apps/dialer/hooks/useDialService';
import InjectDebugData from './os/debug/InjectDebugData';
import { PhoneSnackbar } from './ui/components/PhoneSnackbar';
import { NotificationAlert } from './os/notifications/components/NotificationAlert';
import { useCallModal } from './os/call/hooks/useCallModal';
import WindowSnackbar from './ui/components/WindowSnackbar';
import { useTranslation } from 'react-i18next';
import { useSnackbar } from './ui/hooks/useSnackbar';
import { PhoneEvents } from '../../typings/phone';
import { useKeyboardService } from './os/keyboard/hooks/useKeyboardService';
import PhoneWrapper from './PhoneWrapper';
import { useNotesService } from './apps/notes/hooks/useNotesService';
import { usePhotoService } from './apps/camera/hooks/usePhotoService';
import Nui from './os/nui-events/utils/Nui';
import { usePhone } from './os/phone/hooks/usePhone';
import dayjs from 'dayjs';
import DefaultConfig from '../../config.json';
import { TopLevelErrorComponent } from './ui/components/TopLevelErrorComponent';
import { useConfig } from './os/phone/hooks/useConfig';
// Inject mock data when in development env.
if (process.env.NODE_ENV === 'development') {
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'CAMERA',
method: 'setPhotos',
data: [
{
id: 1,
image: 'https://i.imgur.com/OO8wx6Z.jpg',
},
{
id: 1,
image: 'https://i.imgur.com/pqGBiST.jpg',
},
],
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'BANK',
method: 'setCredentials',
data: {
name: 'Firstname Lastname',
balance: 2000,
},
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'CONTACTS',
method: 'setContacts',
data: [
{
id: 1,
display: 'Ruqen',
number: '43534444',
},
{
id: 1,
display: 'Taso',
number: '43534444',
},
],
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'SIMCARD',
method: 'setNumber',
data: '111-1134',
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'PHONE',
method: 'setVisibility',
data: true,
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'NOTES',
method: 'setNotes',
data: [
{
id: 1,
title: 'First note',
content: 'Hello, this is my shitty note',
},
{
id: 2,
title: 'Second note',
content: 'Hello, this is another shitty note',
},
],
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'BANK',
method: 'setNotification',
data: {
id: 1,
message: 'ahhaha',
},
},
})
);
}, 1000);
setTimeout(() => {
new MessageEvent('messsage', {
data: {
app: 'TWITTER',
method: 'setNotification',
data: {
id: 1,
message: 'ahhaha',
},
},
});
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'BANK',
method: 'setTransaction',
data: [
{
id: 1,
amount: 200,
type: 'Deposit',
source: 'chip',
},
{
id: 2,
amount: 200,
type: 'Withdraw',
source: 'chip',
},
{
id: 3,
amount: 200,
type: 'Withdraw',
source: 'chip',
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: 'chip',
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: 'chip',
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: 'chip',
},
],
},
})
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent('message', {
data: {
app: 'SELLOUT',
method: 'setListings',
data: [
{
id: 1,
name: 'Some guy',
number: '123-4567',
title: 'Car',
category: 'CAR',
description: 'Selling this cool car',
url: 'https://i.imgur.com/ROmGTwi.jpeg',
price: 400,
posted: '1/9/2021',
},
{
id: 2,
name: 'Some other dude',
number: '666-6666',
title: 'Material',
description:
'Selling my wife olsdfjsdfk jfksdaj kasjfksf jdkasf jklasf jasklf jaskf',
url: '',
price: 30,
},
],
},
})
);
}, 1000);
}
function Phone() {
const { t, i18n } = useTranslation();
const { apps } = useApps();
const [settings] = useSettings();
const { addAlert } = useSnackbar();
// Set language from local storage
// This will only trigger on first mount & settings changes
useEffect(() => {
i18n.changeLanguage(settings.language.value).catch((e) => console.error(e));
}, [i18n, settings.language]);
useEffect(() => {
if (!isSettingsSchemaValid()) {
addAlert({
message: t('SETTINGS.MESSAGES.INVALID_SETTINGS'),
type: 'error',
});
}
// We only want to run this on first mount of the phone,
// so we leave an empty dep array. Otherwise, we hit a max depth error.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useConfig();
useKeyboardService();
useNuiService();
usePhoneService();
const { visibility } = usePhone();
const { settings, currentTheme } = useSettings();
const { allApps } = useApps();
useSimcardService();
useContactsService();
useTwitterService();
useMarketplaceService();
useInitKeyboard();
useSelloutService();
useBankService();
useMessagesService();
/*usePhotoService();*/
useCallService();
useDialService();
useNotesService();
usePhotoService();
const { modal: callModal } = useCallModal();
if (visibility === false) {
return null;
}
const calling = false;
document.onkeyup = function (data) {
if (data.which == 27) {
Nui.send('phone:close');
}
};
return (
<div>
<TopLevelErrorComponent>
<WindowSnackbar />
<PhoneWrapper>
<NotificationBar />
<div className="PhoneAppContainer">
<>
<Route exact path="/" component={HomeApp} />
{callModal && <Route exact path="/call" component={CallModal} />}
{apps.map((App) => (
<App.Route key={App.id} />
))}
</>
<NotificationAlert />
<PhoneSnackbar />
<ThemeProvider theme={currentTheme()}>
<div className='PhoneWrapper'>
<div style={{ zoom: settings.zoom }}>
<div className='Phone'>
<div
className='PhoneFrame'
style={{
backgroundImage: `url(./media/frames/${settings.frame})`,
}}
></div>
<div
id='phone'
className='PhoneScreen'
style={{
backgroundImage: `url(./media/backgrounds/${settings.wallpaper})`,
}}
>
<>
<NotificationBar
notifications={[
{
key: 'newMessage',
icon: <NotificationIcon Icon={MessageIcon} />,
},
]}
/>
<div className='PhoneAppContainer'>
{calling ? (
<CallModal />
) : (
<>
<Route exact path='/' component={HomeApp} />
{allApps.map((App) => (
<App.Route key={App.id} />
))}
</>
)}
</div>
<Navigation />
</>
</div>
</div>
<Navigation />
</PhoneWrapper>
</TopLevelErrorComponent>
</div>
</div>
</div>
</ThemeProvider>
);
}
export default Phone;
InjectDebugData<any>([
{
app: 'PHONE',
method: PhoneEvents.SET_VISIBILITY,
data: true,
},
{
app: 'PHONE',
method: PhoneEvents.SET_PHONE_READY,
data: true,
},
{
app: 'PHONE',
method: PhoneEvents.SET_TIME,
data: dayjs().format('hh:mm'),
},
{
app: 'PHONE',
method: PhoneEvents.SET_CONFIG,
data: DefaultConfig,
},
]);
-25
View File
@@ -1,25 +0,0 @@
import React from 'react';
import { ThemeProvider } from '@material-ui/core';
import { NotificationsProvider } from './os/notifications/providers/NotificationsProvider';
import { usePhoneTheme } from './os/phone/hooks/usePhoneTheme';
import SnackbarProvider from './ui/providers/SnackbarProvider';
import Phone from './Phone';
import { NuiProvider } from 'fivem-nui-react-lib';
import { SoundProvider } from './os/sound/providers/SoundProvider';
export const PhoneProviders = () => {
const currentTheme = usePhoneTheme();
return (
<NuiProvider resource="npwd">
<ThemeProvider theme={currentTheme}>
<SoundProvider>
<NotificationsProvider>
<SnackbarProvider>
<Phone />
</SnackbarProvider>
</NotificationsProvider>
</SoundProvider>
</ThemeProvider>
</NuiProvider>
);
};
-46
View File
@@ -1,46 +0,0 @@
import React from 'react';
import { isDefaultWallpaper } from './apps/settings/utils/isDefaultWallpaper';
import { useSettings } from './apps/settings/hooks/useSettings';
import { usePhoneVisibility } from './os/phone/hooks/usePhoneVisibility';
import { Slide } from '@material-ui/core';
const PhoneWrapper: React.FC = ({ children }) => {
const [settings] = useSettings();
const { bottom, visibility } = usePhoneVisibility();
return (
<Slide direction="up" timeout={{ enter: 500, exit: 500 }} in={visibility}>
<div className="PhoneWrapper">
<div
className="Phone"
style={{
position: 'fixed',
transformOrigin: 'right bottom',
transform: `scale(${settings.zoom.value}`,
bottom,
}}
>
<div
className="PhoneFrame"
style={{
backgroundImage: `url(media/frames/${settings.frame.value})`,
}}
/>
<div
id="phone"
className="PhoneScreen"
style={{
backgroundImage: !isDefaultWallpaper(settings.wallpaper.value)
? `url(${settings.wallpaper.value})`
: `url(media/backgrounds/${settings.wallpaper.value})`,
}}
>
{children}
</div>
</div>
</div>
</Slide>
);
};
export default PhoneWrapper;
+8 -7
View File
@@ -1,4 +1,4 @@
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');
@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap");
/* #### Generated By: http://www.cufonfonts.com #### */
@@ -7,11 +7,10 @@
font-style: normal;
font-weight: normal;
src: local('Bahnschrift Regular'), url('../fonts/BAHNSCHRIFT.woff') format('woff');
}
}
#account-section,
#transaction-section {
font-family: 'Bahnschrift Regular';
#account-section, #transaction-section {
font-family: 'Bahnschrift Regular'
}
#transaction-section .MuiTablePagination-root {
@@ -27,10 +26,12 @@
font-size: 50px;
}
#bank-app .Mui-selected {
color: #388cf8 !important;
color: #388CF8 !important;
}
#bank-app .MuiSnackbar-root {
position: absolute;
}
@@ -46,4 +47,4 @@
#actionButton a {
color: #fff;
}
}
+20 -60
View File
@@ -1,73 +1,27 @@
import React from 'react';
import { makeStyles } from '@material-ui/core';
import { makeStyles, Paper, Typography } from '@material-ui/core';
import { BankTitle } from './BankTitle';
import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent';
import { Button } from '../../../ui/components/Button';
import { useTranslation } from 'react-i18next';
import { useTransactions } from '../hooks/useTransactions';
import './BankApp.css';
import { TransferModal } from './transfers/TransferModal';
import { useBankModal } from '../hooks/useBankModal';
import { useCredentials } from '../hooks/useCredentials';
import { Switch, Route } from 'react-router-dom';
// image
import CreditCard from '../img/credit-card.png';
import { NavigationBar } from './navigation/NavigationBar';
import { BankHome } from './home/BankHome';
import { BankAccount } from './account/BankAccount';
import { TransactionList } from './transactions/TransactionList';
import InjectDebugData from '../../../os/debug/InjectDebugData';
InjectDebugData([
{
app: 'BANK',
method: 'setCredentials',
data: {
name: 'Firstname Lastname',
balance: 2000,
},
},
{
app: 'BANK',
method: 'setTransaction',
data: [
{
id: 1,
amount: 200,
type: 'Deposit',
source: 'chip',
},
{
id: 2,
amount: 200,
type: 'Withdraw',
source: 'chip',
},
{
id: 3,
amount: 200,
type: 'Withdraw',
source: 'chip',
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: 'chip',
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: 'chip',
},
{
id: 4,
amount: 50,
type: 'Deposit',
source: 'chip',
},
],
},
]);
import { BankAlert } from './alert/BankAlert';
const useStyles = makeStyles((theme) => ({
root: {
@@ -95,20 +49,26 @@ const useStyles = makeStyles((theme) => ({
}));
export const BankApp = () => {
const { showBankModal } = useBankModal();
const { showBankModal, setShowBankModal } = useBankModal();
const { t } = useTranslation();
const classes = useStyles();
const openTransactionsModal = () => {
setShowBankModal(true);
};
return (
<AppWrapper id="bank-app">
<AppWrapper id='bank-app'>
<BankTitle />
<TransferModal />
<div className={showBankModal ? classes.backgroundModal : undefined} />
<AppContent>
<Switch>
<Route path="/bank" exact component={BankHome} />
<Route path="/bank/account" exact component={BankAccount} />
<Route path="/bank/transactions" exact component={TransactionList} />
<Route path='/bank' exact component={BankHome} />
<Route path='/bank/account' exact component={BankAccount} />
<Route path='/bank/transactions' exact component={TransactionList} />
</Switch>
<BankAlert />
</AppContent>
<NavigationBar />
</AppWrapper>
+3 -2
View File
@@ -1,6 +1,7 @@
import React from 'react';
import Paper from '@material-ui/core/Paper';
import { Typography, makeStyles } from '@material-ui/core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import './BankApp.css';
@@ -23,8 +24,8 @@ const useStyles = makeStyles((theme) => ({
export const BankTitle = () => {
const classes = useStyles();
return (
<Paper className={classes.root} square variant="outlined" elevation={24}>
<Typography id="bank-title" style={{ margin: 0 }} variant="h4">
<Paper className={classes.root} square variant='outlined' elevation={24}>
<Typography id='bank-title' style={{ margin: 0 }} variant='h4'>
WhoDis Banking
</Typography>
</Paper>
@@ -1,6 +1,6 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Button } from '@material-ui/core';
import { makeStyles, Paper, Typography, Button } from '@material-ui/core';
import { useTransactions } from '../../hooks/useTransactions';
import useStyles from './account.styles';
@@ -13,13 +13,15 @@ export const AccountTransactions = (): any => {
Transfer: classes.depositType,
};
const transactionList = useTransactions();
const { transactionList } = useTransactions();
const { t } = useTranslation();
return (
<div id="account-section">
<div id='account-section'>
<div className={classes.header}>
<h2 className={classes.title}>{t('APPS_BANK_ACCOUNT_TRANSACTIONS')}</h2>
<Button className={classes.seeAll}>{t('APPS_BANK_ACCOUNT_SEE_TRANSACTION')}</Button>
<Button className={classes.seeAll}>
{t('APPS_BANK_ACCOUNT_SEE_TRANSACTION')}
</Button>
</div>
<div className={classes.transcationDiv}>
@@ -31,7 +33,7 @@ export const AccountTransactions = (): any => {
</div>
<div>
<p className={TransactionTypes[transaction.type]}>
{transaction.type === 'Withdraw' ? '-' : '+'}
{transaction.type == 'Withdraw' ? '-' : '+'}
{transaction.amount}
</p>
</div>
@@ -1,5 +1,6 @@
import React from 'react';
import { makeStyles } from '@material-ui/core';
import { Button } from '../../../../ui/components/Button';
import { makeStyles, Paper, Typography } from '@material-ui/core';
import { useTranslation } from 'react-i18next';
import { BankCard } from './BankCard';
import { AccountTransactions } from './AccountTransactions';
@@ -18,14 +19,18 @@ const useStyles = makeStyles((theme) => ({
export const BankAccount = () => {
const classes = useStyles();
const credentials = useCredentials();
const { credentials } = useCredentials();
const { t } = useTranslation();
return (
<div className={classes.root}>
<div>
<h1 className={classes.title}>{t('APPS_BANK_ACCOUNT_TITLE')}</h1>
</div>
<BankCard name={credentials.name} account="Checking" balance={credentials.balance} />
<BankCard
name={credentials.name}
account='Checking'
balance={credentials.balance}
/>
<AccountTransactions />
</div>
);
@@ -0,0 +1,8 @@
import React from "react";
import MuiAlert from "@material-ui/lab/Alert";
export function Alert(props) {
return <MuiAlert elevation={6} variant="filled" {...props} />;
}
export default Alert;
@@ -0,0 +1,43 @@
import React, { useState, useEffect } from 'react';
import { useBankAlert } from '../../hooks/useBankAlert';
import Snackbar from '@material-ui/core/Snackbar';
import Alert from './Alert';
import { useTranslation } from 'react-i18next';
export const BankAlert = () => {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const { bankAlert, setBankAlert } = useBankAlert();
const [message, setMessage] = useState(null);
const [severity, setSeverity] = useState('');
const _handleClose = () => {
setOpen(false);
setBankAlert(null);
};
useEffect(() => {
if (bankAlert === true) {
setOpen(true);
setMessage(t('APPS_BANK_ALERT_TRANSFER_SUCCESS'));
setSeverity('success');
} else if (bankAlert === false) {
setOpen(true);
setMessage(t('APPS_BANK_ALERT_TRANSFER_FAILURE'));
setSeverity('error');
}
}, [bankAlert]);
return (
<Snackbar
style={{ width: '80%' }}
open={open}
autoHideDuration={6000}
onClose={_handleClose}
>
<Alert onClose={_handleClose} severity={severity}>
{message}
</Alert>
</Snackbar>
);
};
@@ -12,7 +12,7 @@ import useStyles from './home.styles';
export const BankHome = () => {
const classes = useStyles();
const { setShowBankModal } = useBankModal();
const credentials = useCredentials();
const { credentials } = useCredentials();
const { t } = useTranslation();
const openTransactionsModal = () => {
@@ -24,17 +24,21 @@ export const BankHome = () => {
return (
<div className={classes.root}>
<Typography className={classes.headTitle}>
<span style={{ fontWeight: 'bold' }}>{t('APPS_BANK_HOME_TITLE')}</span>, {credentials.name}
<span style={{ fontWeight: 'bold' }}>{t('APPS_BANK_HOME_TITLE')}</span>,{' '}
{credentials.name}
</Typography>
<div className={classes.accounts}>
<h2 className={classes.accountsType}>Checking:</h2>
<p className={classes.accountBalance}>{credentials.balance}</p>
</div>
<div className={classes.actions}>
<Button id="actionButton" className={classes.actionButton}>
<NavLink to="/bank/account">{t('APPS_BANK_ACCOUNT_LINK')}</NavLink>
<Button id='actionButton' className={classes.actionButton}>
<NavLink to='/bank/account'>{t('APPS_BANK_ACCOUNT_LINK')}</NavLink>
</Button>
<Button onClick={openTransactionsModal} className={classes.actionButton}>
<Button
onClick={openTransactionsModal}
className={classes.actionButton}
>
{t('APPS_BANK_ACTIONS_TRANSFER')}
</Button>
</div>
@@ -3,7 +3,12 @@ import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import { BottomNavigation, BottomNavigationAction } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import { Home, List, Payment } from '@material-ui/icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faHome,
faList,
faMoneyCheck,
} from '@fortawesome/free-solid-svg-icons';
const useStyles = makeStyles((theme) => ({
root: {
@@ -29,9 +34,21 @@ export const NavigationBar = () => {
showLabels
className={classes.root}
>
<BottomNavigationAction component={Link} icon={<Home />} to="/bank" />
<BottomNavigationAction component={Link} icon={<Payment />} to="/bank/account" />
<BottomNavigationAction component={Link} icon={<List />} to="/bank/transactions" />
<BottomNavigationAction
component={Link}
icon={<FontAwesomeIcon icon={faHome} />}
to='/bank'
/>
<BottomNavigationAction
component={Link}
icon={<FontAwesomeIcon icon={faMoneyCheck} />}
to='/bank/account'
/>
<BottomNavigationAction
component={Link}
icon={<FontAwesomeIcon icon={faList} />}
to='/bank/transactions'
/>
</BottomNavigation>
);
};
@@ -0,0 +1,48 @@
import React, { useEffect, useState } from 'react';
import Notification from '../../../../ui/components/Notification';
import { usePhone } from '../../../../os/phone/hooks/usePhone';
import { useTranslation } from 'react-i18next';
import useStyles from './notification.style';
import { useBankNotification } from '../../hooks/useBankNotification';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faWonSign } from '@fortawesome/free-solid-svg-icons';
export const BankNotification = () => {
const { notification } = useBankNotification();
const classes = useStyles();
const { t } = useTranslation();
const [visible, setVisible] = useState(false);
const { config } = usePhone();
useEffect(() => {
if (notification) {
setVisible(true);
}
}, [notification?.id]);
if (!config?.bank.showNotifications || !notification) return null;
return (
<Notification
key={notification.id}
open={visible}
handleClose={() => setVisible(false)}
>
<div className={classes.content}>
<div className={classes.title}>
<div className={classes.titleLeft}>
<div className={classes.icon}>
<FontAwesomeIcon icon={faWonSign} />
</div>
<div className={classes.heading}>{notification.type}</div>
</div>
<div className={classes.justNow}>{t('APPS_BANK_TIME_JUST_NOW')}</div>
</div>
<div className={classes.message}>
{notification.source} sent you ${notification.transferAmount}.{' '}
<br></br> {notification.message}
</div>
</div>
</Notification>
);
};
@@ -0,0 +1,43 @@
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
const useStyles = makeStyles((theme: Theme) =>
createStyles({
content: {
padding: theme.spacing(2),
overflowY: 'hidden',
},
title: {
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'space-between',
alignItems: 'center',
},
titleLeft: {
display: 'flex',
flexFlow: 'row nowrap',
justifyContent: 'flex-start',
alignItems: 'center',
},
icon: {
marginTop: '3px',
marginRight: '5px',
},
heading: {
marginBottom: '3px',
},
justNow: {
fontSize: '18px',
fontStyle: 'italic',
paddingRight: '3px',
},
message: {
fontSize: '16px',
overflow: 'hidden',
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
},
})
);
export default useStyles;
@@ -5,7 +5,7 @@ import TablePagination from '@material-ui/core/TablePagination';
import { useTransactions } from '../../hooks/useTransactions';
export const TransactionList = () => {
const transactionList = useTransactions();
const { transactionList } = useTransactions();
const { t } = useTranslation();
const classes = useStyles();
const [page, setPage] = useState(0);
@@ -27,7 +27,7 @@ export const TransactionList = () => {
};
return (
<div id="transaction-section">
<div id='transaction-section'>
<div className={classes.header}>
<h2 className={classes.title}>{t('APPS_BANK_ACCOUNT_TRANSACTIONS')}</h2>
</div>
@@ -43,12 +43,22 @@ export const TransactionList = () => {
</div>
<div>
<p className={TransactionTypes[transaction.type]}>
{transaction.type === 'Withdraw' ? '-' : '+'}
{transaction.type == 'Withdraw' ? '-' : '+'}
{transaction.amount}
</p>
</div>
</div>
))}
<TablePagination
rowsPerPageOptions={[3, 5]}
className={classes.pagination}
component='div'
count={transactionList.length}
rowsPerPage={rowsPerPage}
page={page}
onChangePage={handleChangePage}
onChangeRowsPerPage={handleChangeRowsPerPage}
/>
</div>
</div>
);
@@ -1,10 +1,17 @@
import React, { useState } from 'react';
import Modal from '../../../../ui/components/Modal';
import { Button, List, ListItem, makeStyles } from '@material-ui/core';
import {
Button,
List,
ListItem,
TextField,
makeStyles,
} from '@material-ui/core';
import CloseIcon from '@material-ui/icons/Close';
import Nui from '../../../../os/nui-events/utils/Nui';
import { useBankModal } from '../../hooks/useBankModal';
import { BankEvents } from '../../../../../../typings/bank';
import { useNuiRequest } from 'fivem-nui-react-lib';
import { TextField } from '../../../../ui/components/Input';
const useStyles = makeStyles((theme) => ({
input: {
@@ -26,10 +33,14 @@ const useStyles = makeStyles((theme) => ({
fontSize: 16,
marginBottom: 30,
},
closeButton: {
position: 'absolute',
right: 0,
width: '10%',
},
}));
export const TransferModal = () => {
const Nui = useNuiRequest();
const classes = useStyles();
const [targetID, setTargetID] = useState('');
@@ -44,7 +55,7 @@ export const TransferModal = () => {
const addTransfer = () => {
const transferAmount = parseInt(amount);
Nui.send(BankEvents.ADD_TRANSFER, {
Nui.send('phone:addTransfer', {
targetID,
transferAmount,
message,
@@ -54,13 +65,16 @@ export const TransferModal = () => {
return (
<Modal visible={showBankModal} handleClose={_handleClose}>
<Button className={classes.closeButton} onClick={_handleClose}>
<CloseIcon />
</Button>
<List style={{ marginTop: 20 }}>
<ListItem>
<TextField
inputProps={{ className: classes.modalInputCenter }}
fullWidth
type="number"
placeholder="ID"
type='number'
placeholder='ID'
value={targetID}
onChange={(e) => setTargetID(e.target.value)}
/>
@@ -68,9 +82,9 @@ export const TransferModal = () => {
<ListItem>
<TextField
inputProps={{ className: classes.modalInputCenter }}
placeholder="Amount"
placeholder='Amount'
fullWidth
type="number"
type='number'
value={amount}
onChange={(e) => setAmount(e.target.value)}
/>
@@ -78,7 +92,7 @@ export const TransferModal = () => {
<ListItem>
<TextField
inputProps={{ className: classes.modalInput }}
placeholder="Message"
placeholder='Message'
fullWidth
value={message}
multiline
+9 -5
View File
@@ -3,18 +3,22 @@ import { atom } from 'recoil';
export const bankState = {
transactions: atom({
key: 'transactionList',
default: [],
default: []
}),
bankModal: atom({
key: 'modalVisibility',
default: false,
}),
transferSuccessful: atom({
key: 'bankAlert',
default: null
}),
bankCredentials: atom({
key: 'bankCredentails',
default: null,
default: null
}),
notification: atom({
key: 'bankNotification',
default: null,
}),
};
default: null
})
}
@@ -0,0 +1,7 @@
import { useRecoilState } from 'recoil';
import { bankState } from './state';
export const useBankAlert = (): any => {
const [ bankAlert, setBankAlert ] = useRecoilState(bankState.transferSuccessful);
return { bankAlert, setBankAlert };
}
+3 -8
View File
@@ -1,12 +1,7 @@
import { useRecoilState } from 'recoil';
import { bankState } from './state';
interface BankModalProps {
showBankModal: boolean;
setShowBankModal: (show: boolean) => void;
}
export const useBankModal = (): BankModalProps => {
const [showBankModal, setShowBankModal] = useRecoilState(bankState.bankModal);
export const useBankModal = () => {
const [ showBankModal, setShowBankModal ] = useRecoilState(bankState.bankModal);
return { showBankModal, setShowBankModal };
};
}
@@ -1,8 +1,13 @@
import { useRecoilValue } from 'recoil';
import { Transfer } from '../../../../../typings/bank';
import { Transfer } from '../../../common/typings/bank';
import { bankState } from './state';
export const useBankNotification = () => {
return useRecoilValue<Transfer | null>(bankState.notification);
interface IBankNotification {
notification: Transfer | null;
}
export const useBankNotification = (): IBankNotification => {
const notification = useRecoilValue<Transfer | null>(bankState.notification);
return { notification };
};
+15 -23
View File
@@ -1,30 +1,22 @@
import { useNuiEvent } from 'fivem-nui-react-lib';
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { bankState } from './state';
import { useTransactions } from './useTransactions';
import { useTransactions } from './useTransactions'
import { useCredentials } from './useCredentials';
import { useSetRecoilState } from 'recoil';
import { useBankAlert } from './useBankAlert';
import { useSetRecoilState } from 'recoil'
import { useBankNotification } from './useBankNotification';
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
import { BankEvents } from '../../../../../typings/bank';
export const useBankService = () => {
const setTransaction = useSetRecoilState(bankState.transactions);
const setCredentials = useSetRecoilState(bankState.bankCredentials);
const setTransaction = useSetRecoilState(bankState.transactions)
const setCredentials = useSetRecoilState(bankState.bankCredentials)
const setAlertMessage = useSetRecoilState(bankState.transferSuccessful)
const setNotification = useSetRecoilState(bankState.notification);
const { addAlert } = useSnackbar();
const { t } = useTranslation();
const handleAddAlert = ({ message, type }: IAlert) => {
addAlert({
message: t(`APPS_${message}`),
type,
});
};
useNuiEvent('BANK', BankEvents.SEND_TRANSFERS, setTransaction);
useNuiEvent('BANK', BankEvents.SEND_CREDENTIALS, setCredentials);
useNuiEvent('BANK', BankEvents.SEND_ALERT, handleAddAlert);
useNuiEvent('BANK', BankEvents.SEND_NOTIFICATION, setNotification);
return { useTransactions, useCredentials, useBankNotification };
};
///
useNuiEvent('BANK', 'setTransaction', setTransaction);
useNuiEvent('BANK', 'setCredentials', setCredentials);
useNuiEvent('BANK', 'setAlert', setAlertMessage);
useNuiEvent('BANK', 'setNotification', setNotification);
return { useTransactions, useCredentials, useBankAlert, useBankNotification };
}
+8 -3
View File
@@ -1,7 +1,12 @@
import { useRecoilValue } from 'recoil';
import { bankState } from './state';
import { IBankCredentials } from '../../../../../typings/bank';
import { IBankCredentials } from '../../../common/typings/bank';
export const useCredentials = () => {
return useRecoilValue<IBankCredentials>(bankState.bankCredentials);
interface ICredentialsHook {
credentials: IBankCredentials;
}
export const useCredentials = (): ICredentialsHook => {
const credentials = useRecoilValue(bankState.bankCredentials);
return { credentials };
};
+4 -4
View File
@@ -1,7 +1,7 @@
import { useRecoilValue } from 'recoil';
import { ITransactions } from '../../../../../typings/bank';
import { bankState } from './state';
import { useRecoilValue } from "recoil";
import { bankState } from './state';
export const useTransactions = () => {
return useRecoilValue<ITransactions[]>(bankState.transactions);
const transactionList = useRecoilValue(bankState.transactions);
return { transactionList };
};
@@ -1,108 +0,0 @@
import { AppWrapper } from '../../../ui/components';
import React, { Reducer, useReducer, useRef } from 'react';
import { AppContent } from '../../../ui/components/AppContent';
import { Box, makeStyles } from '@material-ui/core';
import { BrowserURLBar } from './BrowserURLBar';
import { promiseTimeout } from '../../../utils/promiseTimeout';
import { usePhoneConfig } from '../../../config/hooks/usePhoneConfig';
const useStyles = makeStyles(() => ({
iframe: {
height: '100%',
width: '100%',
zoom: 0.5,
border: 'none',
},
root: {
height: '100%',
display: 'flex',
flexDirection: 'column',
},
}));
interface BrowserState {
browserUrl: string;
browserHistory: string[];
}
interface ReducerAction {
payload: any;
type: ReducerActionsType;
}
enum ReducerActionsType {
SET_URL,
ADD_HISTORY,
RELOAD,
}
const browserReducer: Reducer<BrowserState, ReducerAction> = (state, action) => {
switch (action.type) {
case ReducerActionsType.ADD_HISTORY:
if (action.payload === 'about:blank') return state;
return { ...state, browserHistory: state.browserHistory.concat(action.payload) };
case ReducerActionsType.SET_URL:
return { ...state, browserUrl: action.payload };
default:
throw new Error('Invalid reducer action type');
}
};
export const BrowserApp: React.FC = () => {
const classes = useStyles();
const [{ appSettings }] = usePhoneConfig();
const [browserState, dispatch] = useReducer(browserReducer, {
browserUrl: appSettings.browserHomePage,
browserHistory: [appSettings.browserHomePage],
});
const { browserHistory, browserUrl } = browserState;
const iframeRef = useRef<HTMLIFrameElement | null>(null);
const _setBrowserUrl = (newUrl: string) => {
const formattedUrl = newUrl.match(/^(http|https):\/\//) ? newUrl : 'https://' + newUrl;
dispatch({ payload: browserUrl, type: ReducerActionsType.ADD_HISTORY });
dispatch({ payload: formattedUrl, type: ReducerActionsType.SET_URL });
};
const handleGoBack = () => {
if (browserHistory.length <= 1) return;
// Get last page from history
const lastPage = browserHistory[browserHistory.length - 1];
// Bail if last page is same as current
if (lastPage === browserUrl) return;
_setBrowserUrl(lastPage);
};
const reloadPage = async () => {
const strCopy = browserUrl.slice();
dispatch({ payload: 'about:blank', type: ReducerActionsType.SET_URL });
await promiseTimeout(100);
dispatch({ payload: strCopy, type: ReducerActionsType.SET_URL });
};
return (
<AppWrapper id="browser">
<AppContent className={classes.root}>
<BrowserURLBar
browserUrl={browserUrl}
browserHasHistory={browserHistory.length > 1}
setBrowser={_setBrowserUrl}
goBack={handleGoBack}
reloadPage={reloadPage}
/>
<Box flexGrow={1}>
<iframe
is="x-frame-bypass"
src={browserUrl}
// @ts-ignore
className={classes.iframe}
title="npwd-browser"
ref={iframeRef}
/>
</Box>
</AppContent>
</AppWrapper>
);
};
@@ -1,92 +0,0 @@
import React, { FocusEventHandler, useRef, useState } from 'react';
import { makeStyles, Theme, Box, IconButton } from '@material-ui/core';
import { Cached, KeyboardArrowLeft } from '@material-ui/icons';
import { InputBase } from '../../../ui/components/Input';
const useStyles = makeStyles((theme: Theme) => ({
urlInput: {
borderRadius: 18,
borderWidth: 1,
borderStyle: 'solid',
paddingRight: 10,
paddingLeft: 10,
marginLeft: 5,
borderColor: '#787878FF',
color: '#909090',
transition: 'color 0.1s ease',
},
urlInputFocused: {
color: '#fff',
},
root: {},
}));
interface BrowserControlsProps {
setBrowser: (url: string) => void;
browserUrl: string;
reloadPage: () => void;
browserHasHistory: boolean;
goBack: () => void;
}
export const BrowserURLBar: React.FC<BrowserControlsProps> = ({
goBack,
reloadPage,
browserHasHistory,
browserUrl,
setBrowser,
}) => {
const classes = useStyles();
const inputRef = useRef<HTMLInputElement>(null);
const [inputState, setInputState] = useState('');
const [isFocused, setFocus] = useState(false);
const handleFocus: FocusEventHandler = (e) => {
setInputState(browserUrl);
setFocus(true);
};
const handleFocusOut: FocusEventHandler = (e) => {
setFocus(false);
setInputState(browserUrl);
};
const handleChange: React.ChangeEventHandler<HTMLInputElement> = (e) => {
setInputState(e.target.value);
};
const onEnter: React.KeyboardEventHandler<HTMLInputElement> = (e) => {
if ((e as any).code !== 'Enter') return;
setBrowser(inputState);
e.currentTarget.blur();
};
const styledUrl = browserUrl.replace(/(^\w+:|^)\/\//, '');
const transformedUrl = isFocused ? inputState : styledUrl;
return (
<Box display="flex" py={1} className={classes.root} px={1}>
<IconButton size="small" onClick={() => reloadPage()}>
<Cached />
</IconButton>
{browserHasHistory && (
<IconButton size="small" onClick={() => goBack()}>
<KeyboardArrowLeft />
</IconButton>
)}
<InputBase
className={classes.urlInput}
ref={inputRef}
fullWidth
onChange={handleChange}
onKeyDown={onEnter}
value={transformedUrl}
classes={{ focused: classes.urlInputFocused }}
onFocus={handleFocus}
spellCheck={false}
onBlur={handleFocusOut}
/>
</Box>
);
};
@@ -1,10 +1,6 @@
import React, { useMemo } from 'react';
import React from 'react';
import { useCalculator, CalcButton } from '../hooks/useCalculator';
import { Grid, makeStyles, Box, Paper, Fab } from '@material-ui/core';
import { setClipboard } from '../../../os/phone/hooks/useClipboard';
import FileCopyIcon from '@material-ui/icons/FileCopy';
import { useSnackbar } from '../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
import { Grid, makeStyles, Box, Paper } from '@material-ui/core';
const useStyles = makeStyles((theme) => ({
button: {
@@ -16,12 +12,6 @@ const useStyles = makeStyles((theme) => ({
textAlign: 'right',
overflow: 'hidden',
textOverflow: 'ellipsis',
position: 'relative',
},
copyFab: {
position: 'absolute',
top: '16px',
left: '16px',
},
}));
@@ -47,43 +37,17 @@ export const Calculator = ({ ...props }) => {
eight,
nine,
} = useCalculator();
const { addAlert } = useSnackbar();
const classes = useStyles();
const resultStr = useMemo(
() =>
result().toLocaleString(undefined, {
minimumFractionDigits: 0,
maximumFractionDigits: 4,
}),
[result],
);
const { t } = useTranslation();
return (
<Box display="flex" flexDirection="column">
<Box display='flex' flexDirection='column'>
<Box flexGrow={1} component={Paper} p={4} className={classes.result}>
<Fab
size="small"
onClick={() => {
setClipboard(resultStr);
addAlert({
message: t('GENERIC_WRITE_TO_CLIPBOARD_MESSAGE', {
content: 'number',
}),
type: 'success',
});
}}
className={classes.copyFab}
>
<FileCopyIcon />
</Fab>
{resultStr}
{result().toLocaleString(undefined, {
minimumFractionDigits: 0,
maximumFractionDigits: 4,
})}
</Box>
<Box>
<Grid container justify="space-around">
<Grid container justify='space-around'>
<CalcButton button={clear} className={classes.button} />
<CalcButton button={clearAll} className={classes.button} />
<CalcButton button={divider} className={classes.button} />
@@ -1,12 +1,12 @@
import React from 'react';
import { AppWrapper } from '../../../ui/components';
import { AppTitle } from '../../../ui/components/AppTitle';
import { AppContent } from '../../../ui/components/AppContent';
import { Calculator } from './Calculator';
import { useApp } from '../../../os/apps/hooks/useApps';
import React from "react";
import { AppWrapper } from "../../../ui/components";
import { AppTitle } from "../../../ui/components/AppTitle";
import { AppContent } from "../../../ui/components/AppContent";
import { Calculator } from "./Calculator";
import { useApp } from "../../../os/apps/hooks/useApps";
export const CalculatorApp = () => {
const calculator = useApp('CALCULATOR');
const calculator = useApp("CALCULATOR");
return (
<AppWrapper>
<AppTitle app={calculator} />
@@ -1,7 +1,7 @@
import React from 'react';
import { SvgIcon, SvgIconProps } from '@material-ui/core';
import React from "react";
import { SvgIcon } from "@material-ui/core";
export const CalculatorIcon = ({ ...props }: SvgIconProps) => {
export const CalculatorIcon = ({ ...props }) => {
return (
<SvgIcon {...props}>
<svg
+25 -17
View File
@@ -1,22 +1,30 @@
import React from 'react';
import { AppWrapper } from '../../../ui/components';
import { AppContent } from '../../../ui/components/AppContent';
import { Fab } from '@material-ui/core';
import React from 'react'
import { AppWrapper } from "../../../ui/components";
import { AppContent } from "../../../ui/components/AppContent";
import { usePhotoModal } from '../hooks/usePhotoModal';
import { GalleryGrid } from './grid/GalleryGrid';
import { GalleryModal } from './modal/GalleryModal';
import { Route, Switch } from 'react-router-dom';
import { LoadingSpinner } from '../../../ui/components/LoadingSpinner';
const CameraApp: React.FC = () => (
<AppWrapper id="camera-app">
<AppContent>
<Switch>
<React.Suspense fallback={<LoadingSpinner />}>
<Route path="/camera" exact component={GalleryGrid} />
<Route path="/camera/image" exact component={GalleryModal} />
</React.Suspense>
</Switch>
</AppContent>
</AppWrapper>
);
const CameraApp = () => {
const {modal} = usePhotoModal();
return (
<AppWrapper id='camera-app'>
<AppContent>
<GalleryModal />
{/*<Router>
<Switch>
<Route path="/camera/image" component={GalleryModal} />
<Route path="/" exact component={GalleryGrid} />
</Switch>
</Router>*/}
{!modal ? <GalleryGrid /> : null}
</AppContent>
</AppWrapper>
)
}
export default CameraApp;
@@ -1,80 +1,62 @@
import React, { useState } from 'react';
import { Box, Button, CircularProgress } from '@material-ui/core';
import React from 'react'
import { Box, Button } from '@material-ui/core';
import useStyles from './grid.styles';
import { usePhotos } from '../../hooks/usePhotos';
import AddIcon from '@material-ui/icons/Add';
import { useHistory } from 'react-router-dom';
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
import { addQueryToLocation } from '../../../../common/utils/addQueryToLocation';
import { getLocationFromUrl } from '../../../../common/utils/getLocationFromUrl';
import { fetchNui } from '../../../../utils/fetchNui';
import { ServerPromiseResp } from '../../../../../../typings/common';
import { GalleryPhoto, PhotoEvents } from '../../../../../../typings/photo';
import { usePhotoActions } from '../../hooks/usePhotoActions';
import { usePhotosValue } from '../../hooks/state';
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
import { useTranslation } from 'react-i18next';
import Nui from '../../../../os/nui-events/utils/Nui';
import { usePhotoModal } from '../../hooks/usePhotoModal';
import { usePhotoMeta } from '../../hooks/usePhotoMeta';
import { useModal } from '../../../contacts/hooks/useModal';
//import { useHistory } from 'react-router-dom';
export const GalleryGrid = () => {
const classes = useStyles();
const history = useHistory();
const query = useQueryParams();
const { addAlert } = useSnackbar();
const { t } = useTranslation();
const photos = usePhotosValue();
const { takePhoto } = usePhotoActions();
const [isLoading, setIsLoading] = useState<boolean>(false);
// isMessage will work as a style handler kinda. If the gallery is rendered in the messages,
// it will have the value true, which basically means a tweak on the design to fit in a modal
export const GalleryGrid = (isMessags) => {
const classes = useStyles()
const { setMeta } = usePhotoMeta();
const { setModal } = usePhotoModal();
const referal = query.referal ? decodeURIComponent(query.referal) : '/camera/image';
//let history = useHistory();
const photos = usePhotos();
console.log(photos)
const handleCamera = () => {
Nui.send('phone:TakePhoto', {})
}
const handlePhotoOpen = (photo) => {
history.push(addQueryToLocation(getLocationFromUrl(referal), 'image', photo.image));
};
setModal(true)
setMeta(photo)
//history.push('/camera/image')
}
const handleTakePhoto = () => {
setIsLoading(true);
fetchNui<ServerPromiseResp<GalleryPhoto>>(PhotoEvents.TAKE_PHOTO).then((serverResp) => {
if (serverResp.status !== 'ok') {
return addAlert({
message: t('APPS_CAMERA_FAILED_TO_TAKE_PHOTO'),
type: 'error',
});
}
takePhoto(serverResp.data);
setIsLoading(false);
});
};
if (!photos)
return (
<Box display="flex" flexWrap="wrap" alignContent="flex-start" className={classes.root}>
if(!photos) return (
<Box display="flex" flexWrap="wrap" alignContent="flex-start" className={classes.root}>
<Box>
<Button onClick={takePhoto} style={{ borderRadius: 0 }} className={classes.photo}>
<AddIcon fontSize="large" />
<Button onClick={handleCamera} style={{ borderRadius: 0 }} className={classes.photo}>
<AddIcon fontSize="large"/>
</Button>
</Box>
</Box>
);
)
return (
<div>
<Box display="flex" flexWrap="wrap" alignContent="flex-start" className={classes.root}>
<Box>
<Button
disabled={isLoading}
onClick={handleTakePhoto}
style={{ borderRadius: 0 }}
className={classes.photo}
>
{!isLoading ? <AddIcon fontSize="large" /> : <CircularProgress />}
<Button onClick={handleCamera} style={{ borderRadius: 0 }} className={classes.photo}>
<AddIcon fontSize="large"/>
</Button>
</Box>
{photos.map((photo) => (
<Box key={photo.id} onClick={() => handlePhotoOpen(photo)}>
{photos.map(photo => (
<Box onClick={() => handlePhotoOpen(photo)}>
<div style={{ backgroundImage: `url(${photo.image})` }} className={classes.photo} />
</Box>
))}
</Box>
</div>
);
};
)
}
@@ -2,7 +2,7 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
const useStyles = makeStyles((theme: Theme) => ({
root: {
flexGrow: 1,
flexGrow: 1
},
photo: {
border: '1px inset #fff',
@@ -13,7 +13,7 @@ const useStyles = makeStyles((theme: Theme) => ({
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
},
}));
}
}))
export default useStyles;
export default useStyles;
@@ -1,78 +1,62 @@
import React, { useMemo, useState, useCallback } from 'react';
import React from 'react'
import Modal from '../../../../ui/components/Modal';
import { usePhotoMeta } from '../../hooks/usePhotoMeta';
import { usePhotoModal } from '../../hooks/usePhotoModal';
import useStyles from './modal.styles';
import { useHistory } from 'react-router-dom';
import { Button, Paper } from '@material-ui/core';
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
import DeleteIcon from '@material-ui/icons/Delete';
import ShareIcon from '@material-ui/icons/Share';
import { useHistory } from 'react-router-dom';
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
import Nui from '../../../../os/nui-events/utils/Nui';
import { useShareModal } from '../../hooks/useShareModal';
import { ShareModal } from './ShareModal';
import { GalleryPhoto, PhotoEvents } from '../../../../../../typings/photo';
import { usePhotoActions } from '../../hooks/usePhotoActions';
import { fetchNui } from '../../../../utils/fetchNui';
import { ServerPromiseResp } from '../../../../../../typings/common';
import { useTranslation } from 'react-i18next';
import { useSnackbar } from '../../../../ui/hooks/useSnackbar';
import { useShareLink } from '../../hooks/useShareLink';
export const GalleryModal = () => {
const [shareOpen, setShareOpen] = useState(null);
const { meta, setMeta } = usePhotoMeta();
const { modal, setModal } = usePhotoModal();
const classes = useStyles();
const history = useHistory();
const query = useQueryParams();
const { deletePhoto } = usePhotoActions();
const { addAlert } = useSnackbar();
const { t } = useTranslation();
const referal = query.referal || '/camera';
const { shareModal ,setShareModal } = useShareModal();
const { setShareLink } = useShareLink();
const meta: GalleryPhoto = useMemo(
() => ({ id: parseInt(query.id), image: query.image as string }),
[query],
);
const _handleClose = () => {
history.push(referal);
};
setModal(false)
setMeta(null);
}
const handleDeletePhoto = () => {
fetchNui<ServerPromiseResp<GalleryPhoto>>(PhotoEvents.DELETE_PHOTO, {
image: meta.image,
}).then((serverResp) => {
if (serverResp.status !== 'ok') {
return addAlert({ message: t('APPS_CAMERA_FAILED_TO_DELETE_PHOTO'), type: 'error' });
}
console.log(meta.id)
Nui.send('photo:deletePhoto', {
id: meta.id
})
setModal(false)
}
deletePhoto(meta.image);
history.push(referal);
});
};
const handleSharePhoto = useCallback(() => {
setShareOpen(meta);
}, [meta]);
if (!meta) return null;
const handleSharePhoto = () => {
setShareModal(true)
setShareLink(meta.image)
}
if(!meta) return null;
return (
<>
<ShareModal referal={referal} meta={shareOpen} onClose={() => setShareOpen(null)} />
<Paper className={classes.modal}>
<div className={shareOpen ? classes.backgroundModal : null} />
<Button onClick={_handleClose}>
<ArrowBackIcon />
<Paper className={modal ? classes.modal : classes.modalHide}>
<ShareModal key={meta.id} {...meta}/>
<div className={shareModal ? classes.backgroundModal : undefined} />
<Button onClick={_handleClose}><ArrowBackIcon /></Button>
<div className={classes.image} style={{ backgroundImage: `url(${meta.image})`}} />
<div className={classes.actionDiv}>
<Button onClick={handleDeletePhoto}>
<DeleteIcon fontSize="large" />
</Button>
<div className={classes.image} style={{ backgroundImage: `url(${meta.image})` }} />
<div className={classes.actionDiv}>
<Button onClick={handleDeletePhoto}>
<DeleteIcon fontSize="large" />
</Button>
<Button onClick={handleSharePhoto}>
<ShareIcon fontSize="large" />
</Button>
</div>
</Paper>
</>
);
};
<Button onClick={handleSharePhoto}>
<ShareIcon fontSize="large" />
</Button>
</div>
</Paper>
)
}
@@ -1,42 +1,47 @@
import React from 'react';
import React, { useRef, useState } from 'react';
import Modal from '../../../../ui/components/Modal';
import { useShareLink } from '../../hooks/useShareLink';
import { useShareModal } from '../../hooks/useShareModal';
import { Button } from '@material-ui/core';
import MessageIcon from '@material-ui/icons/Message';
import { setClipboard } from '../../../../os/phone/hooks/useClipboard';
import CloseIcon from '@material-ui/icons/Close';
import useStyles from './modal.styles';
import { useHistory } from 'react-router-dom';
import { GalleryPhoto } from '../../../../../../typings/photo';
import Nui from '../../../../os/nui-events/utils/Nui';
interface IShareModalProps {
meta: GalleryPhoto;
referal: string;
onClose(): void;
}
export const ShareModal = ({ meta, onClose, referal }: IShareModalProps) => {
export const ShareModal = (meta) => {
const classes = useStyles();
const history = useHistory();
const { shareModal, setShareModal } = useShareModal();
const { setShareLink } = useShareLink();
const _handleClose = () => {
setShareModal(false);
setShareLink(null);
};
const handleCopyImage = () => {
setClipboard(meta.image);
history.push(referal);
};
return (
<Modal visible={!!meta} handleClose={onClose}>
<Modal visible={shareModal} handleClose={_handleClose}>
<div className={classes.shareModal}>
<Button
style={{ position: 'absolute', right: 0, width: '10%' }}
onClick={_handleClose}
>
<CloseIcon />
</Button>
<div className={classes.innerShareModal}>
<>
<h4 style={{ textAlign: 'center', marginTop: 20 }}>
Where do you want to share the photo?
</h4>
<Button>{<MessageIcon />} Message</Button>
<h4>Or just copy the image here:</h4>
<Button onClick={handleCopyImage} variant="contained">
Copy image
</Button>
</>
<h4 style={{ textAlign: 'center', marginTop: 20 }}>
Where do you want to share the photo?
</h4>
<Button>{<MessageIcon />} Message</Button>
<h4>Or just copy the image here:</h4>
<Button onClick={handleCopyImage} variant='contained'>
Copy image
</Button>
</div>
</div>
</Modal>
@@ -2,9 +2,9 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
const useStyles = makeStyles((theme: Theme) => ({
backgroundModal: {
background: 'black',
opacity: '0.6',
position: 'absolute',
background: "black",
opacity: "0.6",
position: "absolute",
top: 0,
left: 0,
right: 0,
@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme: Theme) => ({
width: '100%',
},
modalHide: {
display: 'none',
display: 'none'
},
image: {
width: 'auto',
@@ -27,22 +27,22 @@ const useStyles = makeStyles((theme: Theme) => ({
backgroundPosition: 'center',
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
marginTop: '4em',
marginTop: '4em'
},
actionDiv: {
marginTop: 15,
display: 'flex',
justifyContent: 'space-evenly',
justifyContent: 'space-evenly'
},
// share modal
shareModal: {
marginBottom: 50,
marginBottom: 50
},
innerShareModal: {
marginTop: 40,
textAlign: 'center',
},
}));
textAlign: 'center'
}
}))
export default useStyles;
export default useStyles;
+20 -29
View File
@@ -1,33 +1,24 @@
import { atom, selector, useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { ServerPromiseResp } from '../../../../../typings/common';
import { GalleryPhoto, PhotoEvents } from '../../../../../typings/photo';
import { fetchNui } from '../../../utils/fetchNui';
import LogDebugEvent from '../../../os/debug/LogDebugEvents';
import { isEnvBrowser } from '../../../utils/misc';
import { MockPhotoData } from '../utils/constants';
import { atom } from 'recoil';
export const photoState = {
photos: atom<GalleryPhoto[]>({
photos: atom({
key: 'galleryPhotos',
default: selector({
key: 'defaultGalleryPhotos',
get: async () => {
try {
const resp = await fetchNui<ServerPromiseResp<GalleryPhoto[]>>(PhotoEvents.FETCH_PHOTOS);
LogDebugEvent({ action: 'PhotosFetched', data: resp.data });
return resp.data;
} catch (e) {
if (isEnvBrowser()) {
return MockPhotoData;
}
console.error(e);
return [];
}
},
}),
default: null
}),
};
export const useSetPhotos = () => useSetRecoilState(photoState.photos);
export const usePhotos = () => useRecoilState(photoState.photos);
export const usePhotosValue = () => useRecoilValue(photoState.photos);
modal: atom({
key: 'photoModal',
default: false
}),
photoMeta: atom({
key: 'photoMeta',
default: null
}),
shareModal: atom({
key: 'phoneShareModal',
default: false
}),
shareLink: atom({
key: 'photoShareLink',
default: null
})
}
-61
View File
@@ -1,61 +0,0 @@
import { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { SetterOrUpdater, useRecoilState } from 'recoil';
import { GalleryPhoto, PhotoEvents } from '../../../../../typings/photo';
import { useNuiEvent, useNuiCallback } from 'fivem-nui-react-lib/';
import { useSnackbar } from '../../../ui/hooks/useSnackbar';
import { photoState } from './state';
interface IUseCamera {
photos: GalleryPhoto[];
setPhotos: SetterOrUpdater<GalleryPhoto[]>;
takePhoto: () => void;
isLoading: boolean;
}
export const useCamera = (): IUseCamera => {
const { t } = useTranslation();
const { addAlert } = useSnackbar();
const [photos, setPhotos] = useRecoilState<GalleryPhoto[]>(photoState.photos);
const [isUploading, setUploading] = useState(false);
const onPhotoSuccess = useCallback(
(photo) => {
setUploading(false);
if (!photo?.image) return;
setPhotos((curr) => [photo, ...curr]);
},
[setPhotos],
);
const onPhotoError = useCallback(
(i18nKey) => {
setUploading(false);
addAlert({ type: 'error', message: t(i18nKey) });
},
[addAlert, t],
);
const [_takePhoto] = useNuiCallback<void, GalleryPhoto>(
'CAMERA',
PhotoEvents.TAKE_PHOTO,
onPhotoSuccess,
onPhotoError,
);
useNuiEvent('CAMERA', PhotoEvents.UPLOAD_PHOTO, () => setUploading(true));
const takePhoto = () => {
// Timeout at 1 minute
_takePhoto(undefined, { timeout: 60000 });
};
return {
photos,
setPhotos,
takePhoto,
isLoading: isUploading,
};
};
@@ -1,22 +0,0 @@
import { useSetPhotos } from './state';
import { useCallback } from 'react';
export const usePhotoActions = () => {
const setPhotos = useSetPhotos();
const takePhoto = useCallback(
(photo) => {
setPhotos((curPhotos) => [photo, ...curPhotos]);
},
[setPhotos],
);
const deletePhoto = useCallback(
(image: string) => {
setPhotos((curPhotos) => [...curPhotos].filter((meta) => meta.image !== image));
},
[setPhotos],
);
return { takePhoto, deletePhoto };
};
@@ -0,0 +1,7 @@
import { useRecoilState } from 'recoil';
import { photoState } from './state';
export const usePhotoMeta = () => {
const [meta, setMeta] = useRecoilState(photoState.photoMeta);
return { meta, setMeta};
}
@@ -0,0 +1,7 @@
import { useRecoilState } from 'recoil';
import { photoState } from './state';
export const usePhotoModal = () => {
const [modal, setModal] = useRecoilState(photoState.modal);
return { modal, setModal}
}
@@ -0,0 +1,10 @@
import { useSetRecoilState } from 'recoil';
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import { photoState } from './state';
import { usePhotos } from './usePhotos';
export const usePhotoService = () => {
const setPhotos = useSetRecoilState(photoState.photos);
useNuiEvent('CAMERA', 'setPhotos', setPhotos);
return usePhotos();
}
+14
View File
@@ -0,0 +1,14 @@
import { useRecoilValue } from 'recoil';
import { photoState } from './state';
interface IPhotos {
image: string[];
map?: any;
}
export const usePhotos = (): IPhotos | null => {
const photos = useRecoilValue<IPhotos | null>(photoState.photos);
return photos;
}
@@ -0,0 +1,7 @@
import { useRecoilState } from 'recoil';
import { photoState } from './state';
export const useShareLink = () => {
const [ shareLink, setShareLink ] = useRecoilState(photoState.shareLink);
return { shareLink, setShareLink }
}
@@ -0,0 +1,7 @@
import { useRecoilState } from 'recoil';
import { photoState } from './state';
export const useShareModal = () => {
const [ shareModal, setShareModal ] = useRecoilState(photoState.shareModal);
return { shareModal, setShareModal }
}
-10
View File
@@ -1,10 +0,0 @@
export const MockPhotoData = [
{
id: 1,
image: 'https://beta.iodine.gg/noDcb.jpeg',
},
{
id: 2,
image: 'https://beta.iodine.gg/teUcY.jpeg',
},
];
@@ -0,0 +1,3 @@
#contact-app .Mui-focused::after {
border-bottom: #2196f3 solid 4px;
}
@@ -0,0 +1,87 @@
import React, { useState } from 'react';
import { makeStyles, Theme } from '@material-ui/core/styles';
import { Button, TextField } from '@material-ui/core';
import Nui from '../../../os/nui-events/utils/Nui';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import Modal from '../../../ui/components/Modal';
import { useModal } from '../hooks/useModal';
import ClearIcon from '@material-ui/icons/Clear';
import PersonIcon from '@material-ui/icons/Person';
import PhoneIcon from '@material-ui/icons/Phone';
import AccountCircleIcon from '@material-ui/icons/AccountCircle';
import useStyles from './styles.contactmodal';
export const AddContactModal = () => {
const [name, setName] = useState('');
const [number, setNumber] = useState('');
const [avatar, setAvatar] = useState('');
const classes = useStyles();
const { showModal, setShowModal } = useModal();
const addContact = () => {
if (name === '' || number === '') {
console.log('You need to pass in values');
} else {
Nui.send('contacts:add', {
name,
number,
avatar,
});
console.log(name, number, avatar);
}
};
const _handleClose = () => {
setShowModal(false);
};
return (
<Modal visible={showModal} handleClose={_handleClose}>
<Button onClick={_handleClose} className={classes.clearButton}>
<ClearIcon />
</Button>
<List style={{ marginTop: 30 }}>
<ListItem>
<PersonIcon className={classes.icons} />
<TextField
value={name}
inputProps={{ className: classes.textInputField }}
onChange={(e) => setName(e.target.value)}
fullWidth
variant='standard'
placeholder='Name'
/>
</ListItem>
<ListItem>
<PhoneIcon className={classes.icons} />
<TextField
value={number}
inputProps={{ className: classes.textInputField }}
onChange={(e) => setNumber(e.target.value)}
fullWidth
placeholder='Number'
variant='standard'
type='text'
/>
</ListItem>
<ListItem>
<AccountCircleIcon className={classes.icons} />
<TextField
value={avatar}
inputProps={{ className: classes.textInputField }}
onChange={(e) => setAvatar(e.target.value)}
fullWidth
placeholder='Avatar URL'
variant='standard'
type='text'
/>
</ListItem>
</List>
<Button className={classes.addBtn} onClick={addContact}>
Add Contact
</Button>
</Modal>
);
};
@@ -0,0 +1,13 @@
import React from 'react';
import Paper from '@material-ui/core/Paper';
import ContactsIcon from '@material-ui/icons/Contacts';
import useStyles from './styles.contacts';
export const ContactTitle = () => {
const classes = useStyles();
return (
<Paper className={classes.root} square variant='outlined' elevation={24}>
<ContactsIcon className={classes.icon} />
</Paper>
);
};
@@ -1,49 +1,49 @@
import React from 'react';
import { AppWrapper } from '../../../ui/components';
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
import { AppTitle } from '../../../ui/components/AppTitle';
import { AppContent } from '../../../ui/components/AppContent';
import { ContactList } from './List/ContactList';
import { useApp } from '../../../os/apps/hooks/useApps';
import { Route } from 'react-router-dom';
import ContactsInfoPage from './views/ContactInfo';
import { ContactPage } from './views/ContactsPage';
import { ContactsThemeProvider } from '../providers/ContactsThemeProvider';
import { AddContactModal } from './ContactModal';
import { useModal } from '../hooks/useModal';
import { SearchContacts } from './List/SearchContacts';
import PersonAddIcon from '@material-ui/icons/PersonAdd';
import Fab from '@material-ui/core/Fab';
import { useHistory } from 'react-router';
import { makeStyles, Theme } from '@material-ui/core/styles';
import { LoadingSpinner } from '../../../ui/components/LoadingSpinner';
import { InfoModal } from './modal/InfoModal';
import { useContactDetail } from '../hooks/useContactDetail';
import { ContactAlert } from './alert/ContactAlert';
const useStyles = makeStyles((theme: Theme) => ({
absolute: {
position: 'absolute',
right: theme.spacing(3),
bottom: theme.spacing(2),
},
}));
import useStyles from './styles.contacts';
export const ContactsApp = () => {
const contacts = useApp('CONTACTS');
const history = useHistory();
const classes = useStyles();
const { showModal, setShowModal } = useModal();
const contacts = useApp('CONTACTS');
const { contactDetail } = useContactDetail();
const openModal = () => {
setShowModal(true);
};
return (
<ContactsThemeProvider>
<AppWrapper id="contact-app">
<AppTitle app={contacts} />
<AppContent>
<React.Suspense fallback={<LoadingSpinner />}>
<Route path="/contacts/" exact component={ContactPage} />
<Route path="/contacts/:id" exact component={ContactsInfoPage} />
</React.Suspense>
</AppContent>
<AppWrapper id='contact-app'>
<AppTitle app={contacts} />
<SearchContacts />
<AddContactModal />
<InfoModal key={contactDetail?.id} />
<div className={showModal ? classes.backgroundModal : undefined} />
<AppContent>
<ContactList />
<Fab
color="primary"
onClick={() => history.push('/contacts/-1')}
onClick={openModal}
style={{ backgroundColor: '#2196f3', color: '#fff' }}
className={classes.absolute}
>
<PersonAddIcon />
</Fab>
</AppWrapper>
</ContactsThemeProvider>
<ContactAlert />
</AppContent>
</AppWrapper>
);
};
@@ -1,68 +1,110 @@
import React from 'react';
import ListItemText from '@material-ui/core/ListItemText';
import { Button, ListItemAvatar, Avatar as MuiAvatar, List, ListItem } from '@material-ui/core';
import {
Button,
ListItemAvatar,
Avatar as MuiAvatar,
List,
ListItem,
TextField,
Collapse,
makeStyles,
} from '@material-ui/core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faPen } from '@fortawesome/free-solid-svg-icons';
import { useFilteredContacts } from '../../hooks/useFilteredContacts';
import PhoneIcon from '@material-ui/icons/Phone';
import ChatIcon from '@material-ui/icons/Chat';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import { SearchContacts } from './SearchContacts';
import { useHistory } from 'react-router-dom';
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
import { useFilteredContacts } from '../../hooks/state';
import { useCall } from '../../../../os/call/hooks/useCall';
import { useContacts } from '../../hooks/useContacts';
import { useContactModal } from '../../hooks/useContactModal';
import { useContactDetail } from '../../hooks/useContactDetail';
import Nui from '../../../../os/nui-events/utils/Nui';
import '../Contact.css';
import { ContactAlert } from '../alert/ContactAlert';
const useStyles = makeStyles((theme) => ({
updateButton: {
margin: 'auto',
fontSize: 14,
width: 150,
background: '#2196f3',
marginBottom: 10,
padding: 8,
},
collapseItem: {
margin: 'auto',
width: '50%',
},
}));
export const ContactList = () => {
const filteredContacts = useFilteredContacts();
const history = useHistory();
const { initializeCall } = useCall();
const { filteredContacts } = useFilteredContacts();
const { setShowContactModal } = useContactModal();
const { contactDetail, setContactDetail } = useContactDetail();
const openContactInfo = (contactId: number) => {
history.push(`/contacts/${contactId}`);
const contacts = useContacts();
const openContactInfo = (contact) => {
setShowContactModal(true);
setContactDetail(contact);
console.log('CONTACT', contactDetail);
};
const startCall = (number: string) => {
LogDebugEvent({
action: 'Emitting `Start Call` to Scripts',
level: 2,
data: true,
const startCall = (number) => {
console.log(number);
Nui.send('phone:startCall', {
number,
});
initializeCall(number);
};
const handleMessage = (phoneNumber: string) => {
LogDebugEvent({
action: 'Routing to Message',
level: 1,
data: { phoneNumber },
});
history.push(`/messages/new/${phoneNumber}`);
};
return (
<>
<SearchContacts />
<List>
{filteredContacts.map((contact) => (
<ListItem key={contact.id} divider>
<ListItemAvatar>
{contact.avatar ? (
<MuiAvatar src={contact.avatar} />
) : (
<MuiAvatar>{contact.display.slice(0, 1).toUpperCase()}</MuiAvatar>
)}
</ListItemAvatar>
<ListItemText primary={contact.display} secondary={contact.number} />
<Button onClick={() => startCall(contact.number)}>
<PhoneIcon />
</Button>
<Button onClick={() => handleMessage(contact.number)}>
<ChatIcon />
</Button>
<Button style={{ margin: -15 }} onClick={() => openContactInfo(contact.id)}>
<MoreVertIcon />
</Button>
</ListItem>
<List>
{contacts.contacts
.filter(
(contact) =>
contact.display.includes(filteredContacts.toLowerCase()) ||
contact.number.includes(filteredContacts.toLowerCase())
)
.map((contact) => (
<>
<ListItem key={contact.id} divider>
<ListItemAvatar>
{contact.avatar ? (
<MuiAvatar src={contact.avatar} />
) : (
<MuiAvatar>
{contact.display.slice(0, 1).toUpperCase()}
</MuiAvatar>
)}
</ListItemAvatar>
<ListItemText
primary={contact.display}
secondary={contact.number}
/>
<Button onClick={() => startCall(contact.number)}>
<PhoneIcon />
</Button>
<Button
onClick={() =>
console.log('Message: ' + contact.display, contact.number)
}
>
<ChatIcon />
</Button>
<Button
style={{ margin: -15 }}
onClick={() => openContactInfo(contact)}
>
<MoreVertIcon />
</Button>
</ListItem>
</>
))}
</List>
</>
</List>
);
};
@@ -1,30 +1,94 @@
import React, { useEffect, useState } from 'react';
import { Box } from '@material-ui/core';
import React from 'react';
import { InputBase } from '@material-ui/core';
import SearchIcon from '@material-ui/icons/Search';
import {
createStyles,
fade,
Theme,
makeStyles,
} from '@material-ui/core/styles';
import { useTranslation } from 'react-i18next';
import { useFilteredContacts } from '../../hooks/useFilteredContacts';
import { SearchField } from '../../../../ui/components/SearchField';
import { useDebounce } from '../../../../os/phone/hooks/useDebounce';
import { useSetContactFilterInput } from '../../hooks/state';
const useStyles = makeStyles((theme: Theme) =>
createStyles({
bg: {
backgroundColor: '#232323',
display: 'flex',
height: 60,
justifyContent: 'center',
alignItems: 'center',
},
textFieldInput: {
fontSize: 20,
},
inputRoot: {
color: '#fff',
fontSize: 18,
},
inputInput: {
padding: theme.spacing(1, 4, 1, 4),
transition: theme.transitions.create('width'),
width: '100%',
[theme.breakpoints.up('sm')]: {
width: '13ch',
'&:focus': {
width: '20ch',
},
},
},
search: {
position: 'relative',
borderRadius: theme.shape.borderRadius,
backgroundColor: fade(theme.palette.common.white, 0.15),
'&:hover': {
backgroundColor: fade(theme.palette.common.white, 0.25),
},
marginLeft: 0,
width: '100%',
[theme.breakpoints.up('sm')]: {
marginLeft: theme.spacing(1),
width: 'auto',
},
},
searchIcon: {
padding: theme.spacing(0, 0.5),
height: '100%',
position: 'absolute',
pointerEvents: 'none',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
})
);
export const SearchContacts = () => {
const { t } = useTranslation();
const setFilterVal = useSetContactFilterInput();
const [inputVal, setInputVal] = useState('');
const { setFilteredContacts } = useFilteredContacts();
const debouncedVal = useDebounce<string>(inputVal, 500);
const classes = useStyles();
useEffect(() => {
setFilterVal(debouncedVal);
}, [debouncedVal, setFilterVal]);
const handleChange = (e) => {
setFilteredContacts(e.target.value);
};
return (
<Box>
<SearchField
onChange={(e) => setInputVal(e.target.value)}
placeholder={t('APPS_CONTACT_PLACEHOLDER_SEARCH_CONTACTS')}
value={inputVal}
/>
</Box>
<div className={classes.bg}>
<div className={classes.search}>
<div className={classes.searchIcon}>
<SearchIcon style={{ color: '#fff' }} />
</div>
<InputBase
onChange={handleChange}
placeholder='Search contacts...'
classes={{
root: classes.inputRoot,
input: classes.inputInput,
}}
inputProps={{ 'aria-label': 'search' }}
/>
</div>
</div>
);
};
Loaded 100 of 623 files, more files were not shown because too many files have changed in this diff. Show more