Skip to content

Commit

Permalink
Merge branch 'master' into feature/1707-auto-accept
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/build_android.yml
#	android/app/build.gradle
#	ios/CoopCycle/Info.plist
  • Loading branch information
vladimir-8 committed Jun 21, 2024
2 parents 5fb4ede + 80e184d commit 31659fb
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 19 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ on:
description: 'Build Naofood app'
required: true
type: boolean
# build_zampate:
# description: 'Build Zampate app'
# required: true
# type: boolean
build_kooglof:
description: 'Build Kooglof app'
required: true
Expand All @@ -60,6 +56,10 @@ on:
description: 'Build Coursiers Rennais app'
required: true
type: boolean
build_eraman:
description: 'Build Eraman app'
required: true
type: boolean
jobs:
coopcycle:
if: ${{ inputs.build_official }}
Expand Down Expand Up @@ -196,3 +196,18 @@ jobs:
google_play_track: ${{ inputs.google_play_track }}
deploy_google_play: ${{ inputs.deploy_google_play }}
secrets: inherit
eraman:
if: ${{ inputs.build_eraman }}
name: Build Eraman app
uses: ./.github/workflows/fastlane_android.yml
with:
instance: eraman
instance_url: https://eramangasteiz.coopcycle.org
app_name: Eraman
primary_color: "#317764"
package_name: fr.coopcycle.eraman
keystore_key_alias: instance
keystore_key_password_secret: SIGNING_KEY_PASSWORD_INSTANCE
google_play_track: ${{ inputs.google_play_track }}
deploy_google_play: ${{ inputs.deploy_google_play }}
secrets: inherit
16 changes: 16 additions & 0 deletions .github/workflows/build_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ on:
description: 'Build RobinFood app'
required: true
type: boolean
build_lcr:
description: 'Build les coursiers Rennais app'
required: true
type: boolean
jobs:
coopcycle:
if: ${{ inputs.build_official }}
Expand Down Expand Up @@ -92,3 +96,15 @@ jobs:
primary_color: "#ff0000"
google_service_info_plist_base64: GOOGLE_SERVICE_INFO_PLIST_BASE64_ROBINFOOD
secrets: inherit
lcr:
if: ${{ inputs.build_lcr }}
name: Build les coursiers Rennais app
uses: ./.github/workflows/fastlane_ios.yml
with:
instance: lcr
instance_url: https://lcr.coopcycle.org
app_name: Les Coursiers Rennais
app_id: org.coopcycle.LCR
primary_color: "#0A090A"
google_service_info_plist_base64: GOOGLE_SERVICE_INFO_PLIST_BASE64_LCR
secrets: inherit
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled true
versionCode 207
versionName "2.17.3"
versionCode 210
versionName "2.19.1"

manifestPlaceholders = [
tipsiStripeRedirectScheme: "coopcycle",
Expand Down
Binary file added android/fastlane/metadata-eraman/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions ios/CoopCycle/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.17.3</string>
<string>2.19.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -37,7 +37,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>207</string>
<string>146</string>
<key>FacebookAppID</key>
<string>1303550106471840</string>
<key>FacebookClientToken</key>
Expand Down
Binary file added ios/fastlane/metadata-lcr/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,6 @@
"type": "android.attached"
}
}
}
},
"packageManager": "[email protected]+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
}
6 changes: 5 additions & 1 deletion src/navigation/dispatch/UnassignedTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { selectUnassignedTasksNotCancelled } from '../../redux/Dispatch/selector
import AddButton from './components/AddButton';

import { navigateToTask } from '../../navigation/utils';
import moment from 'moment';
import { tasksSort } from '../../shared/src/logistics/redux/taskUtils';

class UnassignedTasks extends Component {
componentDidMount() {
Expand Down Expand Up @@ -52,6 +54,8 @@ class UnassignedTasks extends Component {
const { navigate } = this.props.navigation;
const isEmpty = this.props.unassignedTasks.length === 0;

const unassignedTasks = this.props.unassignedTasks.sort(tasksSort)

return (
<View style={{ flex: 1 }}>
<View>
Expand All @@ -67,7 +71,7 @@ class UnassignedTasks extends Component {
{isEmpty && <TapToRefresh onPress={this.props.loadUnassignedTasks} />}
{!isEmpty && (
<TaskList
tasks={this.props.unassignedTasks}
tasks={unassignedTasks}
tasksWithColor={this.props.tasksWithColor}
swipeOutLeftEnabled={task => !task.isAssigned}
onSwipeLeft={task =>
Expand Down
24 changes: 20 additions & 4 deletions src/redux/Dispatch/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CommonActions } from '@react-navigation/native';
import { Alert } from 'react-native';
import { createAction } from 'redux-actions';

import _ from 'lodash';
import NavigationHolder from '../../NavigationHolder';
import i18n from '../../i18n';
import { connect } from '../middlewares/CentrifugoMiddleware/actions';
Expand All @@ -20,7 +21,7 @@ import {
startTaskSuccess,
} from '../Courier';

import { withLinkedTasks } from '../../shared/src/logistics/redux/taskUtils';
import { withUnassignedLinkedTasks } from '../../shared/src/logistics/redux/taskUtils';
import { isSameDate } from './utils';

/*
Expand Down Expand Up @@ -298,7 +299,7 @@ export function assignTask(task, username) {
return function (dispatch, getState) {
const httpClient = getState().app.httpClient;

const linkedTasks = withLinkedTasks(task, selectAllTasks(getState()));
const linkedTasks = withUnassignedLinkedTasks(task, selectAllTasks(getState()));

if (linkedTasks.length > 1) {
dispatch(bulkAssignmentTasksRequest());
Expand All @@ -325,16 +326,30 @@ export function assignTask(task, username) {
};
}

/**
* Assign several tasks at once (and add the linked tasks)
* @param {Array.Objects} tasks - Tasks to be assigned
* @param {string} username - Username of the rider to which we assign
*
*/
export function bulkAssignmentTasks(tasks, username) {
return function (dispatch, getState) {
const httpClient = getState().app.httpClient;

dispatch(bulkAssignmentTasksRequest());

let tasksToAssign = [];

tasks.forEach((task) => {
tasksToAssign.push(...withUnassignedLinkedTasks(task, selectAllTasks(getState())))
});

const payload = _.uniq(tasksToAssign.map(t => t['@id']));

return httpClient
.put('/api/tasks/assign', {
username,
tasks: tasks.map(t => t['@id']),
tasks: payload,
})
.then(res => dispatch(bulkAssignmentTasksSuccess(res['hydra:member'])))
.catch(e => dispatch(bulkAssignmentTasksFailure(e)));
Expand All @@ -357,7 +372,8 @@ export function unassignTask(task, username) {
export function updateTask(action, task) {
return function (dispatch, getState) {
let date = selectSelectedDate(getState());

console.log(action)
console.log(task)
if (isSameDate(task, date)) {
switch (action) {
case 'task:created':
Expand Down
27 changes: 22 additions & 5 deletions src/shared/src/logistics/redux/taskUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import ColorHash from 'color-hash';
import _, { mapValues } from 'lodash';
import moment from 'moment';


/**
* Utility function to sort a list of tasks
* @param {Object} a - Task
* @param {Object} b - Task
*/
export function tasksSort(a, b) {
if (moment(a.before).isSame(b.before) && a.type === 'PICKUP') {
return -1
} else {
// put on top of the list the tasks that have an end of delivery window that finishes sooner
return moment(a.before).isBefore(b.before) ? -1 : 1
}
}

const colorHash = new ColorHash();

Expand Down Expand Up @@ -36,13 +52,11 @@ export function groupLinkedTasks(tasks) {
}

return mapValues(groups, value => {
value.sort();

return value;
return value.sort(); // sort by task id useless if the dropoff was created before the pickup
});
}

export function withLinkedTasks(task, allTasks) {
function withLinkedTasks(task, allTasks) {
const groups = groupLinkedTasks(allTasks);
const newTasks = [];

Expand All @@ -55,8 +69,11 @@ export function withLinkedTasks(task, allTasks) {
// task with no linked tasks
newTasks.push(task);
}
return newTasks.sort(tasksSort);
}

return newTasks;
export function withUnassignedLinkedTasks(task, allTasks) {
return withLinkedTasks(task, allTasks).filter(t => !t.assignedTo)
}

export function mapToColor(tasks) {
Expand Down

0 comments on commit 31659fb

Please sign in to comment.